// File: /workspace/github_cpp_makefile_star2_O2/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, 0x3564(%rip)      # 0x6250
movq $0x7a120, 0x35a1(%rip) # imm = 0x7A120
movb $0x1, 0x35a2(%rip)      # 0x62a0
xorps %xmm0, %xmm0
movups %xmm0, 0x3580(%rip)     # 0x6288
leaq 0x157e(%rip), %r14      # 0x428d
movl %ebp, %edi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2040
cmpl $0x64, %eax
jne 0x2d2a
movb $0x1, 0x3528(%rip)      # 0x6250
jmp 0x2d0f
cmpl $-0x1, %eax
jne 0x2e2b
leaq 0x3476(%rip), %rdi      # 0x61b0
callq 0x26ea
leaq 0x14c5(%rip), %rsi      # 0x420b
leaq 0x8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x2f02
leaq 0x28(%rsp), %rdi
callq 0x24bc
leaq 0x34f2(%rip), %rdi      # 0x6258
leaq 0x28(%rsp), %rbx
movq %rbx, %rsi
callq 0x346a
movq %rbx, %rdi
callq 0x301a
leaq 0x8(%rsp), %rdi
callq 0x2318
movq 0x34d4(%rip), %rax      # 0x6260
cmpq 0x34c5(%rip), %rax      # 0x6258
je 0x2e53
cmpb $0x0, 0x34b0(%rip)      # 0x6250
jne 0x2dab
xorl %edi, %edi
xorl %esi, %esi
callq 0x2190
leaq 0x341e(%rip), %r14      # 0x61d0
movq %r14, %rdi
callq 0x21c0
leaq 0x33ef(%rip), %rbx      # 0x61b0
pushq $0x2
popq %rsi
movq %r14, %rdi
callq 0x21f0
pushq $0xf
popq %rsi
movq %r14, %rdi
callq 0x21f0
xorl %edi, %edi
movq %r14, %rsi
xorl %edx, %edx
callq 0x2050
leaq 0x33de(%rip), %rdi      # 0x61c8
leaq -0x1a8(%rip), %rdx      # 0x2c49
xorl %esi, %esi
movq %rbx, %rcx
callq 0x22b0
movq %rbx, %rdi
callq 0x27b4
movq 0x33ae(%rip), %rdi      # 0x61b8
callq 0x22d0
movq 0x339a(%rip), %rdi      # 0x61b0
callq 0x22d0
leaq 0x1435(%rip), %rdi      # 0x4257
xorl %eax, %eax
callq 0x2577
jmp 0x2e48
movq (%rbx), %rsi
leaq 0x13c6(%rip), %rdi      # 0x41fb
xorl %eax, %eax
callq 0x2030
leaq 0x1466(%rip), %rdi      # 0x42a9
callq 0x2220
xorl %eax, %eax
addq $0x40, %rsp
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x13dd(%rip), %rdi      # 0x4237
jmp 0x2e7d
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x2318
jmp 0x2e6e
movq %rax, %rbx
movq %rbx, %rdi
callq 0x20b0
leaq 0x139a(%rip), %rdi      # 0x4217
xorl %eax, %eax
callq 0x2577
pushq $0x1
popq %rdi
callq 0x21a0