// File: /workspace/github_cpp_makefile_star2_O2/exrok[P]evdoublebind/./src/make_config.cc
// Function: gen(Settings&)
int gen(Settings &settings) {
    char * buffer = file_contents(settings.input_conf);
    if (!buffer) {
        fprintf(stderr,"Error Reading Config File [%s]: ", settings.input_conf);
        perror("");
        exit(1);
    }
    Config config;

    struct xkb_keymap *keymap;
    struct xkb_context *ctx;

    ctx = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
    if (!ctx) {
        exit(1);
    }
    keymap = xkb_keymap_new_from_names(ctx, &settings.xkb_names,
                                       XKB_KEYMAP_COMPILE_NO_FLAGS);
    if (!keymap) {
        exit(1);
    }
    struct xkb_state *state;
    state = xkb_state_new(keymap);

    if (!state) {
        exit(1);
    }

    auto entry = ConfigParser(buffer);
    while (entry.next()) {
        if (strcmp(entry.key, "unused") == 0)  {
            parse_unused_keys(keymap, config, entry.value);
        } else if (strcmp(entry.key, "kbd") == 0) {
            config.keyboards.push(entry.value);
        } else {
            char *symtap_sep = strchr(entry.value, '|');
            char *evtap_sep = strchr(entry.value, '@');
            if (symtap_sep && evtap_sep) {
                fprintf(stderr,"CONFIG ERROR[line:%d]: Both symkey and raw keycode taps specfied.\n",
                        entry.line);
                exit(1);
            }
            auto map = config.mappings.top_new();
            map->keycode = parse_keycode(keymap, entry.key);
            if (symtap_sep != NULL){
                *symtap_sep = '\0';
                symtap_sep++;
                int i = parse_symlevel(map->tap_map, symtap_sep);
                for (int i = 0; i < 2; i++) map->tap_raw[i] = -1;
            } else if (evtap_sep != NULL) {
                *evtap_sep = '\0';
                evtap_sep++;
                parse_raw_tap(entry.line, keymap,map->tap_raw, evtap_sep);
                for (int i = 0; i < 4; i++) map->tap_map[i] = NULL;
            }
            int count = parse_symlevel(map->hold_map, entry.value);
            if (count == 0 && symtap_sep == NULL && evtap_sep == NULL) {
                fprintf(stderr,"CONFIG ERROR[line:%d]: No mappings Specified\n",
                        entry.line);
                exit(1);
            }
        }
    }
    generate_hfile(config,settings);
    if (!settings.only_arguments) {
        generate_xkb_file(keymap,config, settings);
    }
    free(buffer);

    xkb_state_unref(state);
    xkb_keymap_unref(keymap);
    xkb_context_unref(ctx);
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdi, %rbx
movq 0x30(%rdi), %rdi
callq 0x37da
testq %rax, %rax
je 0x4083
movq %rax, %r14
leaq 0x48(%rsp), %rdi
callq 0x42ca
xorl %edi, %edi
callq 0x3150
testq %rax, %rax
je 0x407b
movq %rax, %r15
movq %rax, %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x30e0
testq %rax, %rax
je 0x407b
movq %rax, %r12
movq %r15, 0x38(%rsp)
movq %rbx, 0x40(%rsp)
movq %rax, %rdi
callq 0x3120
movq %rax, 0x30(%rsp)
testq %rax, %rax
je 0x407b
leaq 0x8(%rsp), %rbp
movq %r14, 0x28(%rsp)
movq %r14, (%rbp)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rbp)
orl $-0x1, 0x18(%rbp)
movb $0x0, 0x1c(%rbp)
leaq 0x226b(%rip), %r14      # 0x6101
movq %rbp, %rdi
callq 0x42ea
testb %al, %al
je 0x3ff3
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3130
testl %eax, %eax
je 0x3f4b
movq %rbx, %rdi
leaq 0x2240(%rip), %rsi      # 0x6108
callq 0x3130
movq 0x18(%rsp), %rbx
testl %eax, %eax
je 0x3f62
movq %rbx, %rdi
pushq $0x7c
popq %rsi
callq 0x3090
movq %rax, %r13
movq %rbx, %rdi
pushq $0x40
popq %rsi
callq 0x3090
movq %rax, %r15
testq %r13, %r13
sete %al
testq %r15, %r15
sete %cl
orb %al, %cl
je 0x405f
leaq 0x48(%rsp), %rdi
callq 0x4442
movq %rax, %rbx
movq 0x10(%rsp), %rsi
movq %r12, %rdi
callq 0x3584
movl %eax, (%rbx)
testq %r13, %r13
je 0x3f74
movb $0x0, (%r13)
leaq 0x1(%r13), %rsi
leaq 0x28(%rbx), %rdi
callq 0x3508
orq $-0x1, 0x48(%rbx)
testq %r15, %r15
sete %r15b
jmp 0x3fae
movq 0x18(%rsp), %rdx
movq %r12, %rdi
leaq 0x48(%rsp), %rsi
callq 0x369b
jmp 0x3e96
leaq 0x58(%rsp), %rdi
movq %rbx, %rsi
callq 0x4416
jmp 0x3e96
testq %r15, %r15
je 0x3fab
movb $0x0, (%r15)
incq %r15
movl 0x20(%rsp), %edi
leaq 0x48(%rbx), %rdx
movq %r12, %rsi
movq %r15, %rcx
callq 0x360c
xorl %eax, %eax
cmpq $0x4, %rax
je 0x3fa6
andq $0x0, 0x28(%rbx,%rax,8)
incq %rax
jmp 0x3f95
xorl %r15d, %r15d
jmp 0x3fae
movb $0x1, %r15b
addq $0x8, %rbx
movq 0x18(%rsp), %rsi
movq %rbx, %rdi
callq 0x3508
testb %r15b, %r15b
je 0x3e96
testl %eax, %eax
jne 0x3e96
testq %r13, %r13
jne 0x3e96
movq 0x5018(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
movl 0x20(%rsp), %edx
leaq 0x2161(%rip), %rsi      # 0x614f
jmp 0x4074
leaq 0x48(%rsp), %rdi
movq 0x40(%rsp), %rbx
movq %rbx, %rsi
callq 0x3c08
cmpb $0x0, 0x28(%rbx)
movq 0x38(%rsp), %r14
jne 0x4020
leaq 0x48(%rsp), %rsi
movq %r12, %rdi
movq %rbx, %rdx
callq 0x38e6
movq 0x28(%rsp), %rdi
callq 0x3040
movq 0x30(%rsp), %rdi
callq 0x3200
movq %r12, %rdi
callq 0x3170
movq %r14, %rdi
callq 0x3060
leaq 0x48(%rsp), %rdi
callq 0x445e
xorl %eax, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x4f92(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
movl 0x20(%rsp), %edx
leaq 0x2098(%rip), %rsi      # 0x610c
xorl %eax, %eax
callq 0x3140
pushq $0x1
popq %rdi
callq 0x3220
movq 0x4f6e(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
movq 0x30(%rbx), %rdx
leaq 0x2048(%rip), %rsi      # 0x60e0
xorl %eax, %eax
callq 0x3140
leaq 0x1f2f(%rip), %rdi      # 0x5fd5
callq 0x31e0
jmp 0x407b