// File: /workspace/github_cpp_makefile_star2_O3/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 $0x24b18, %rsp          # imm = 0x24B18
movq %rsi, %rbx
leaq 0x4d019(%rip), %rax     # 0x778c0
movq %rax, 0x50(%rsp)
movapd 0x860c(%rip), %xmm0     # 0x32ec0
movapd %xmm0, 0x40(%rsp)
leaq 0xa0(%rsp), %r14
movb $0xf, 0xf(%r14)
xorl %ebp, %ebp
movb %bpl, (%r14)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x10(%r14)
leaq 0x921(%rip), %rax       # 0x2b1fe
movq %rax, 0x28(%r14)
movq %rax, 0x20(%r14)
movq $0x0, 0x30(%r14)
movb %bpl, 0x38(%r14)
leaq 0x7(%rsp), %r15
movb %bpl, (%r15)
leaq 0xc617(%rip), %rsi      # 0x36f17
leaq 0x90(%rsp), %r12
movl $0x9, %edx
movq %r12, %rdi
movl $0x1, %ecx
callq 0x5990
movq (%r12), %rdx
movq 0x8(%r12), %rcx
movq %r14, %rdi
xorl %esi, %esi
movq %r15, %r8
callq 0x2b200
leaq 0x6(%rsp), %r12
movb %bpl, (%r12)
leaq 0xc5e1(%rip), %rsi      # 0x36f21
leaq 0x80(%rsp), %r13
movl $0x7, %edx
movq %r13, %rdi
movl $0x1, %ecx
callq 0x5990
movq (%r13), %rdx
movq 0x8(%r13), %rcx
movq %r14, %rdi
xorl %esi, %esi
movq %r12, %r8
callq 0x2b200
movq %r14, %rdi
movq %rbx, %rsi
callq 0x55f4
movb (%r12), %al
cmpb $0x1, (%r15)
jne 0x2a9a2
testb %al, %al
je 0x2aa11
leaq 0xc596(%rip), %rdi      # 0x36f29
callq 0x3590
movl $0x1, %ebx
jmp 0x2b063
testb %al, %al
je 0x2aba8
callq 0x1dfa0
movq %rax, %rbx
xorl %r14d, %r14d
leaq 0x110(%rsp), %r15
movl %r14d, 0x8(%r15)
movq %r14, (%r15)
movl %r14d, 0x18(%rsp)
movq %r14, 0x10(%rsp)
movb $0x10, 0x1a(%rsp)
callq 0x1bca8
movq %rax, %r12
leaq 0x40(%rsp), %r13
leal 0x1(%r14), %ebp
testl %r14d, %ebp
jne 0x2a9fc
callq 0x1bca8
subl %r12d, %eax
cmpl $0x7a120, %eax          # imm = 0x7A120
ja 0x2af02
movq (%rbx), %rax
movq %rbx, %rdi
movq %r15, %rsi
movq %r13, %rdx
xorl %ecx, %ecx
callq *(%rax)
movl %ebp, %r14d
jmp 0x2a9e0
leaq 0x1b9f8(%rip), %rdi     # 0x46410
xorl %r14d, %r14d
movq %r14, (%rdi)
callq 0x16860
leaq 0x110(%rsp), %rbx
movq $0x1001, (%rbx)         # imm = 0x1001
movq %r14, 0x8(%rbx)
movq %r14, 0x10(%rbx)
movq %r14, 0x18(%rbx)
movq %r14, 0x20(%rbx)
movq %r14, 0x28(%rbx)
movq %rbx, %rax
xorl %edx, %edx
rolq $0x3, %rdi
rolq $0xd, %rdi
rolq $0x3d, %rdi
rolq $0x33, %rdi
xchgq %rbx, %rbx
leaq 0x28(%rsp), %rax
movq %rdx, -0x18(%rax)
movq -0x18(%rax), %r14
callq 0x1bcdb
movq %rax, 0x58(%rsp)
testl %r14d, %r14d
movl $0x2710, %eax           # imm = 0x2710
movl $0x3e8, %ecx            # imm = 0x3E8
cmovel %eax, %ecx
movl %ecx, 0x8(%rsp)
movl $0x64, %eax
movl $0xa, %ecx
cmovel %eax, %ecx
movl %ecx, 0xc(%rsp)
movl $0x3, %r13d
leaq -0x8049(%rip), %r14     # 0x22a5e
xorl %r12d, %r12d
xorl %ebp, %ebp
xorl %r15d, %r15d
movl %r15d, %eax
xorl %edx, %edx
divw 0xc(%rsp)
testw %dx, %dx
jne 0x2aae1
leaq 0xc487(%rip), %rdi      # 0x36f4c
movl %r13d, %esi
movl %r15d, %edx
xorl %eax, %eax
callq 0x3050
movq 0x1b4df(%rip), %rax     # 0x45fb8
movq (%rax), %rdi
callq 0x3400
movq %r14, 0x30(%rsp)
movq %r14, 0x28(%rsp)
movq $0x0, 0x38(%rsp)
movb %r13b, 0x10(%rsp)
movb %r13b, 0x11(%rsp)
movabsq $0x13ecccccd, %rax      # imm = 0x13ECCCCCD
movq %rax, 0x14(%rsp)
movb $0x1, 0x1c(%rsp)
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, 0x20(%rsp)
movq %rbx, %rdi
leaq 0x10(%rsp), %rsi
callq 0x22a7e
movq %rbx, %rdi
callq 0x230d2
movq %rbx, %rdi
callq 0x25d70
testb %al, %al
je 0x2b0ab
movq %rbx, %rdi
callq 0x26574
movzbl %al, %ecx
xorb $0x1, %al
movzbl %al, %eax
addl %eax, %r12d
addl %ecx, %ebp
leaq 0x28(%rsp), %rdi
callq 0x22a62
incl %r15d
cmpl %r15d, 0x8(%rsp)
jne 0x2aaaf
incl %r13d
cmpl $0xa, %r13d
jne 0x2aaac
callq 0x1bcdb
subl 0x58(%rsp), %eax
leaq 0xc3ce(%rip), %rdi      # 0x36f5e
xorl %ebx, %ebx
movl %r12d, %esi
xorl %edx, %edx
movl %ebp, %ecx
movl %eax, %r8d
xorl %eax, %eax
callq 0x3050
jmp 0x2b063
xorl %r12d, %r12d
leaq 0x110(%rsp), %r14
movq %r12, (%r14)
leaq 0xc455(%rip), %rsi      # 0x37012
leaq 0x70(%rsp), %rbx
movl $0x7, %edx
movq %rbx, %rdi
movl $0x1, %ecx
callq 0x5990
movq (%rbx), %r8
movq 0x8(%rbx), %r9
movq %r14, %rdi
movl $0x280, %esi            # imm = 0x280
movl $0x1e0, %edx            # imm = 0x1E0
movl $0x64, %ecx
callq 0x2b17c
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 0x82b2(%rip), %xmm1     # 0x32ed0
movsd 0x82b2(%rip), %xmm3     # 0x32ed8
movsd 0x82b2(%rip), %xmm4     # 0x32ee0
movsd 0x82b2(%rip), %xmm5     # 0x32ee8
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 0x60(%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 0x820d(%rip), %rdi      # 0x32f10
movl $0x26, %esi
callq 0x1e00a
movq %rax, %r14
leaq 0x10(%rsp), %r13
movq %r12, (%r13)
movl $0x0, 0x8(%r13)
leaq 0x3ca(%rip), %rax       # 0x2b0f2
leaq 0xf8(%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 0xac70
leaq 0x410(%rip), %rax       # 0x2b166
leaq 0xe0(%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 0xac54
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x8(%rax)
testb %al, %al
je 0x2aee6
movb $0x1, %bpl
leaq 0x10(%rsp), %r15
leaq 0x40(%rsp), %r12
movb $0x1, %r13b
testb $0x1, %bpl
je 0x2ae02
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 0x2adfa
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 0x4cadc(%rip), %rax     # 0x778c0
pushq %rax
pushq $0x8367                 # imm = 0x8367
pushq $0x80e1                 # imm = 0x80E1
callq *0x1900(%rsp)
addq $0x20, %rsp
shrl $0x1f, %ebp
xorl %r13d, %r13d
jmp 0x2ae05
movb $0x1, %bpl
movl $0x4000, %edi           # imm = 0x4000
callq *0x2b0(%rsp)
movl $0x5, %edi
callq *0x150(%rsp)
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
callq *0x1710(%rsp)
xorl %edi, %edi
movl $0x1e0, %esi            # imm = 0x1E0
xorl %edx, %edx
callq *0x1b38(%rsp)
xorpd %xmm1, %xmm1
movss 0x80b0(%rip), %xmm0     # 0x32ef8
callq *0x1710(%rsp)
movl $0x280, %edi            # imm = 0x280
movl $0x1e0, %esi            # imm = 0x1E0
xorl %edx, %edx
callq *0x1b38(%rsp)
xorps %xmm0, %xmm0
movss 0x808f(%rip), %xmm1     # 0x32efc
callq *0x1710(%rsp)
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
callq *0x1b38(%rsp)
movss 0x806f(%rip), %xmm0     # 0x32ef8
movss 0x806b(%rip), %xmm1     # 0x32efc
callq *0x1710(%rsp)
movl $0x280, %edi            # imm = 0x280
xorl %esi, %esi
xorl %edx, %edx
callq *0x1b38(%rsp)
callq *0x748(%rsp)
movq 0x110(%rsp), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
movq (%rbx), %rax
movzbl %bpl, %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 0x2ad9e
testq %r14, %r14
je 0x2aef4
movq (%r14), %rax
movq %r14, %rdi
callq *0x18(%rax)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x28(%rax)
jmp 0x2b061
movl %eax, %eax
imulq $0x10624dd3, %rax, %rdx # imm = 0x10624DD3
incl %r14d
cvtsi2sd %r14, %xmm0
mulsd 0x7fd5(%rip), %xmm0     # 0x32ef0
shrq $0x26, %rdx
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
leaq 0xc06e(%rip), %rdi      # 0x36f9d
movl %r14d, %esi
movb $0x1, %al
callq 0x3050
movq (%rbx), %rax
leaq 0x10(%rsp), %rsi
leaq 0x40(%rsp), %r15
xorl %r14d, %r14d
movq %rbx, %rdi
movq %r15, %rdx
xorl %ecx, %ecx
callq *(%rax)
callq 0x1bca8
movq %rax, %r12
leaq 0x110(%rsp), %r13
leal 0x1(%r14), %ebp
testl %r14d, %ebp
jne 0x2af7b
callq 0x1bca8
subl %r12d, %eax
cmpl $0x7a120, %eax          # imm = 0x7A120
ja 0x2af90
movq (%rbx), %rax
movq %rbx, %rdi
movq %r13, %rsi
movq %r15, %rdx
xorl %ecx, %ecx
callq *(%rax)
movl %ebp, %r14d
jmp 0x2af63
movl %eax, %eax
imulq $0x10624dd3, %rax, %rdx # imm = 0x10624DD3
incl %r14d
xorps %xmm0, %xmm0
cvtsi2sd %r14, %xmm0
mulsd 0x7f44(%rip), %xmm0     # 0x32ef0
shrq $0x26, %rdx
xorps %xmm1, %xmm1
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
leaq 0xc003(%rip), %rdi      # 0x36fc6
movl %r14d, %esi
movb $0x1, %al
callq 0x3050
movq (%rbx), %rax
leaq 0x10(%rsp), %rsi
leaq 0x40(%rsp), %r15
xorl %r14d, %r14d
movq %rbx, %rdi
movq %r15, %rdx
xorl %ecx, %ecx
callq *(%rax)
callq 0x1bca8
movq %rax, %r12
leaq 0x110(%rsp), %r13
leal 0x1(%r14), %ebp
testl %r14d, %ebp
jne 0x2b00f
callq 0x1bca8
subl %r12d, %eax
cmpl $0x7a120, %eax          # imm = 0x7A120
ja 0x2b024
movq (%rbx), %rax
movq %rbx, %rdi
movq %r13, %rsi
movq %r15, %rdx
xorl %ecx, %ecx
callq *(%rax)
movl %ebp, %r14d
jmp 0x2aff7
movl %eax, %eax
imulq $0x10624dd3, %rax, %rdx # imm = 0x10624DD3
incl %r14d
xorps %xmm0, %xmm0
cvtsi2sd %r14, %xmm0
mulsd 0x7eb0(%rip), %xmm0     # 0x32ef0
shrq $0x26, %rdx
xorps %xmm1, %xmm1
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
leaq 0xbf98(%rip), %rdi      # 0x36fef
movl %r14d, %esi
movb $0x1, %al
callq 0x3050
xorl %ebx, %ebx
leaq 0xb0(%rsp), %r14
leaq 0xc0(%rsp), %r15
movq %r15, %rdi
callq 0x2b398
movq %r14, %rdi
callq 0x2b3b4
cmpb $0x0, -0x11(%r15)
jns 0x2b097
movq 0xa0(%rsp), %rdi
callq 0x3430
movl %ebx, %eax
addq $0x24b18, %rsp          # imm = 0x24B18
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xbea6(%rip), %rdi      # 0x36f58
callq 0x3590
leaq 0x60(%rsp), %rbx
leaq 0x110(%rsp), %rsi
movq %rbx, %rdi
callq 0x2335a
cmpb $0x0, 0xf(%rbx)
movq %rbx, %rdi
jns 0x2b0da
movq 0x60(%rsp), %rdi
callq 0x3590
movq %rbx, %rdi
callq 0x2a87c
movl $0x1, %edi
callq 0x3440
nop