// File: /workspace/github_cpp_makefile_star2_O2/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 0x4ede5(%rip), %rax     # 0x728c0
movq %rax, 0x60(%rsp)
leaq 0xd0(%rsp), %r14
movb $0xf, 0xf(%r14)
xorl %ebp, %ebp
movb %bpl, (%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%r14)
movapd 0x830e(%rip), %xmm0     # 0x2be10
leaq 0x909(%rip), %rax       # 0x24412
movq %rax, 0x28(%r14)
movq %rax, 0x20(%r14)
andq $0x0, 0x30(%r14)
movapd %xmm0, 0x50(%rsp)
movb %bpl, 0x38(%r14)
leaq 0x7(%rsp), %r15
movb %bpl, (%r15)
leaq 0xc338(%rip), %rsi      # 0x2fe67
leaq 0x90(%rsp), %r12
movq %r12, %rdi
callq 0x42ce
movq (%r12), %rsi
movq 0x8(%r12), %rdx
movq %r14, %rdi
movq %r15, %rcx
callq 0x24380
leaq 0x6(%rsp), %r12
movb %bpl, (%r12)
leaq 0xc30e(%rip), %rsi      # 0x2fe71
leaq 0x80(%rsp), %r13
movq %r13, %rdi
callq 0x42ce
movq (%r13), %rsi
movq 0x8(%r13), %rdx
movq %r14, %rdi
movq %r12, %rcx
callq 0x24380
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3ec0
movb (%r12), %al
cmpb $0x1, (%r15)
jne 0x23bb7
testb %al, %al
je 0x23c3b
leaq 0xc2cf(%rip), %rdi      # 0x2fe79
callq 0x3590
pushq $0x1
popq %rbx
jmp 0x2429a
testb %al, %al
je 0x23dab
callq 0x1933c
leaq 0x20(%rsp), %r14
andl $0x0, 0x8(%r14)
andq $0x0, (%r14)
movq %rax, %rbx
andl $0x0, 0x10(%rsp)
andq $0x0, 0x8(%rsp)
movb $0x10, 0x12(%rsp)
callq 0x17410
leaq 0x110(%rsp), %r15
movq %rax, (%r15)
movl $0x7a120, 0xc(%r15)     # imm = 0x7A120
xorl %eax, %eax
leaq 0x50(%rsp), %r12
leal 0x1(%rax), %ecx
movl %ecx, 0x118(%rsp)
testl %eax, %ecx
jne 0x23c22
movq %r15, %rdi
callq 0x24638
testb %al, %al
je 0x240ca
movq (%rbx), %rax
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
xorl %ecx, %ecx
callq *(%rax)
movl 0x118(%rsp), %eax
jmp 0x23c04
leaq 0x1d7ce(%rip), %rdi     # 0x41410
andq $0x0, (%rdi)
callq 0x123a8
leaq 0x110(%rsp), %rbx
movq $0x1001, (%rbx)         # imm = 0x1001
xorl %eax, %eax
movq %rax, 0x8(%rbx)
movq %rax, 0x10(%rbx)
movq %rax, 0x18(%rbx)
movq %rax, 0x20(%rbx)
movq %rax, 0x28(%rbx)
movq %rbx, %rax
xorl %edx, %edx
rolq $0x3, %rdi
rolq $0xd, %rdi
rolq $0x3d, %rdi
rolq $0x33, %rdi
xchgq %rbx, %rbx
leaq 0x38(%rsp), %rax
movq %rdx, -0x18(%rax)
movq -0x18(%rax), %r14
callq 0x17441
movq %rax, 0x68(%rsp)
testl %r14d, %r14d
movl $0x2710, %eax           # imm = 0x2710
movl $0x3e8, %ecx            # imm = 0x3E8
cmovel %eax, %ecx
movl %ecx, 0x1c(%rsp)
pushq $0x64
popq %rax
pushq $0xa
popq %rcx
cmovel %eax, %ecx
movl %ecx, 0x18(%rsp)
pushq $0x3
popq %r13
leaq -0x6c87(%rip), %r14     # 0x1d044
xorl %ebp, %ebp
xorl %r12d, %r12d
cmpl $0xa, %r13d
je 0x24277
xorl %r15d, %r15d
cmpl %r15d, 0x1c(%rsp)
je 0x23da3
movl %r15d, %eax
xorl %edx, %edx
divw 0x18(%rsp)
testw %dx, %dx
jne 0x23d1a
leaq 0xc19e(%rip), %rdi      # 0x2fe9c
movl %r13d, %esi
movl %r15d, %edx
xorl %eax, %eax
callq 0x3050
movq 0x1d29e(%rip), %rax     # 0x40fb0
movq (%rax), %rdi
callq 0x3400
movq %r14, 0x40(%rsp)
movq %r14, 0x38(%rsp)
andq $0x0, 0x48(%rsp)
movb %r13b, 0x20(%rsp)
movb %r13b, 0x21(%rsp)
movabsq $0x13ecccccd, %rax      # imm = 0x13ECCCCCD
movq %rax, 0x24(%rsp)
movb $0x1, 0x2c(%rsp)
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, 0x30(%rsp)
movq %rbx, %rdi
leaq 0x20(%rsp), %rsi
callq 0x1d074
movq %rbx, %rdi
callq 0x1d5f8
movq %rbx, %rdi
callq 0x1fc6c
testb %al, %al
je 0x242bb
movq %rbx, %rdi
callq 0x2017a
movzbl %al, %ecx
xorb $0x1, %al
movzbl %al, %eax
addl %eax, %r12d
addl %ecx, %ebp
leaq 0x38(%rsp), %rdi
callq 0x1d048
incl %r15d
jmp 0x23cdd
incl %r13d
jmp 0x23cd0
leaq 0x110(%rsp), %r14
andq $0x0, (%r14)
leaq 0xc1a4(%rip), %rsi      # 0x2ff62
leaq 0x70(%rsp), %rbx
movq %rbx, %rdi
callq 0x42ce
movq (%rbx), %r8
movq 0x8(%rbx), %r9
pushq $0x64
popq %rcx
movq %r14, %rdi
movl $0x280, %esi            # imm = 0x280
movl $0x1e0, %edx            # imm = 0x1E0
callq 0x24390
movq %rax, %rbx
movq (%r14), %rdi
movq (%rdi), %rax
pushq $0x1
popq %rbp
movl %ebp, %esi
callq *0x8(%rax)
movl $0x1701, %edi           # imm = 0x1701
callq *0xdf0(%r14)
callq *0xd48(%r14)
movsd 0x800d(%rip), %xmm1     # 0x2be20
movsd 0x800d(%rip), %xmm3     # 0x2be28
movsd 0x800d(%rip), %xmm4     # 0x2be30
movsd 0x800d(%rip), %xmm5     # 0x2be38
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 0x8(%rsp), %r15
movl %ebp, %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 $0x0
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 0x7f6b(%rip), %rdi      # 0x2be60
pushq $0x26
popq %rsi
callq 0x193ac
leaq 0x20(%rsp), %r15
andl $0x0, 0x8(%r15)
movq %rax, %r14
andq $0x0, (%r15)
leaq 0x3eb(%rip), %rax       # 0x24300
leaq 0xb8(%rsp), %r12
movq %rax, 0x8(%r12)
movq %r15, (%r12)
andq $0x0, 0x10(%r12)
movq (%rbx), %rax
movq %rbx, %rdi
movq %r12, %rsi
callq *0x38(%rax)
movq %r12, %rdi
callq 0x8f94
leaq 0x423(%rip), %rax       # 0x2436a
leaq 0xa0(%rsp), %r12
movq %rax, 0x8(%r12)
movq %r15, (%r12)
andq $0x0, 0x10(%r12)
movq (%rbx), %rax
movq %rbx, %rdi
movq %r12, %rsi
callq *0x40(%rax)
movq %r12, %rdi
callq 0x8f68
movb $0x1, %r15b
pushq $0x5
popq %rbp
movb $0x1, %r12b
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x8(%rax)
testb %al, %al
je 0x24170
movb $0x1, %r13b
testb $0x1, %r12b
je 0x23ff7
notb %r15b
movq (%r14), %rax
movzbl %r15b, %ecx
andl $0x1, %ecx
movq %r14, %rdi
leaq 0x20(%rsp), %rsi
leaq 0x50(%rsp), %rdx
callq *(%rax)
movl %eax, %r13d
testl %eax, %eax
jle 0x23ff0
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 0x4e8e6(%rip), %rax     # 0x728c0
pushq %rax
pushq $0x8367                 # imm = 0x8367
pushq $0x80e1                 # imm = 0x80E1
callq *0x1900(%rsp)
addq $0x20, %rsp
shrl $0x1f, %r13d
xorl %r15d, %r15d
movl $0x4000, %edi           # imm = 0x4000
callq *0x2b0(%rsp)
movl %ebp, %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 0x7e11(%rip), %xmm0     # 0x2be48
callq *0x1710(%rsp)
movl $0x280, %edi            # imm = 0x280
movl $0x1e0, %esi            # imm = 0x1E0
xorl %edx, %edx
callq *0x1b38(%rsp)
xorps %xmm0, %xmm0
movss 0x7df0(%rip), %xmm1     # 0x2be4c
callq *0x1710(%rsp)
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
callq *0x1b38(%rsp)
movss 0x7dd0(%rip), %xmm0     # 0x2be48
movss 0x7dcc(%rip), %xmm1     # 0x2be4c
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 %r13b, %esi
movq %rbx, %rdi
callq *0x30(%rax)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x18(%rax)
movl %eax, %r12d
jmp 0x23f7b
leaq 0x110(%rsp), %r14
movl 0x8(%r14), %esi
movl 0xc(%r14), %ecx
xorl %r13d, %r13d
movl $0x3e8, %edi            # imm = 0x3E8
movl %ecx, %eax
xorl %edx, %edx
divl %edi
cvtsi2sd %rsi, %xmm0
mulsd 0x7d4b(%rip), %xmm0     # 0x2be40
cvtsi2sd %rcx, %xmm1
divsd %xmm1, %xmm0
leaq 0xbde8(%rip), %rdi      # 0x2feed
movl %eax, %edx
movb $0x1, %al
callq 0x3050
movq (%rbx), %rax
leaq 0x8(%rsp), %rsi
leaq 0x50(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rdx
xorl %ecx, %ecx
callq *(%rax)
callq 0x17410
movq %rax, (%r14)
movl $0x7a120, 0xc(%r14)     # imm = 0x7A120
leaq 0x20(%rsp), %r12
leal 0x1(%r13), %eax
movl %eax, 0x118(%rsp)
testl %r13d, %eax
jne 0x24156
movq %r14, %rdi
callq 0x24638
testb %al, %al
je 0x2418e
movq (%rbx), %rax
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
xorl %ecx, %ecx
callq *(%rax)
movl 0x118(%rsp), %r13d
jmp 0x2413a
testq %r14, %r14
je 0x2417e
movq (%r14), %rax
movq %r14, %rdi
callq *0x18(%rax)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x28(%rax)
xorl %ebx, %ebx
jmp 0x2429a
leaq 0x110(%rsp), %r14
movl 0x8(%r14), %esi
movl 0xc(%r14), %ecx
xorl %r13d, %r13d
movl $0x3e8, %edi            # imm = 0x3E8
movl %ecx, %eax
xorl %edx, %edx
divl %edi
cvtsi2sd %rsi, %xmm0
mulsd 0x7c87(%rip), %xmm0     # 0x2be40
cvtsi2sd %rcx, %xmm1
divsd %xmm1, %xmm0
leaq 0xbd4d(%rip), %rdi      # 0x2ff16
movl %eax, %edx
movb $0x1, %al
callq 0x3050
movq (%rbx), %rax
leaq 0x8(%rsp), %rsi
leaq 0x50(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rdx
xorl %ecx, %ecx
callq *(%rax)
callq 0x17410
movq %rax, (%r14)
movl $0x7a120, 0xc(%r14)     # imm = 0x7A120
leaq 0x20(%rsp), %r12
leal 0x1(%r13), %eax
movl %eax, 0x118(%rsp)
testl %r13d, %eax
jne 0x2421a
movq %r14, %rdi
callq 0x24638
testb %al, %al
je 0x24234
movq (%rbx), %rax
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
xorl %ecx, %ecx
callq *(%rax)
movl 0x118(%rsp), %r13d
jmp 0x241fe
movl 0x118(%rsp), %esi
movl 0x11c(%rsp), %ecx
xorl %ebx, %ebx
movl $0x3e8, %edi            # imm = 0x3E8
movl %ecx, %eax
xorl %edx, %edx
divl %edi
cvtsi2sd %rsi, %xmm0
mulsd 0x7be4(%rip), %xmm0     # 0x2be40
cvtsi2sd %rcx, %xmm1
divsd %xmm1, %xmm0
leaq 0xbcd3(%rip), %rdi      # 0x2ff3f
movl %eax, %edx
movb $0x1, %al
callq 0x3050
jmp 0x2429a
callq 0x17441
subl 0x68(%rsp), %eax
leaq 0xbc27(%rip), %rdi      # 0x2feae
xorl %ebx, %ebx
movl %r12d, %esi
xorl %edx, %edx
movl %ebp, %ecx
movl %eax, %r8d
xorl %eax, %eax
callq 0x3050
leaq 0xd0(%rsp), %rdi
callq 0x243f2
movl %ebx, %eax
addq $0x24b18, %rsp          # imm = 0x24B18
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xbbe6(%rip), %rdi      # 0x2fea8
callq 0x3590
leaq 0x8(%rsp), %rbx
leaq 0x110(%rsp), %rsi
movq %rbx, %rdi
callq 0x1d85a
cmpb $0x0, 0xf(%rbx)
movq %rbx, %rdi
jns 0x242ea
movq 0x8(%rsp), %rdi
callq 0x3590
movq %rbx, %rdi
callq 0x23ab8
pushq $0x1
popq %rdi
callq 0x3440
nop