	.file	"p3mod.c"
	.section	.text.unlikely,"ax",@progbits
.LCOLDB0:
	.text
.LHOTB0:
	.globl	mulmod
	.type	mulmod, @function
mulmod:
.LFB0:
	.cfi_startproc
	movq     %rsi,%rax	#%rax=x
	xorq     %rsi,%rsi	#%rsi=0
	xchgq    %rdi,%rdx	#%rdx=y,%rdi=%rdx (reserved)
	mulq     %rdx		#%rdx:%rax=x*y
	addq	 %rdx,%rax	#%rax=[x*y]_high+[x*y]_low
	adcq     %rsi,%rax	#if rax>=2^64 then %rax
	movq     %rax,%rdx	#%rdx=%rax
	incq     %rdx		#if %rdx==(-1) then %rax=0
	cmovzq   %rdx,%rax	#return x*y mod (2^64-1)
	xchgq    %rdi,%rdx	#original rdx
	ret
	.cfi_endproc
.LFE0:
	.size	mulmod, .-mulmod
	.section	.text.unlikely
.LCOLDE0:
	.text
.LHOTE0:
	.section	.text.unlikely
.LCOLDB1:
	.text
.LHOTB1:
	.globl	p3mod
	.type	p3mod, @function
p3mod:
.LFB1:
	.cfi_startproc
	movq     %rdi,%rax	#%rax=x
	xorq     %rsi,%rsi	#%rsi=0
	mulq     %rax		#%rdx:%rax=[x*x]
	addq	 %rdx,%rax	#%rax=[x*x]_high+[x*x]_low
	adcq     %rsi,%rax	#if %rax>=2^64 then %rax++
	movq     %rax,%rdx	#%rdx=%rax
	incq     %rdx		#%rdx++
	cmovzq   %rdx,%rax	#if %rdx==0 then %rax=0 (mod 2^64-1)

	movq     %rdi,%rdx	#%rdx=x
	mulq     %rdx		#%rdx:%rax=[x*x*x]
	addq	 %rdx,%rax	#%rax=[x*x*x]_hiht+[x*x*x]_low
	adcq     %rsi,%rax	#if %rax>=2^64 then %rax++
	movq     %rax,%rdx	#%rdx=%rax
	incq     %rdx		#%rdx++
	cmovzq   %rdx,%rax	#if %rdx==0 then %rax=0 (mod 2^64-1)
	ret
	.cfi_endproc
.LFE1:
	.size	p3mod, .-p3mod
	.section	.text.unlikely
.LCOLDE1:
	.text
.LHOTE1:
	.section	.text.unlikely
.LCOLDB2:
	.text
.LHOTB2:
	.globl	addmod
	.type	addmod, @function
addmod:
.LFB2:
	.cfi_startproc
	xorq     %rax,%rax	#%rax=0
	addq     %rdi,%rsi	#%rax=x+y
	adcq     %rsi,%rax	#if %rax>=2^64 then %rax++
	movq     %rax,%rdx	#%rdx=%rax
	incq     %rdx		#%rdx++
	cmovzq   %rdx,%rax	#if %rdx==0 then %rax=0 (mod 2^64-1)
	ret
	.cfi_endproc
.LFE2:
	.size	addmod, .-addmod
	.section	.text.unlikely
.LCOLDE2:
	.text
.LHOTE2:
	.section	.text.unlikely
.LCOLDB3:
	.text
.LHOTB3:
	.globl	addmodq
	.type	addmodq, @function
addmodq:
.LFB3:
	.cfi_startproc
	leaq	(%rdi,%rsi),%rax #%rax=x+y
	movq    %rax,%rdi	 #%rdi=x+y
	subq	%rdx,%rax	 #%rax=x+y-q
	cmova	%rdi,%rax	 #if x+y<q then %rax=x+y
	ret
	.cfi_endproc
.LFE3:
	.size	addmodq, .-addmodq
	.section	.text.unlikely
.LCOLDE3:
	.text
.LHOTE3:
	.section	.text.unlikely
.LCOLDB4:
	.text
.LHOTB4:
	.globl	mulmodq
	.type	mulmodq, @function
mulmodq:
.LFB4:
	.cfi_startproc
	movq	%rdx,%rcx    	#%rsi=x,%rdi=y,%rdx=q 
	movq	%rdi,%rax       #%rax=y
	mulq	%rsi		#%rdx:%rax=x*y
	divq	%rcx		#%rdx=(x*y) mod q
	movq	%rdx,%rax     	#return x*y (mod q)
	ret
	.cfi_endproc
