// File: /workspace/github_cpp_makefile_star2_O1/Alcaro[P]bridges/ui-arlib.cpp
// Function: main
int main(int argc, char** argv)
{
	static uint32_t pixels[640*480]; // static to keep the stack frame small
	image out; // initialized up here so perf-ui can use it too
	out.init_ptr(pixels, 640, 480, sizeof(uint32_t)*640, ifmt_xrgb8888); // xrgb is faster than 0rgb
	
#ifndef STDOUT_ERROR
	argparse args;
	bool do_bench_solv = false;
	args.add("perf-solv", &do_bench_solv);
	bool do_bench_ui = false;
	args.add("perf-ui", &do_bench_ui);
	args.parse(argv);
	
	if (do_bench_solv && do_bench_ui)
	{
		puts("can't benchmark both solver and UI");
		return 1;
	}
	if (do_bench_solv)
	{
		g_rand.seed(0);
		bool vg = RUNNING_ON_VALGRIND;
		uint64_t start = time_ms_ne();
		
		int nsolv = 0;
		int nunsolv = 0;
		int nmultisolv = 0;
		for (int side=3;side<10;side++)
		{
			for (int i=0;i<(vg ? 1000 : 10000);i++) // ignore benchmark, we want iteration count constant between runs
			{
				if (i%(vg ? 10 : 100) == 0) { printf("%i %i     \r", side, i); fflush(stdout); }
				
				gamemap::genparams par = {};
				par.width = side;
				par.height = side;
				par.density = 0.4;
				par.dense = true;
				par.use_reef = false;
				par.use_large = false;
				par.use_castle = false;
				par.allow_ambiguous = true;
				par.difficulty = 0.0;
				par.quality = 1;
				
				gamemap map;
				map.generate(par);
				map.reset();
				int result = 0;
				if (map.solve())
				{
					result = 1;
					if (map.solve_another()) result = 2;
				}
				
				if (result == 0)
				{
					puts("ERROR");
					puts(map.serialize());
					exit(1);
				}
				if (result == 0) nunsolv++;
				if (result == 1) nsolv++;
				if (result == 2) nmultisolv++;
			}
		}
		uint64_t end = time_ms_ne();
		//expected (with side = 3..9, i = 0..9999, generate.cpp md5 f32cac429a654b96cc327086541aac4b):
		//41535 solvable, 0 unsolvable, 28465 multiple solutions, took 7266 ms
		printf("%i solvable, %i unsolvable, %i multiple solutions, took %u ms\n",
		       nsolv, nunsolv, nmultisolv, (unsigned)(end-start));
		
		return 0;
	}
	if (do_bench_ui)
	{
		game* g = game::create();
		game::input in = {};
		game::input in_press = {};
		in_press.keys = 1 << game::k_confirm;
		
		using (benchmark b)
		{
			while (b) g->run(in, out);
			printf("title screen: %u frames in %ums = %ffps\n", b.iterations, b.us/1000, b.per_second());
		}
		
		g->run(in_press, out);
		
		using (benchmark b)
		{
			while (b) g->run(in, out);
			printf("level select: %u frames in %ums = %ffps\n", b.iterations, b.us/1000, b.per_second());
		}
		
		g->run(in_press, out);
		
		using (benchmark b)
		{
			while (b) g->run(in, out);
			printf("ingame: %u frames in %ums = %ffps\n", b.iterations, b.us/1000, b.per_second());
		}
		
		return 0;
	}
#endif
	
	aropengl gl;
	autoptr<gameview> gv = gameview::create(gl, 640, 480, aropengl::t_ver_1_0/*|aropengl::t_direct3d_vsync*/, "bridges");
	gl.swapInterval(1);
	
	gl.MatrixMode(GL_PROJECTION);
	gl.LoadIdentity();
	gl.Ortho(0, 640, 0, 480, -1.0, 1.0);
	gl.Viewport(0, 0, 640, 480);
	
	gl.MatrixMode(GL_MODELVIEW);
	gl.LoadIdentity();
	
	gl.Enable(GL_TEXTURE_2D);
	GLuint tex;
	gl.GenTextures(1, &tex);
	gl.BindTexture(GL_TEXTURE_2D, tex);
	
	gl.TexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, 1024, 512, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
	gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
	gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
	
	// save support not implemented here, just hardcode something reasonable
	// the long-term plan has always been making this game a libretro core, this frontend is mostly a far-too-long-lived placeholder
	static const uint8_t save[] = { 31,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
	autoptr<game> g = game::create(save);
	game::input in = {};
	
	gv->keys_cb([&in](int scancode, gameview::key_t key, bool down) {
//printf("key %d,%d,%d\n",scancode,key,down);
		int bit;
		if(0);
		else if (key == gameview::K_RIGHT  || key == gameview::K_d)         bit = game::k_right;
		else if (key == gameview::K_UP     || key == gameview::K_w)         bit = game::k_up;
		else if (key == gameview::K_LEFT   || key == gameview::K_a)         bit = game::k_left;
		else if (key == gameview::K_DOWN   || key == gameview::K_s)         bit = game::k_down;
		else if (key == gameview::K_RETURN || key == gameview::K_SPACE)     bit = game::k_confirm;
		else if (key == gameview::K_ESCAPE || key == gameview::K_BACKSPACE) bit = game::k_cancel;
		else return;
		
		in.keys = (in.keys & ~(1<<bit)) | (down << bit);
	});
	
	gv->mouse_cb([&in](int x, int y, uint8_t buttons) {
//printf("mouse %d,%d,%d\n",x,y,buttons);
		in.mousex = x;
		in.mousey = y;
		in.lmousedown = (buttons&1);
		in.rmousedown = (buttons&2);
	});
	
	bool first = true;
	bool active = true;
	
	//time_t t=0;
	//int fps=0;
	
	while (gv->running())
	{
		//fps++;
		//if (t != time(NULL))
		//{
//printf("%dfps\n",fps);
			//fps = 0;
			//t = time(NULL);
		//}
		
		if (active)
		{
#if defined(ARLIB_OPT) && !defined(STDOUT_ERROR)
			timer t;
#endif
			int do_upload = g->run(in, out, !first);
			first = false;
#if defined(ARLIB_OPT) && !defined(STDOUT_ERROR)
			if (t.us() >= 2500)
				printf("rendered in %uus\n", (unsigned)t.us());
#endif
			if (do_upload > 0) gl.TexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 640, 480, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, pixels);
			active = (do_upload >= 0);
		}
		
		//redraw the texture, to avoid glitches if compositor discarded our pixels
		//no point reuploading, and no point checking why gv->tmp_step returned, just redraw
		gl.Clear(GL_COLOR_BUFFER_BIT); // does nothing, but docs say it makes things faster
		gl.Begin(GL_TRIANGLE_STRIP);
		gl.TexCoord2f(0,            0          ); gl.Vertex3i(0,   480, 0);
		gl.TexCoord2f(640.0/1024.0, 0          ); gl.Vertex3i(640, 480, 0);
		gl.TexCoord2f(0,            480.0/512.0); gl.Vertex3i(0,   0,   0);
		gl.TexCoord2f(640.0/1024.0, 480.0/512.0); gl.Vertex3i(640, 0,   0);
		gl.End();
		
		gl.swapBuffers();
		
		gv->step(!active);
		active = (gv->focused()); // keep them in this order, so the pause-if-inactive implementation works
	}
	
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x24b28, %rsp          # imm = 0x24B28
movq %rsi, %rbx
leaq 0x4d349(%rip), %rax     # 0x778c0
movq %rax, 0x68(%rsp)
movapd 0x885c(%rip), %xmm0     # 0x32de0
movupd %xmm0, 0x58(%rsp)
leaq 0xb0(%rsp), %r14
movb $0xf, 0xf(%r14)
xorl %ebp, %ebp
movb %bpl, (%r14)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x10(%r14)
leaq 0x9a1(%rip), %rax       # 0x2af4e
movq %rax, 0x28(%r14)
movq %rax, 0x20(%r14)
movq $0x0, 0x30(%r14)
movb %bpl, 0x38(%r14)
leaq 0x1b(%rsp), %r15
movb %bpl, (%r15)
leaq 0xc867(%rip), %rsi      # 0x36e37
leaq 0xa0(%rsp), %r12
movl $0x9, %edx
movq %r12, %rdi
movl $0x1, %ecx
callq 0x5040
movq (%r12), %rdx
movq 0x8(%r12), %rcx
movq %r14, %rdi
xorl %esi, %esi
movq %r15, %r8
callq 0x2af50
leaq 0xf(%rsp), %r12
movb %bpl, (%r12)
leaq 0xc831(%rip), %rsi      # 0x36e41
leaq 0x90(%rsp), %r13
movl $0x7, %edx
movq %r13, %rdi
movl $0x1, %ecx
callq 0x5040
movq (%r13), %rdx
movq 0x8(%r13), %rcx
movq %r14, %rdi
xorl %esi, %esi
movq %r12, %r8
callq 0x2af50
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4cae
movb (%r15), %al
cmpb $0x1, %al
jne 0x2a83a
cmpb $0x1, 0xf(%rsp)
jne 0x2a672
leaq 0xc7e6(%rip), %rdi      # 0x36e49
callq 0x3590
movl $0x1, %ebx
jmp 0x2ada1
testb %al, %al
je 0x2a83a
leaq 0x1bd8f(%rip), %rdi     # 0x46410
xorl %ebx, %ebx
movq %rbx, (%rdi)
callq 0x165dc
leaq 0x120(%rsp), %rax
movq $0x1001, (%rax)         # imm = 0x1001
movq %rbx, 0x8(%rax)
movq %rbx, 0x10(%rax)
movq %rbx, 0x18(%rax)
movq %rbx, 0x20(%rax)
movq %rbx, 0x28(%rax)
xorl %edx, %edx
rolq $0x3, %rdi
rolq $0xd, %rdi
rolq $0x3d, %rdi
rolq $0x33, %rdi
xchgq %rbx, %rbx
leaq 0x24(%rsp), %rax
movq %rdx, -0x4(%rax)
movq -0x4(%rax), %rbx
callq 0x1c3af
movq %rax, 0x50(%rsp)
testl %ebx, %ebx
movl $0x2710, %eax           # imm = 0x2710
movl $0x3e8, %ecx            # imm = 0x3E8
cmovel %eax, %ecx
movl %ecx, 0x1c(%rsp)
movl $0x64, %eax
movl $0xa, %ecx
cmovel %eax, %ecx
movl %ecx, 0x10(%rsp)
movl $0x3, %r12d
xorl %r15d, %r15d
xorl %ebp, %ebp
xorl %r13d, %r13d
movl %r13d, %eax
xorl %edx, %edx
divl 0x10(%rsp)
testl %edx, %edx
jne 0x2a73c
leaq 0xc74c(%rip), %rdi      # 0x36e6c
movl %r12d, %esi
movl %r13d, %edx
xorl %eax, %eax
callq 0x3050
movq 0x1b884(%rip), %rax     # 0x45fb8
movq (%rax), %rdi
callq 0x3400
movw $0x0, 0x20(%rsp)
xorl %ebx, %ebx
movq %rbx, 0x30(%rsp)
leaq 0x24(%rsp), %rax
movq %rbx, (%rax)
movb $0x0, 0x8(%rax)
leaq -0x799d(%rip), %rax     # 0x22dc0
movq %rax, 0x40(%rsp)
movq %rax, 0x38(%rsp)
movq %rbx, 0x48(%rsp)
movb %r12b, 0x20(%rsp)
movb %r12b, 0x21(%rsp)
movabsq $0x13ecccccd, %rax      # imm = 0x13ECCCCCD
movq %rax, 0x24(%rsp)
movb $0x1, 0x2c(%rsp)
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, 0x30(%rsp)
leaq 0x120(%rsp), %r14
movq %r14, %rdi
leaq 0x20(%rsp), %rsi
callq 0x22de0
movq %r14, %rdi
callq 0x233e0
movq %r14, %rdi
callq 0x25dc4
movl %eax, %r14d
movl $0x0, %ecx
testb %al, %al
je 0x2a7df
leaq 0x120(%rsp), %rdi
callq 0x2633c
movzbl %al, %ecx
xorb $0x1, %al
movzbl %al, %ebx
testb %r14b, %r14b
je 0x2ade9
addl %ebx, %r15d
addl %ecx, %ebp
leaq 0x38(%rsp), %rdi
callq 0x22dc4
incl %r13d
cmpl %r13d, 0x1c(%rsp)
jne 0x2a70c
incl %r12d
cmpl $0xa, %r12d
jne 0x2a709
callq 0x1c3af
subl 0x50(%rsp), %eax
leaq 0xc65c(%rip), %rdi      # 0x36e7e
xorl %ebx, %ebx
movl %r15d, %esi
xorl %edx, %edx
movl %ebp, %ecx
movl %eax, %r8d
xorl %eax, %eax
callq 0x3050
jmp 0x2ada1
cmpb $0x1, 0xf(%rsp)
jne 0x2a8b9
callq 0x1e724
movq %rax, %rbx
xorl %r14d, %r14d
leaq 0x120(%rsp), %r15
movl %r14d, 0x8(%r15)
movq %r14, (%r15)
movl %r14d, 0x28(%rsp)
movq %r14, 0x20(%rsp)
movb $0x10, 0x2a(%rsp)
movl $0x7a120, %ebp          # imm = 0x7A120
callq 0x1c37c
movq %rax, 0x10(%rsp)
leaq 0x58(%rsp), %r13
leal 0x1(%r14), %r12d
movb $0x1, %cl
testl %r14d, %r12d
jne 0x2a89c
callq 0x1c37c
subl 0x10(%rsp), %eax
cmpl %eax, %ebp
setae %cl
cmoval %ebp, %eax
movl %eax, %ebp
testb %cl, %cl
je 0x2ac1a
movq (%rbx), %rax
movq %rbx, %rdi
movq %r15, %rsi
movq %r13, %rdx
xorl %ecx, %ecx
callq *(%rax)
movl %r12d, %r14d
jmp 0x2a87e
xorl %r12d, %r12d
leaq 0x120(%rsp), %r14
movq %r12, (%r14)
leaq 0xc664(%rip), %rsi      # 0x36f32
leaq 0x80(%rsp), %rbx
movl $0x7, %edx
movq %rbx, %rdi
movl $0x1, %ecx
callq 0x5040
movq (%rbx), %r8
movq 0x8(%rbx), %r9
movq %r14, %rdi
movl $0x280, %esi            # imm = 0x280
movl $0x1e0, %edx            # imm = 0x1E0
movl $0x64, %ecx
callq 0x2aecc
movq %rax, %rbx
movq (%r14), %rdi
movq (%rdi), %rax
movl $0x1, %esi
callq *0x8(%rax)
movl $0x1701, %edi           # imm = 0x1701
callq *0xdf0(%r14)
callq *0xd48(%r14)
movsd 0x84be(%rip), %xmm1     # 0x32df0
movsd 0x84be(%rip), %xmm3     # 0x32df8
movsd 0x84be(%rip), %xmm4     # 0x32e00
movsd 0x84be(%rip), %xmm5     # 0x32e08
xorpd %xmm0, %xmm0
xorps %xmm2, %xmm2
callq *0x1018(%r14)
xorl %edi, %edi
xorl %esi, %esi
movl $0x280, %edx            # imm = 0x280
movl $0x1e0, %ecx            # imm = 0x1E0
callq *0x1d48(%r14)
movl $0x1700, %edi           # imm = 0x1700
callq *0xdf0(%r14)
callq *0xd48(%r14)
movl $0xde1, %edi            # imm = 0xDE1
callq *0x618(%r14)
leaq 0x70(%rsp), %r15
movl $0x1, %edi
movq %r15, %rsi
callq *0x7b8(%r14)
movl (%r15), %esi
movl $0xde1, %edi            # imm = 0xDE1
callq *0xe0(%r14)
subq $0x8, %rsp
movl $0xde1, %edi            # imm = 0xDE1
xorl %esi, %esi
movl $0x8051, %edx           # imm = 0x8051
movl $0x400, %ecx            # imm = 0x400
movl $0x200, %r8d            # imm = 0x200
xorl %r9d, %r9d
pushq %r12
pushq $0x8367                 # imm = 0x8367
pushq $0x80e1                 # imm = 0x80E1
callq *0x1750(%r14)
addq $0x20, %rsp
movl $0xde1, %edi            # imm = 0xDE1
movl $0x2800, %esi           # imm = 0x2800
movl $0x2600, %edx           # imm = 0x2600
callq *0x1790(%r14)
movl $0xde1, %edi            # imm = 0xDE1
movl $0x2801, %esi           # imm = 0x2801
movl $0x2600, %edx           # imm = 0x2600
callq *0x1790(%r14)
leaq 0x8419(%rip), %rdi      # 0x32e30
movl $0x26, %esi
callq 0x1e796
movq %rax, %r14
leaq 0x20(%rsp), %r13
movq %r12, (%r13)
movl $0x0, 0x8(%r13)
leaq 0x3f4(%rip), %rax       # 0x2ae30
leaq 0x108(%rsp), %r15
movq %rax, 0x8(%r15)
movq %r13, (%r15)
movq %r12, 0x10(%r15)
movq (%rbx), %rax
movq %rbx, %rdi
movq %r15, %rsi
callq *0x38(%rax)
movq %r15, %rdi
callq 0xa78a
leaq 0x44c(%rip), %rax       # 0x2aeb6
leaq 0xf0(%rsp), %r15
movq %rax, 0x8(%r15)
movq %r13, (%r15)
movq %r12, 0x10(%r15)
movq (%rbx), %rax
movq %rbx, %rdi
movq %r15, %rsi
callq *0x40(%rax)
movq %r15, %rdi
callq 0xa76e
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x8(%rax)
testb %al, %al
je 0x2abfe
movb $0x1, %bpl
leaq 0x20(%rsp), %r15
leaq 0x58(%rsp), %r12
movb $0x1, %r13b
testb $0x1, %bpl
je 0x2ab17
notb %r13b
movq (%r14), %rax
movzbl %r13b, %ecx
andl $0x1, %ecx
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq *(%rax)
movl %eax, %ebp
testl %eax, %eax
jle 0x2ab0e
subq $0x8, %rsp
movl $0xde1, %edi            # imm = 0xDE1
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movl $0x280, %r8d            # imm = 0x280
movl $0x1e0, %r9d            # imm = 0x1E0
leaq 0x4cdc8(%rip), %rax     # 0x778c0
pushq %rax
pushq $0x8367                 # imm = 0x8367
pushq $0x80e1                 # imm = 0x80E1
callq *0x1910(%rsp)
addq $0x20, %rsp
testl %ebp, %ebp
setns %bpl
xorl %r13d, %r13d
movl $0x4000, %edi           # imm = 0x4000
callq *0x2c0(%rsp)
movl $0x5, %edi
callq *0x160(%rsp)
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
callq *0x1720(%rsp)
xorl %edi, %edi
movl $0x1e0, %esi            # imm = 0x1E0
xorl %edx, %edx
callq *0x1b48(%rsp)
xorpd %xmm1, %xmm1
movss 0x82be(%rip), %xmm0     # 0x32e18
callq *0x1720(%rsp)
movl $0x280, %edi            # imm = 0x280
movl $0x1e0, %esi            # imm = 0x1E0
xorl %edx, %edx
callq *0x1b48(%rsp)
xorps %xmm0, %xmm0
movss 0x829d(%rip), %xmm1     # 0x32e1c
callq *0x1720(%rsp)
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
callq *0x1b48(%rsp)
movss 0x827d(%rip), %xmm0     # 0x32e18
movss 0x8279(%rip), %xmm1     # 0x32e1c
callq *0x1720(%rsp)
movl $0x280, %edi            # imm = 0x280
xorl %esi, %esi
xorl %edx, %edx
callq *0x1b48(%rsp)
callq *0x758(%rsp)
movq 0x120(%rsp), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
notb %bpl
movq (%rbx), %rax
movzbl %bpl, %esi
andl $0x1, %esi
movq %rbx, %rdi
callq *0x30(%rax)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x18(%rax)
movl %eax, %ebp
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x8(%rax)
testb %al, %al
jne 0x2aab2
testq %r14, %r14
je 0x2ac0c
movq (%r14), %rax
movq %r14, %rdi
callq *0x18(%rax)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x28(%rax)
jmp 0x2ad9f
movl %ebp, %eax
imulq $0x10624dd3, %rax, %rdx # imm = 0x10624DD3
incl %r14d
cvtsi2sd %r14, %xmm0
mulsd 0x81dd(%rip), %xmm0     # 0x32e10
shrq $0x26, %rdx
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
leaq 0xc276(%rip), %rdi      # 0x36ebd
movl %r14d, %esi
movb $0x1, %al
callq 0x3050
movq (%rbx), %rax
leaq 0x20(%rsp), %rsi
leaq 0x58(%rsp), %r15
xorl %r14d, %r14d
movq %rbx, %rdi
movq %r15, %rdx
xorl %ecx, %ecx
callq *(%rax)
movl $0x7a120, %ebp          # imm = 0x7A120
callq 0x1c37c
movq %rax, 0x10(%rsp)
leaq 0x120(%rsp), %r13
leal 0x1(%r14), %r12d
testl %r14d, %r12d
je 0x2ac8f
movb $0x1, %cl
jmp 0x2aca2
callq 0x1c37c
subl 0x10(%rsp), %eax
cmpl %eax, %ebp
setae %cl
cmoval %ebp, %eax
movl %eax, %ebp
testb %cl, %cl
je 0x2acbb
movq (%rbx), %rax
movq %rbx, %rdi
movq %r13, %rsi
movq %r15, %rdx
xorl %ecx, %ecx
callq *(%rax)
movl %r12d, %r14d
jmp 0x2ac82
movl %ebp, %eax
imulq $0x10624dd3, %rax, %rdx # imm = 0x10624DD3
incl %r14d
xorps %xmm0, %xmm0
cvtsi2sd %r14, %xmm0
mulsd 0x8139(%rip), %xmm0     # 0x32e10
shrq $0x26, %rdx
xorps %xmm1, %xmm1
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
leaq 0xc1f8(%rip), %rdi      # 0x36ee6
movl %r14d, %esi
movb $0x1, %al
callq 0x3050
movq (%rbx), %rax
leaq 0x20(%rsp), %rsi
leaq 0x58(%rsp), %r15
xorl %r14d, %r14d
movq %rbx, %rdi
movq %r15, %rdx
xorl %ecx, %ecx
callq *(%rax)
movl $0x7a120, %ebp          # imm = 0x7A120
callq 0x1c37c
movq %rax, 0x10(%rsp)
leaq 0x120(%rsp), %r13
leal 0x1(%r14), %r12d
testl %r14d, %r12d
je 0x2ad36
movb $0x1, %cl
jmp 0x2ad49
callq 0x1c37c
subl 0x10(%rsp), %eax
cmpl %eax, %ebp
setae %cl
cmoval %ebp, %eax
movl %eax, %ebp
testb %cl, %cl
je 0x2ad62
movq (%rbx), %rax
movq %rbx, %rdi
movq %r13, %rsi
movq %r15, %rdx
xorl %ecx, %ecx
callq *(%rax)
movl %r12d, %r14d
jmp 0x2ad29
movl %ebp, %eax
imulq $0x10624dd3, %rax, %rdx # imm = 0x10624DD3
incl %r14d
xorps %xmm0, %xmm0
cvtsi2sd %r14, %xmm0
mulsd 0x8092(%rip), %xmm0     # 0x32e10
shrq $0x26, %rdx
xorps %xmm1, %xmm1
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
leaq 0xc17a(%rip), %rdi      # 0x36f0f
movl %r14d, %esi
movb $0x1, %al
callq 0x3050
xorl %ebx, %ebx
leaq 0xc0(%rsp), %r14
leaq 0xd0(%rsp), %r15
movq %r15, %rdi
callq 0x2b0e8
movq %r14, %rdi
callq 0x2b104
cmpb $0x0, -0x11(%r15)
jns 0x2add5
movq 0xb0(%rsp), %rdi
callq 0x3430
movl %ebx, %eax
addq $0x24b28, %rsp          # imm = 0x24B28
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xc088(%rip), %rdi      # 0x36e78
callq 0x3590
leaq 0x70(%rsp), %rbx
leaq 0x120(%rsp), %rsi
movq %rbx, %rdi
callq 0x236d6
cmpb $0x0, 0xf(%rbx)
movq %rbx, %rdi
jns 0x2ae18
movq 0x70(%rsp), %rdi
callq 0x3590
movq %rbx, %rdi
callq 0x2a54c
movl $0x1, %edi
callq 0x3440
nop