// File: /workspace/github_cpp_makefile_star2_O1/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 0x4fba
movq %rsi, %rbx
movl %edi, %r14d
movq %rsp, %rdi
callq 0x26bc
cmpl $0x2, %r14d
jne 0x4dd3
leaq 0x145c(%rip), %rdi      # 0x622d
jmp 0x4dd7
movq 0x10(%rbx), %rdi
leaq 0x14a0(%rip), %rsi      # 0x627e
callq 0x21f0
testq %rax, %rax
je 0x4ed4
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 0x4f24
movq %rsp, %rdi
leaq 0x5b0(%rsp), %rsi
callq 0x283a
testl %eax, %eax
js 0x4f32
movq %rsp, %rdi
callq 0x2844
movq %rsp, %rdi
movq %r14, %rsi
callq 0x2c88
movq %rsp, %rdi
callq 0x2ec2
movq 0x8(%rbx), %rdi
leaq 0x13f2(%rip), %rsi      # 0x627e
callq 0x21f0
testq %rax, %rax
je 0x4f40
movq %rax, %r14
movq %rsp, %rdi
movq %rax, %rsi
callq 0x2854
movq %r14, %rdi
callq 0x2170
movq %rsp, %rdi
movl $0x1, %esi
callq 0x31a0
movq %rsp, %rdi
callq 0x3186
xorl %ebp, %ebp
movq %rsp, %rdi
callq 0x3080
jmp 0x4fb2
movq 0x5115(%rip), %rbx      # 0x9ff0
leaq 0x1355(%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 0x50e3(%rip), %rdi      # 0x9ff0
callq 0x2030
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movq %rax, %rdi
callq 0x2100
jmp 0x4fb2
movl $0x19, %edx
leaq 0x131f(%rip), %rbx      # 0x624f
jmp 0x4f6f
movl $0x16, %edx
leaq 0x132b(%rip), %rbx      # 0x6269
jmp 0x4f6f
movq 0x50a9(%rip), %r14      # 0x9ff0
leaq 0x1332(%rip), %rsi      # 0x6280
movl $0xc, %edx
movq %r14, %rdi
callq 0x21d0
movq 0x8(%rbx), %rbx
testq %rbx, %rbx
je 0x4fcc
movq %rbx, %rdi
callq 0x20c0
movq %rax, %rdx
movq 0x507a(%rip), %rdi      # 0x9ff0
movq %rbx, %rsi
callq 0x21d0
movq 0x506b(%rip), %rdi      # 0x9ff0
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x2160
movsbl %al, %esi
movq 0x5050(%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 0x4f7e
jmp 0x4fe8
movq %rax, %rbx
movq %rsp, %rdi
callq 0x27d2
movq %rbx, %rdi
callq 0x2300
nop