.LFE4:
	.size	mulmodq, .-mulmodq
	.section	.text.unlikely
.LCOLDE4:
	.text
.LHOTE4:
	.section	.text.unlikely
.LCOLDB5:
	.text
.LHOTB5:
	.globl	p3modq
	.type	p3modq, @function
p3modq:
.LFB5:
	.cfi_startproc
	movq	%rdi,%rax	#%rax=x
	mulq	%rdi		#%rdx:%rax=[x*x]
	divq    %rsi		#%rdx=[x*x] mod q
	movq    %rdx,%rax	#%rax=[x*x] mod q
	mulq	%rdi		#%rax=[x*x*x]
	divq    %rsi		#%rdx=[x*x*x] mod q
	movq	%rdx,%rax	#%rax=[x*x*x] mod q
	ret
	.cfi_endproc
.LFE5:
	.size	p3modq, .-p3modq
	.section	.text.unlikely
.LCOLDE5:
	.text
.LHOTE5:
	.section	.text.unlikely
.LCOLDB6:
	.text
.LHOTB6:
	.globl	s3ppm_mod128
	.type	s3ppm_mod128, @function
s3ppm_mod128:
	# UINT s3ppp_mod128(UINT x,UINT y,UINT z);
	#   where 0<=x<=y<=z<2^64
	#   return x^3+y^3-z^3 (mod 2^128) or 0 (overflow LINT)
.LFB7:
	.cfi_startproc
	movq	%rdx,%r8      	#%rsi=x,%rdi=y,%rdx=z,%r8=z
	movq    %rdx,%rax	#%rax=z
	mulq    %rax		#%rdx:%rax=[z*z]
	movq    %rdx,%rcx	#%rcx=[z*z]_high
	mulq    %r8		#%rdx:%rax=[[z*z]_low*z]
	xchgq   %rdx,%rcx	#%rdx=[z*z]_high,%rcx=[[[z*z]_low]*z]_high
	xchgq   %r8,%rax	#%r8=[[z*z]_low*z]_low,%rax=z
	mulq	%rdx		#%rdx:%rax=[[z*z]_high*z]
	addq    %rax,%rcx	#%rcx:%r8=[z^3]

	xorq    %rax,%rax       #%rax=0
	notq    %rcx            #%rcx=~%rcx
	notq    %r8             #%r8=~%r8
	addq    $1,%r8
	adcq    %rax,%rcx	#%rcx:%r8=[-z^3]

	movq	%rdi,%rax	#%rax=y
	mulq	%rax		#%rdx:%rax=[y*y]
	movq	%rdx,%r9	#%r9=[y*y]_high
	mulq    %rdi		#%rdx:%rax=[[y*y]_low*y]
	addq    %rax,%r8	#
	adcq    %rdx,%rcx	#%rcx:%r8+=[[y*y]_low*y]
	movq    %r9,%rax	#%rax=[y*y]_high
	mulq    %rdi		#%rdx:%rax=[[y*y]_high*y]
	addq    %rax,%rcx      	#%rcx:%r8=[-z^3+y^3]

	movq	%rsi,%rax	#%rax=x
	mulq    %rax		#%rdx:%rax=[x*x]
	movq    %rdx,%rdi	#%rdi=[x*x]_high
	mulq    %rsi		#%rdx:%rax=[x*x]_low*x
	addq    %rax,%r8	#
	adcq    %rdx,%rcx	#%rcx:%r8+=[[x*x]_low*x]
	movq    %rdi,%rax	#%rax=[x*x]_high
	mulq    %rsi		#%rdx:%rax=[[x*x]_hight*x]
	addq    %rax,%rcx       #%rcx:%r8=[-z^3+y^3+x^3]
	movq    %r8,%rax	#%rcx:%rax=[-z^3+y^3+x^3]

	xorq    %rdi,%rdi       #%rdi=0
	cmpq    %rdi,%rcx       #%rcx==0?
	jnz     .LFE6      
	shlq	$1,%r8          #case %rcx==0:: %rax should be >=0
	cmovcq	%rdi,%rax       #if %rax<0 then %rax=0
	ret                     #return x^3+y^3-z^3 (mod 2^128) or 0
