
typedef long long LL;

__device__ 
int cuda_field_modulus;

__device__
int inverse(int a, int p){
	return a == 1 ? 1 : ((LL)(a-inverse(p%a, a))*p+1)/a;
}

__device__
void cuda_field_init(int m){
	cuda_field_modulus = m;
}

struct cuda_field_element {
	__device__
	cuda_field_element(){}
	
	__device__
	cuda_field_element(const cuda_field_element &v) : value(v.value) {}

	__device__
	cuda_field_element(int v) : value(v) { value %= cuda_field_modulus; }


	__device__
	cuda_field_element& operator=(const cuda_field_element &v){ value = v.value; return *this; }

	__device__
	cuda_field_element& operator+=(const cuda_field_element &v){
		value += v.value; if(value >= cuda_field_modulus) value -= cuda_field_modulus; return *this;
	}

	__device__
	cuda_field_element& operator-=(const cuda_field_element &v){
		value -= v.value; if(value < 0) value += cuda_field_modulus; return *this;
	}

	__device__
	cuda_field_element& operator*=(const cuda_field_element &v){ value = (LL)value * v.value % cuda_field_modulus; return *this; }
	

	__device__
	cuda_field_element operator+(const cuda_field_element &v) const { return cuda_field_element(*this) += v; }

	__device__
	cuda_field_element operator-(const cuda_field_element &v) const { return cuda_field_element(*this) -= v; }

	__device__
	cuda_field_element operator*(const cuda_field_element &v) const { return cuda_field_element(*this) *= v; }


	__device__
	cuda_field_element operator-() const { return value == 0 ? 0 : cuda_field_modulus - value; }

	__device__
	cuda_field_element operator~() const { return inverse(value, cuda_field_modulus); }


	__device__
	bool operator==(const cuda_field_element &v) const { return value == v.value; }

	__device__
	bool operator!=(const cuda_field_element &v) const { return value != v.value; }


	__device__
	int get_value() const { return value; }

private:
	int value;
};

	.file	"tmpxft_0024f50f_00000000-6_cuda_field.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2033:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2033:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z7inverseii
	.type	_Z7inverseii, @function
_Z7inverseii:
.LFB2008:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2008:
	.size	_Z7inverseii, .-_Z7inverseii
	.globl	_Z15cuda_field_initi
	.type	_Z15cuda_field_initi, @function
_Z15cuda_field_initi:
.LFB2009:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2009:
	.size	_Z15cuda_field_initi, .-_Z15cuda_field_initi
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"cuda_field_modulus"
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2056:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	movl	$4, %r9d
	xorl	%r8d, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC0(%rip), %rdx
	movq	%rax, %rdi
	leaq	_ZL18cuda_field_modulus(%rip), %rsi
	movq	%rdx, %rcx
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterVar@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 24
	popq	%rcx
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rsi
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2056:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.local	_ZL18cuda_field_modulus
	.comm	_ZL18cuda_field_modulus,4,4
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:


#include <hip/hip_runtime.h>

typedef long long LL;

__device__ 
int cuda_field_modulus;

__device__
int inverse(int a, int p){
	return a == 1 ? 1 : ((LL)(a-inverse(p%a, a))*p+1)/a;
}

__device__
void cuda_field_init(int m){
	cuda_field_modulus = m;
}

struct cuda_field_element {
	__device__
	cuda_field_element(){}
	
	__device__
	cuda_field_element(const cuda_field_element &v) : value(v.value) {}

	__device__
	cuda_field_element(int v) : value(v) { value %= cuda_field_modulus; }


	__device__
	cuda_field_element& operator=(const cuda_field_element &v){ value = v.value; return *this; }

	__device__
	cuda_field_element& operator+=(const cuda_field_element &v){
		value += v.value; if(value >= cuda_field_modulus) value -= cuda_field_modulus; return *this;
	}

