// File: /workspace/github_cpp_makefile_star2_O3/daklqw[P]beepmania/main.cpp
// Function: main
int main(int argc, char ** argv) {
	if (argc <= 1) return 0;
	gamecore gm;
	FILE * fin = fopen(argc < 3 ? "track.ini" : argv[2], "r");
	if (fin == NULL) {
		std::cerr << "Cannot open config file" << std::endl;
		return -1;
	}
	char keybd[1024], beep[1024];
	fgets(keybd, 1024, fin);
	keybd[strlen(keybd) - 1] = 0;
	fgets(beep, 1024, fin);
	beep[strlen(beep) - 1] = 0;
	if (gm.registerkeybd(keybd) < 0) {
		std::cerr << "Open keyboard event error" << std::endl;
		return -1;
	}
	if (gm.configsound(beep) < 0) {
		std::cerr << "Open beep device error" << std::endl;
		return -1;
	}
	gm.configscore();
	gm.configtrack(fin);
	gm.configui();
	fin = fopen(argv[1], "r");
	if (fin == NULL) {
		std::cerr << "Cannot open " << argv[1] << std::endl;
		return -1;
	}
	gm.readbeatmap(fin);
	fclose(fin);
	gm.setsound(true);
	gm.warn();
	gm.start();
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xdb0, %rsp            # imm = 0xDB0
xorl %ebp, %ebp
cmpl $0x2, %edi
jl 0x4fca
movq %rsi, %rbx
movl %edi, %r14d
movq %rsp, %rdi
callq 0x26bc
cmpl $0x2, %r14d
jne 0x4de3
leaq 0x144c(%rip), %rdi      # 0x622d
jmp 0x4de7
movq 0x10(%rbx), %rdi
leaq 0x1490(%rip), %rsi      # 0x627e
callq 0x21f0
testq %rax, %rax
je 0x4ee4
movq %rax, %r14
leaq 0x9b0(%rsp), %r15
movq %r15, %rdi
movl $0x400, %esi            # imm = 0x400
movq %rax, %rdx
callq 0x2290
movq %r15, %rdi
callq 0x20c0
xorl %ebp, %ebp
movb %bpl, -0x1(%rax,%r15)
leaq 0x5b0(%rsp), %r12
movq %r12, %rdi
movl $0x400, %esi            # imm = 0x400
movq %r14, %rdx
callq 0x2290
movq %r12, %rdi
callq 0x20c0
movb %bpl, -0x1(%rax,%r12)
movq %rsp, %rdi
movq %r15, %rsi
callq 0x282e
testl %eax, %eax
js 0x4f34
movq %rsp, %rdi
leaq 0x5b0(%rsp), %rsi
callq 0x283a
testl %eax, %eax
js 0x4f42
movq %rsp, %rdi
callq 0x2844
movq %rsp, %rdi
movq %r14, %rsi
callq 0x2c92
movq %rsp, %rdi
callq 0x2ecc
movq 0x8(%rbx), %rdi
leaq 0x13e2(%rip), %rsi      # 0x627e
callq 0x21f0
testq %rax, %rax
je 0x4f50
movq %rax, %r14
movq %rsp, %rdi
movq %rax, %rsi
callq 0x2854
movq %r14, %rdi
callq 0x2170
movq %rsp, %rdi
movl $0x1, %esi
callq 0x319a
movq %rsp, %rdi
callq 0x3180
xorl %ebp, %ebp
movq %rsp, %rdi
callq 0x307a
jmp 0x4fc2
movq 0x5105(%rip), %rbx      # 0x9ff0
leaq 0x1345(%rip), %rsi      # 0x6237
movl $0x17, %edx
movq %rbx, %rdi
callq 0x21d0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2160
movsbl %al, %esi
movq 0x50d3(%rip), %rdi      # 0x9ff0
callq 0x2030
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movq %rax, %rdi
callq 0x2100
jmp 0x4fc2
movl $0x19, %edx
leaq 0x130f(%rip), %rbx      # 0x624f
jmp 0x4f7f
movl $0x16, %edx
leaq 0x131b(%rip), %rbx      # 0x6269
jmp 0x4f7f
movq 0x5099(%rip), %r14      # 0x9ff0
leaq 0x1322(%rip), %rsi      # 0x6280
movl $0xc, %edx
movq %r14, %rdi
callq 0x21d0
movq 0x8(%rbx), %rbx
testq %rbx, %rbx
je 0x4fdc
movq %rbx, %rdi
callq 0x20c0
movq %rax, %rdx
movq 0x506a(%rip), %rdi      # 0x9ff0
movq %rbx, %rsi
callq 0x21d0
movq 0x505b(%rip), %rdi      # 0x9ff0
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x2160
movsbl %al, %esi
movq 0x5040(%rip), %rdi      # 0x9ff0
callq 0x2030
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movq %rax, %rdi
callq 0x2100
movq %rsp, %rdi
callq 0x27d2
movl %ebp, %eax
addq $0xdb0, %rsp            # imm = 0xDB0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq (%r14), %rax
movq -0x18(%rax), %rax
leaq (%r14,%rax), %rdi
movl 0x20(%r14,%rax), %esi
orl $0x1, %esi
callq 0x22c0
jmp 0x4f8e
jmp 0x4ff8
movq %rax, %rbx
movq %rsp, %rdi
callq 0x27d2
movq %rbx, %rdi
callq 0x2300
nop