.LFE6:
        incq    %rcx            #%rcx==(-1)?
	cmovnzq %rdi,%rax       #if %rcx!=0 && %rcx!=(-1) then %rax=0
        shlq    $1,%r8         	#case %rcx==(-1):: %rax should be <0
	cmovncq %rdi,%rax       #if %rax>=0 then %rax=0
	ret
	.cfi_endproc
.LFE7:
	.size	s3ppm_mod128, .-s3ppm_mod128
	.section	.text.unlikely
.LCOLDE6:
	.text
.LHOTE6:
	.section	.text.unlikely
.LCOLDB7:
	.text
.LHOTB7:
	.globl	s3ppp_mod128
	.type	s3ppp_mod128, @function
s3ppp_mod128:
	# UINT s3ppp_mod128(UINT x,UINT y,UINT z);
	#   where 0<=x<=y<=z<2^64
	#   return x^3+y^3+z^3 (mod 2^128) or 0 (overflow UINT)
.LFB9:
	.cfi_startproc
	movq	%rdx,%r8      	#%rsi=x,%rdi=y,%rdx=z,%r8=z
	movq    %rdx,%rax	#%rax=z
	mulq    %rax		#%rdx:%rax=[z*z]
	movq    %rdx,%rcx	#%rcx=[z*z]_high
	mulq    %r8		#%rdx:%rax=[[z*z]_low*z]
	xchgq   %rdx,%rcx	#%rdx=[z*z]_high,%rcx=[[[z*z]_low]*z]_high
	xchgq   %r8,%rax	#%r8=[[z*z]_low*z]_low,%rax=z
	mulq	%rdx		#%rdx:%rax=[[z*z]_high*z]
	addq    %rax,%rcx	#%rcx:%r8=[z^3]

	movq	%rdi,%rax	#%rax=y
	mulq	%rax		#%rdx:%ax=[y*y]
	movq	%rdx,%r9	#%r9=[y*y]_high
	mulq    %rdi		#%rdx:%rax=[[y*y]_low*y]
	addq    %rax,%r8	#
	adcq    %rdx,%rcx	#%rcx:%r8 += [[y*y]_low*y]
	movq    %r9,%rax	#%rax=[y*y]_high
	mulq    %rdi		#%rdx:%rax=[[y*y]_high*y]
	addq    %rax,%rcx      	#%rcx:%r8=[z^3+y^3]

	movq	%rsi, %rax	#%rax=x
	mulq    %rax		#%rdx:%rax=[x*x]
	movq    %rdx,%rdi	#%rdi=[x*x]_high
	mulq    %rsi		#%rdx:%rax=[x*x]_low*x
	addq    %rax,%r8	#
	adcq    %rdx,%rcx	#%rcx:%r8=[z^3+y^3]+[[x*x]_low*x]
	movq    %rdi,%rax	#%rax=[x*x]_high
	xorq    %rdi,%rdi       #%rdi=0
	mulq    %rsi		#%rdx:%rax=[[x*x]_high*x]
	xchgq   %r8,%rax        #%rcx:%rax=[z^3+y^3]+[[x*x]_low*x]
	                        #%r8=[[x*x]_high*x]_low
	addq    %r8,%rcx	#%rcx:%rax=[z^3+y^3+x^3]

	cmovnzq	%rdi,%rax       #if %rdx!=0 then %rax=0
	ret                     #return x^3+y^3+z^3 (mod 2^128) or 0
	.cfi_endproc
.LFE9:
	.size	s3ppp_mod128, .-s3ppp_mod128
	.section	.text.unlikely
.LCOLDE7:
	.text
.LHOTE7:
	.globl	s3ppp_mod128a
	.type	s3ppp_mod128a, @function
s3ppp_mod128a:
	# UINT s3ppp_mod128a(UINT x,UINT y,UINT z);
	#      where 0<=x<=y<=z<2^32 i.e. 0<=z*z<2^64
	#		0<=x^3+y^3+^3<3*2^96<2^128
	# return x^3+y^3+z^3 (mod 2^128) or 0(overflow UINT)