	__device__
	cuda_field_element& operator-=(const cuda_field_element &v){
		value -= v.value; if(value < 0) value += cuda_field_modulus; return *this;
	}

	__device__
	cuda_field_element& operator*=(const cuda_field_element &v){ value = (LL)value * v.value % cuda_field_modulus; return *this; }
	

	__device__
	cuda_field_element operator+(const cuda_field_element &v) const { return cuda_field_element(*this) += v; }

	__device__
	cuda_field_element operator-(const cuda_field_element &v) const { return cuda_field_element(*this) -= v; }

	__device__
	cuda_field_element operator*(const cuda_field_element &v) const { return cuda_field_element(*this) *= v; }


	__device__
	cuda_field_element operator-() const { return value == 0 ? 0 : cuda_field_modulus - value; }

	__device__
	cuda_field_element operator~() const { return inverse(value, cuda_field_modulus); }


	__device__
	bool operator==(const cuda_field_element &v) const { return value == v.value; }

	__device__
	bool operator!=(const cuda_field_element &v) const { return value != v.value; }


	__device__
	int get_value() const { return value; }

private:
	int value;
};

	.text
	.file	"cuda_field.hip"
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB0_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB0_2:
	movl	$cuda_field_modulus, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movl	$4, %r9d
	xorl	%r8d, %r8d
	pushq	$0
	.cfi_adjust_cfa_offset 8
	pushq	$0
	.cfi_adjust_cfa_offset 8
	callq	__hipRegisterVar
	addq	$16, %rsp
	.cfi_adjust_cfa_offset -16
	movl	$__hip_module_dtor, %edi
	popq	%rax
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end0:
	.size	__hip_module_ctor, .Lfunc_end0-__hip_module_ctor
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_dtor
	.type	__hip_module_dtor,@function
__hip_module_dtor:                      # @__hip_module_dtor
	.cfi_startproc
# %bb.0:
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	je	.LBB1_2
# %bb.1:
	pushq	%rax
	.cfi_def_cfa_offset 16
	callq	__hipUnregisterFatBinary
	movq	$0, __hip_gpubin_handle(%rip)
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
.LBB1_2:
	retq
.Lfunc_end1:
	.size	__hip_module_dtor, .Lfunc_end1-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	cuda_field_modulus,@object      # @cuda_field_modulus
	.local	cuda_field_modulus
	.comm	cuda_field_modulus,4,4
	.type	.L__unnamed_1,@object           # @0
	.section	.rodata.str1.1,"aMS",@progbits,1
.L__unnamed_1:
	.asciz	"cuda_field_modulus"
	.size	.L__unnamed_1, 19

	.type	__hip_fatbin_wrapper,@object    # @__hip_fatbin_wrapper
	.section	.hipFatBinSegment,"a",@progbits
	.p2align	3, 0x0
__hip_fatbin_wrapper:
	.long	1212764230                      # 0x48495046
	.long	1                               # 0x1
	.quad	__hip_fatbin
	.quad	0
	.size	__hip_fatbin_wrapper, 24

	.type	__hip_gpubin_handle,@object     # @__hip_gpubin_handle
	.local	__hip_gpubin_handle
	.comm	__hip_gpubin_handle,8,8
	.section	.init_array,"aw",@init_array
	.p2align	3, 0x0
	.quad	__hip_module_ctor
	.type	__hip_cuid_,@object             # @__hip_cuid_
	.bss
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               # 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym cuda_field_modulus
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.protected	cuda_field_modulus      ; @cuda_field_modulus
	.type	cuda_field_modulus,@object
	.section	.bss,"aw",@nobits
	.globl	cuda_field_modulus
	.p2align	2, 0x0
cuda_field_modulus:
	.long	0                               ; 0x0
	.size	cuda_field_modulus, 4

	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym cuda_field_modulus
	.addrsig_sym __hip_cuid_
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.amdgpu_metadata
---
amdhsa.kernels:  []
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
