// File: /workspace/github_cpp_makefile_star2_O1/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, 0x348a(%rip)      # 0x6248
movq $0x7a120, 0x34c7(%rip) # imm = 0x7A120
movb $0x1, 0x34c8(%rip)      # 0x6298
xorps %xmm0, %xmm0
movups %xmm0, 0x34a6(%rip)     # 0x6280
leaq 0x149c(%rip), %r14      # 0x427d
movl %ebp, %edi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2040
cmpl $0x64, %eax
jne 0x2dfc
movb $0x1, 0x344e(%rip)      # 0x6248
jmp 0x2de1
cmpl $-0x1, %eax
jne 0x2f26
leaq 0x339c(%rip), %rdi      # 0x61a8
callq 0x2764
leaq 0x18(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x13da(%rip), %rsi      # 0x41fb
leaq 0x13de(%rip), %rdx      # 0x4206
leaq 0x8(%rsp), %rdi
callq 0x2fd4
leaq 0x28(%rsp), %rdi
callq 0x24fc
leaq 0x340d(%rip), %rdi      # 0x6250
leaq 0x28(%rsp), %rbx
movq %rbx, %rsi
callq 0x3454
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x2e65
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x2150
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
je 0x2e7c
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2150
movq 0x33d5(%rip), %rax      # 0x6258
cmpq 0x33c6(%rip), %rax      # 0x6250
je 0x2f4e
cmpb $0x0, 0x33b1(%rip)      # 0x6248
jne 0x2ea2
xorl %edi, %edi
xorl %esi, %esi
callq 0x2180
leaq 0x331f(%rip), %rbx      # 0x61c8
movq %rbx, %rdi
callq 0x21b0
leaq 0x32f0(%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 0x32db(%rip), %rdi      # 0x61c0
leaq -0x1b2(%rip), %rdx      # 0x2d3a
xorl %esi, %esi
movq %r14, %rcx
callq 0x22a0
movq %r14, %rdi
callq 0x2830
movq 0x32ab(%rip), %rdi      # 0x61b0
callq 0x22c0
movq 0x3297(%rip), %rdi      # 0x61a8
callq 0x22c0
leaq 0x132a(%rip), %rdi      # 0x4247
xorl %eax, %eax
callq 0x25eb
jmp 0x2f43
movq (%rbx), %rsi
leaq 0x12bb(%rip), %rdi      # 0x41eb
xorl %eax, %eax
callq 0x2030
leaq 0x135b(%rip), %rdi      # 0x4299
callq 0x2210
xorl %eax, %eax
addq $0x40, %rsp
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x12d2(%rip), %rdi      # 0x4227
jmp 0x2f85
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
je 0x2f76
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2150
jmp 0x2f76
movq %rax, %rbx
movq %rbx, %rdi
callq 0x20a0
leaq 0x1282(%rip), %rdi      # 0x4207
xorl %eax, %eax
callq 0x25eb
movl $0x1, %edi
callq 0x2190