.LFB11:
	.cfi_startproc
	movq	%rdx,%r8      	#%rsi=x,%rdi=y,%rdx=z,%r8=z
	movq    %rdx,%rax	#%rax=z
	mulq    %rax		#%rdx:%rax=[z*z]
	mulq    %r8		#%rdx:%rax=[z*z*z]
	movq    %rdx,%rcx	#%rcx=[z*z*z]_high
	movq    %rax,%r8	#%r8=[z*z*z]_low

	movq	%rdi,%rax	#%rax=y
	mulq	%rax		#%rdx:%ax=[y*y]
	mulq    %rdi		#%rdx:%rax=[y*y*y]
	addq    %rax,%r8	#
	adcq    %rdx,%rcx	#%rcx:%r8 = [z^3+y^3]

	movq	%rsi, %rax	#%rax=x
	mulq    %rax		#%rdx:%rax=[x*x]
	mulq    %rsi		#%rdx:%rax=[x*x*x]
	addq    %rax,%r8	#
	adcq    %rdx,%rcx	#%rcx:%r8=[z^3+y^3+x^3]
	movq    %r8,%rax	#%rcx:%rax=[z^3+y^3+x^3]

	cmovnzq	%rdi,%rax       #if %rcx!=0 then %rax=0
	ret                     #return x^3+y^3+z^3 (mod 2^128) or 0
	.cfi_endproc
.LFE11:
	.size	s3ppp_mod128a, .-s3ppp_mod128a
	.section	.text.unlikely
.LCOLDE11:
	.text
.LHOTE11:
	.globl	s3ppm_mod128a
	.type	s3ppm_mod128a, @function
s3ppm_mod128a:
	# UINT s3ppm_mod128a(UINT x,UINT y,UINT z);
	#      where 0<=x<=y<=z<2^32 i.e. 0<=z*z<2^64
	#            |x^3+y^3-z^3|<3*2^96<2^127
	# return x^3+y^3-z^3 (mod 2^128) or 0(overflow LINT)
.LFB13:
	.cfi_startproc
	movq	%rdx,%rcx     	#%rsi=x,%rdi=y,%rdx=z,%rcx=z
	movq    %rdx,%rax	#%rax=z
	mulq    %rax		#%rdx:%rax=[z*z], where rdx=0
	mulq    %rcx		#%rdx:%rax=[z*z*z]
	movq	%rdx,%rcx	#%rcx=[z*z*z]_high
	movq	%rax,%r8	#%rcx:%r8=[z*z*z]
	xorq    %rax,%rax       #%rax=0
	notq    %rcx            #%rcx=~%rcx
	notq    %r8             #%r8=~%r8
	addq    $1,%r8
	adcq    %rax,%rcx	#%rcx:%r8=[-z^3]

	movq	%rdi,%rax	#%rax=y
	mulq	%rax		#%rdx:%rax=[y*y]
	mulq    %rdi		#%rdx:%rax=[y*y*y]
	addq    %rax,%r8	#
	adcq    %rdx,%rcx	#%rcx:%r8+=[y*y*y]

	movq	%rsi,%rax	#%rax=x
	mulq    %rax		#%rdx:%rax=[x*x]
	mulq    %rsi		#%rdx:%rax=[x*x*x]
	addq    %rax,%r8	#
	adcq    %rdx,%rcx	#%rcx:%r8+=[x*x*x]
	movq    %rcx,%rax       #%rcx:%r8=[-z^3+y^3+x^3]
	movq    %r8,%rax	#%rcx:%rax=[-z^3+y^3+x^3]
				#%r8=[x^3+y^3-z^3]_low

	xorq    %rdi,%rdi       #%rdi=0
	cmpq    %rdi,%rcx       #%rcx==0?
	jnz     .LFE12      
	shlq	$1,%r8          #case %rcx==0:: %rax should be >=0
	cmovcq	%rdi,%rax       #if %rax<0 then %rax=0
	ret                     #return x^3+y^3-z^3 (mod 2^128) or 0
.LFE12:
        incq    %rcx            #%rcx==(-1)?
	cmovnzq %rdi,%rax       #if %rcx!=0 && %rcx!=(-1) then %rax=0
        shlq    $1,%r8         	#case %rcx==(-1):: %rax should be <0
	cmovncq %rdi,%rax       #if %rax>=0 then %rax=0
	ret
	.cfi_endproc
.LFE13:
	.size	s3ppm_mod128, .-s3ppm_mod128
	.section	.text.unlikely
.LCOLDE8:
	.text
.LHOTE8:
	.section	.text.unlikely
.LCOLDB9:
	.text
.LHOTE9:
	.ident	"GCC: (nb2 20180327) 5.5.0"
