// File: /workspace/github_cpp_makefile_star2_O2/menhits[P]phplus/src/PhplusStdLib.cpp
// Function: populateIntArrayAndFuncs()
void populateIntArrayAndFuncs()
{
	TupleTypeMaker maker;
	maker.add("_size", Int);
	maker.add("_data", Int->getPtr());
	IntArray=maker.get(false);
	
	addType(IntArray, "IntArray");
	
	//func("IntArray", IntArray, Void, Int,
	//	retrn Tuple(right, (double)((int*)malloc(Int->getSize()*right)));
	//);
	
	addAction("IntArray", Void, Int, IntArray, LAMBDA_HEADER
		{
			char* out=(char*)malloc(IntArray->getSize());
			int sizeIn=*(int*)rightIn;
			int* intPtrData=(int *)malloc(Int->getSize()*sizeIn);
			setValInTuple<int>(out, IntArray, "_size", sizeIn);
			setValInTuple<int *>(out, IntArray, "_data", intPtrData);
			return out;
		},
		ADD_CPP_HEADER
		{
			addToProgMakeIntArray(prog);
			prog->name("$makeIntArray");
			prog->pushExpr();
				right->addToProg(prog);
			prog->popExpr();
		}
	);
	
	addAction("len", IntArray, Void, Int,
		LAMBDA_HEADER
		{
			int* out=(int*)malloc(sizeof(int));
			*out=getValFromTuple<int>(leftIn, IntArray, "_size");
			return out;
		},
		ADD_CPP_HEADER
		{
			getElemFromTupleAction(IntArray, "_size")->addToProg(left, voidAction, prog);
		}
	);
	
	addAction("get", IntArray, Int, Int, LAMBDA_HEADER
		{
			int pos=*(int*)rightIn;
			int size=getValFromTuple<int>(leftIn, IntArray, "_size");
			if (pos<0 || pos>=size)
				throw PhplusError("tried to acces position "+to_string(pos)+" of array "+to_string(size)+" long", RUNTIME_ERROR);
			int* arrayPtr=getValFromTuple<int*>(leftIn, IntArray, "_data");
			int val=*(arrayPtr+pos);
			int* out=(int*)malloc(sizeof(int));
			*out=val;
			return out;
		},
		ADD_CPP_HEADER
		{
			getElemFromTupleAction(IntArray, "_data")->addToProg(left, voidAction, prog);
			prog->code("[");
			prog->pushExpr();
				right->addToProg(prog);
			prog->popExpr();
			prog->code("]");
		}
	);
	
	addAction("set", IntArray, PNCN_Tuple(Int, Int), Void,
		LAMBDA_HEADER
		{
			Type rightType=PNCN_Tuple(Int, Int);
			int pos=getValFromTuple<int>(rightIn, rightType, "a");
			int size=getValFromTuple<int>(leftIn, IntArray, "_size");
			if (pos<0 || pos>=size)
				throw PhplusError("tried to set value at position "+to_string(pos)+" of array "+to_string(size)+" long", RUNTIME_ERROR);
			int val=getValFromTuple<int>(rightIn, rightType, "b");
			int* arrayPtr=getValFromTuple<int*>(leftIn, IntArray, "_data");
			*(arrayPtr+pos)=val;
			return nullptr;
		},
		ADD_CPP_HEADER
		{
			getElemFromTupleAction(IntArray, "_data")->addToProg(left, voidAction, prog);
			prog->code("[");
			prog->pushExpr();
				getElemFromTupleAction(right->getReturnType(), "a")->addToProg(right, voidAction, prog);
			prog->popExpr();
			prog->code("]");
			prog->code(" = ");
			getElemFromTupleAction(right->getReturnType(), "b")->addToProg(right, voidAction, prog);
		}
	);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x2e8, %rsp            # imm = 0x2E8
leaq 0x10(%rsp), %rdi
callq 0x3e21a
leaq 0x2a3a9(%rip), %rsi     # 0x57b1c
leaq 0x1c0(%rsp), %rdi
leaq 0x120(%rsp), %rdx
callq 0xa150
leaq 0x4cc91(%rip), %rbx     # 0x7a420
leaq 0xf8(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x12c0a
leaq 0x10(%rsp), %rdi
leaq 0x1c0(%rsp), %rsi
movq %r14, %rdx
callq 0x3e26e
leaq 0x100(%rsp), %rdi
callq 0xc984
leaq 0x1c0(%rsp), %rdi
callq 0xa558
leaq 0x2a6df(%rip), %rsi     # 0x57eb7
leaq 0x1a0(%rsp), %rdi
leaq 0x120(%rsp), %rdx
callq 0xa150
movq (%rbx), %rsi
leaq 0x48(%rsp), %rdi
callq 0x3dce8
leaq 0x10(%rsp), %rdi
leaq 0x1a0(%rsp), %rsi
leaq 0x48(%rsp), %rdx
callq 0x3e26e
leaq 0x50(%rsp), %rdi
callq 0xc984
leaq 0x1a0(%rsp), %rdi
callq 0xa558
leaq 0x120(%rsp), %rdi
leaq 0x10(%rsp), %rsi
xorl %edx, %edx
callq 0x3e5ae
leaq 0x4cb3d(%rip), %rbx     # 0x7a380
leaq 0x120(%rsp), %rsi
movq %rbx, %rdi
callq 0x135a2
leaq 0x128(%rsp), %rdi
callq 0xc984
leaq 0x38(%rsp), %rdi
movq %rbx, %rsi
callq 0x12c0a
leaq 0x2a267(%rip), %rsi     # 0x57adb
leaq 0x180(%rsp), %rdi
leaq 0x120(%rsp), %rdx
callq 0xa150
leaq 0x38(%rsp), %rdi
leaq 0x180(%rsp), %rsi
callq 0x23237
leaq 0x180(%rsp), %rdi
callq 0xa558
leaq 0x40(%rsp), %rdi
callq 0xc984
leaq 0x4cb27(%rip), %rsi     # 0x7a3e0
leaq 0xe8(%rsp), %rbx
movq %rbx, %rdi
callq 0x12c0a
leaq 0x4cb50(%rip), %rsi     # 0x7a420
leaq 0xd8(%rsp), %r14
movq %r14, %rdi
callq 0x12c0a
leaq 0x4ca99(%rip), %rsi     # 0x7a380
leaq 0xc8(%rsp), %r15
movq %r15, %rdi
callq 0x12c0a
xorps %xmm0, %xmm0
leaq 0x2c0(%rsp), %r8
movaps %xmm0, (%r8)
leaq 0xa14b(%rip), %rax      # 0x37a58
movq %rax, 0x18(%r8)
leaq 0xa27a(%rip), %rax      # 0x37b92
movq %rax, 0x10(%r8)
leaq 0x2a0(%rsp), %r9
movaps %xmm0, (%r9)
leaq 0xa27b(%rip), %rax      # 0x37baa
movq %rax, 0x18(%r9)
leaq 0xa33e(%rip), %rax      # 0x37c78
movq %rax, 0x10(%r9)
leaq 0x2a196(%rip), %rdi     # 0x57adb
movq %rbx, %rsi
movq %r14, %rdx
movq %r15, %rcx
callq 0x39f90
leaq 0x2a0(%rsp), %rdi
callq 0x182be
leaq 0x2c0(%rsp), %rdi
callq 0x182be
leaq 0xd0(%rsp), %rdi
callq 0xc984
leaq 0xe0(%rsp), %rdi
callq 0xc984
leaq 0xf0(%rsp), %rdi
callq 0xc984
leaq 0x4c9e5(%rip), %rsi     # 0x7a380
leaq 0xb8(%rsp), %rbx
movq %rbx, %rdi
callq 0x12c0a
leaq 0x4ca2e(%rip), %rsi     # 0x7a3e0
leaq 0xa8(%rsp), %r14
movq %r14, %rdi
callq 0x12c0a
leaq 0x4ca57(%rip), %rsi     # 0x7a420
leaq 0x98(%rsp), %r15
movq %r15, %rdi
callq 0x12c0a
leaq 0x280(%rsp), %r8
xorps %xmm0, %xmm0
movaps %xmm0, (%r8)
leaq 0xa2a1(%rip), %rax      # 0x37c90
movq %rax, 0x18(%r8)
leaq 0xa32a(%rip), %rax      # 0x37d24
movq %rax, 0x10(%r8)
leaq 0x260(%rsp), %r9
movaps %xmm0, (%r9)
leaq 0xa32b(%rip), %rax      # 0x37d3c
movq %rax, 0x18(%r9)
leaq 0xa486(%rip), %rax      # 0x37ea2
movq %rax, 0x10(%r9)
leaq 0x2a321(%rip), %rdi     # 0x57d48
movq %rbx, %rsi
movq %r14, %rdx
movq %r15, %rcx
callq 0x39f90
leaq 0x260(%rsp), %rdi
callq 0x182be
leaq 0x280(%rsp), %rdi
callq 0x182be
leaq 0xa0(%rsp), %rdi
callq 0xc984
leaq 0xb0(%rsp), %rdi
callq 0xc984
leaq 0xc0(%rsp), %rdi
callq 0xc984
leaq 0x4c903(%rip), %rsi     # 0x7a380
leaq 0x88(%rsp), %rbx
movq %rbx, %rdi
callq 0x12c0a
leaq 0x4c98c(%rip), %r14     # 0x7a420
leaq 0x78(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x12c0a
leaq 0x68(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x12c0a
xorps %xmm0, %xmm0
leaq 0x240(%rsp), %r8
movaps %xmm0, (%r8)
leaq 0xa3f0(%rip), %rax      # 0x37eba
movq %rax, 0x18(%r8)
leaq 0xa645(%rip), %rax      # 0x3811a
movq %rax, 0x10(%r8)
leaq 0x220(%rsp), %r9
movaps %xmm0, (%r9)
leaq 0xa646(%rip), %rax      # 0x38132
movq %rax, 0x18(%r9)
leaq 0xa83b(%rip), %rax      # 0x38332
movq %rax, 0x10(%r9)
leaq 0x2a261(%rip), %rdi     # 0x57d63
movq %rbx, %rsi
movq %r15, %rdx
movq %r12, %rcx
callq 0x39f90
leaq 0x220(%rsp), %rdi
callq 0x182be
leaq 0x240(%rsp), %rdi
callq 0x182be
leaq 0x70(%rsp), %rdi
callq 0xc984
leaq 0x80(%rsp), %rdi
callq 0xc984
leaq 0x90(%rsp), %rdi
callq 0xc984
leaq 0x4c82b(%rip), %rsi     # 0x7a380
leaq 0x28(%rsp), %rdi
callq 0x12c0a
leaq 0x2a355(%rip), %rsi     # 0x57ebb
leaq 0x120(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0xa150
leaq 0x140(%rsp), %rdi
leaq 0x4c899(%rip), %rsi     # 0x7a420
callq 0x12c0a
leaq 0x150(%rsp), %rdi
leaq 0x298b7(%rip), %rsi     # 0x57452
leaq 0xe(%rsp), %rdx
callq 0xa150
leaq 0x170(%rsp), %rdi
leaq 0x4c86c(%rip), %rsi     # 0x7a420
callq 0x12c0a
leaq 0x108(%rsp), %rdi
leaq 0x120(%rsp), %rsi
pushq $0x2
popq %rdx
leaq 0xd(%rsp), %rcx
callq 0x39d84
leaq 0x18(%rsp), %rdi
leaq 0x108(%rsp), %rsi
pushq $0x1
popq %rdx
callq 0x3e156
leaq 0x4c7ee(%rip), %rsi     # 0x7a3e0
leaq 0x58(%rsp), %rbx
movq %rbx, %rdi
callq 0x12c0a
xorps %xmm0, %xmm0
leaq 0x200(%rsp), %r8
movaps %xmm0, (%r8)
leaq 0xa735(%rip), %rax      # 0x3834a
movq %rax, 0x18(%r8)
leaq 0xaba0(%rip), %rax      # 0x387c0
movq %rax, 0x10(%r8)
leaq 0x1e0(%rsp), %r9
movaps %xmm0, (%r9)
leaq 0xaba1(%rip), %rax      # 0x387d8
movq %rax, 0x18(%r9)
leaq 0xaff2(%rip), %rax      # 0x38c34
movq %rax, 0x10(%r9)
leaq 0x26a15(%rip), %rdi     # 0x54662
leaq 0x28(%rsp), %rsi
leaq 0x18(%rsp), %rdx
movq %rbx, %rcx
callq 0x39f90
leaq 0x1e0(%rsp), %rdi
callq 0x182be
leaq 0x200(%rsp), %rdi
callq 0x182be
leaq 0x60(%rsp), %rdi
callq 0xc984
leaq 0x20(%rsp), %rdi
callq 0xc984
leaq 0x108(%rsp), %rdi
callq 0x12f12
pushq $0x30
popq %rbx
leaq (%rsp,%rbx), %rdi
addq $0x120, %rdi            # imm = 0x120
callq 0x12f68
addq $-0x30, %rbx
cmpq $-0x30, %rbx
jne 0x2dc9d
leaq 0x30(%rsp), %rdi
callq 0xc984
leaq 0x10(%rsp), %rdi
callq 0x12ede
addq $0x2e8, %rsp            # imm = 0x2E8
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq %rax, %rbx
leaq 0x1e0(%rsp), %rdi
callq 0x182be
leaq 0x200(%rsp), %rdi
callq 0x182be
leaq 0x60(%rsp), %rdi
callq 0xc984
leaq 0x20(%rsp), %rdi
callq 0xc984
jmp 0x2dd10
movq %rax, %rbx
leaq 0x108(%rsp), %rdi
callq 0x12f12
jmp 0x2dd22
movq %rax, %rbx
pushq $0x30
popq %r14
leaq (%rsp,%r14), %rdi
addq $0x120, %rdi            # imm = 0x120
callq 0x12f68
addq $-0x30, %r14
cmpq $-0x30, %r14
jne 0x2dd26
jmp 0x2dd57
movq %rax, %rbx
leaq 0x120(%rsp), %rdi
callq 0x12f68
jmp 0x2dd57
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
jmp 0x2de3e
movq %rax, %rbx
leaq 0x220(%rsp), %rdi
callq 0x182be
leaq 0x240(%rsp), %rdi
callq 0x182be
leaq 0x70(%rsp), %rdi
callq 0xc984
leaq 0x80(%rsp), %rdi
callq 0xc984
leaq 0x90(%rsp), %rdi
jmp 0x2de3e
movq %rax, %rbx
leaq 0x260(%rsp), %rdi
callq 0x182be
leaq 0x280(%rsp), %rdi
callq 0x182be
leaq 0xa0(%rsp), %rdi
callq 0xc984
leaq 0xb0(%rsp), %rdi
callq 0xc984
leaq 0xc0(%rsp), %rdi
jmp 0x2de3e
movq %rax, %rbx
leaq 0x2a0(%rsp), %rdi
callq 0x182be
leaq 0x2c0(%rsp), %rdi
callq 0x182be
leaq 0xd0(%rsp), %rdi
callq 0xc984
leaq 0xe0(%rsp), %rdi
callq 0xc984
leaq 0xf0(%rsp), %rdi
jmp 0x2de3e
movq %rax, %rbx
leaq 0x180(%rsp), %rdi
callq 0xa558
jmp 0x2de39
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0xc984
jmp 0x2de87
jmp 0x2de84
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0xc984
jmp 0x2de59
movq %rax, %rbx
leaq 0x1a0(%rsp), %rdi
jmp 0x2de7d
jmp 0x2de84
movq %rax, %rbx
leaq 0x100(%rsp), %rdi
callq 0xc984
leaq 0x1c0(%rsp), %rdi
callq 0xa558
jmp 0x2de87
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x12ede
movq %rbx, %rdi
callq 0xa500