// File: /workspace/github_cpp_makefile_star2_O3/utkukaratas[P]xkeylayers/xkeylayers.cpp
// Function: main
int main(int argc, char **argv)
{
    int ch;
    app.debug = False;
    app.timeout.tv_sec = 0;
    app.timeout.tv_usec = 500000;
    app.timeout_valid = True;
    app.generated = NULL;

    while ((ch = getopt (argc, argv, "d")) != -1)
    {
        switch (ch)
        {
        case 'd':
            app.debug = True;
            break;
        default:
            printf("Usage: %s [-d]\n", argv[0]);
            printf("Runs as a daemon unless -d flag is set\n");
            return EXIT_SUCCESS;
        }
    }

    app.connect_x11();

    try {
       app.modifiers = load_config(".xkeylayers");
    }
    catch (...) {
        debug("configuration failure. exiting!");
        exit(EXIT_FAILURE);
    }

    if (app.modifiers.size() == 0) {
        debug("no modifiers declared. exiting!");
        exit(EXIT_FAILURE);
    }

    if (!app.debug)
        daemon (0, 0);

    // setup signal handler for proper exits.
    sigemptyset(&app._sigset);
    sigaddset(&app._sigset, SIGINT);
    sigaddset(&app._sigset, SIGTERM);
    pthread_sigmask(SIG_BLOCK, &app._sigset, NULL);
    pthread_create(&app._sigwait_thread, NULL, sig_handler, &app);

    // hook 11 and start processing input events. this call will block.
    app.hook_x11();

    XCloseDisplay(app._ctrl_conn);
    XCloseDisplay(app._data_conn);

    debug("main exiting\n");

    return EXIT_SUCCESS;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x40, %rsp
movq %rsi, %rbx
movl %edi, %ebp
movb $0x0, 0x349a(%rip)      # 0x6248
movq $0x7a120, 0x34d7(%rip) # imm = 0x7A120
movb $0x1, 0x34d8(%rip)      # 0x6298
xorps %xmm0, %xmm0
movups %xmm0, 0x34b6(%rip)     # 0x6280
leaq 0x14bc(%rip), %r14      # 0x428d
movl %ebp, %edi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2040
cmpl $0x64, %eax
jne 0x2dec
movb $0x1, 0x345e(%rip)      # 0x6248
jmp 0x2dd1
cmpl $-0x1, %eax
jne 0x2f43
leaq 0x33ac(%rip), %rdi      # 0x61a8
callq 0x2750
leaq 0x30(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x13fa(%rip), %rsi      # 0x420b
leaq 0x13fe(%rip), %rdx      # 0x4216
leaq 0x20(%rsp), %rdi
callq 0x2ff2
movq %rsp, %rdi
callq 0x24fc
movq 0x341f(%rip), %rdi      # 0x6250
movq 0x3428(%rip), %rsi      # 0x6260
movaps (%rsp), %xmm0
movups %xmm0, 0x340d(%rip)     # 0x6250
movq 0x10(%rsp), %rax
movq %rax, 0x3411(%rip)      # 0x6260
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
testq %rdi, %rdi
je 0x2e82
subq %rdi, %rsi
callq 0x2150
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x2e82
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x2150
movq 0x20(%rsp), %rdi
cmpq %r14, %rdi
je 0x2e99
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x2150
movq 0x33b8(%rip), %rax      # 0x6258
cmpq 0x33a9(%rip), %rax      # 0x6250
je 0x2f6b
cmpb $0x0, 0x3394(%rip)      # 0x6248
jne 0x2ebf
xorl %edi, %edi
xorl %esi, %esi
callq 0x2180
leaq 0x3302(%rip), %rbx      # 0x61c8
movq %rbx, %rdi
callq 0x21b0
leaq 0x32d3(%rip), %r14      # 0x61a8
movq %rbx, %rdi
movl $0x2, %esi
callq 0x21e0
movq %rbx, %rdi
movl $0xf, %esi
callq 0x21e0
xorl %edi, %edi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x2050
leaq 0x32be(%rip), %rdi      # 0x61c0
leaq -0x1df(%rip), %rdx      # 0x2d2a
xorl %esi, %esi
movq %r14, %rcx
callq 0x22a0
movq %r14, %rdi
callq 0x281c
movq 0x328e(%rip), %rdi      # 0x61b0
callq 0x22c0
movq 0x327a(%rip), %rdi      # 0x61a8
callq 0x22c0
leaq 0x131d(%rip), %rdi      # 0x4257
xorl %eax, %eax
callq 0x25d3
jmp 0x2f60
movq (%rbx), %rsi
leaq 0x12ae(%rip), %rdi      # 0x41fb
xorl %eax, %eax
callq 0x2030
leaq 0x134e(%rip), %rdi      # 0x42a9
callq 0x2210
xorl %eax, %eax
addq $0x40, %rsp
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x12c5(%rip), %rdi      # 0x4237
jmp 0x2fa2
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %r14, %rdi
je 0x2f93
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x2150
jmp 0x2f93
movq %rax, %rbx
movq %rbx, %rdi
callq 0x20a0
leaq 0x1275(%rip), %rdi      # 0x4217
xorl %eax, %eax
callq 0x25d3
movl $0x1, %edi
callq 0x2190
nop