// File: exrok[P]evdoublebind/./src/make_config.cc
// Function: generate_hfile(Config&, Settings&)
void generate_hfile(Config &config, Settings &settings) {
     FILE * hfile;
     if (settings.evdoublebind_conf_output == NULL) {
         hfile = stdout;
     } else {
         hfile = fopen(settings.evdoublebind_conf_output, "w");
     }
     if (hfile == NULL) {
         perror("Failed Creating xkb config file: ");
     }
     for (auto &kbd : config.keyboards){
         fprintf(hfile,"%s ", kbd);
         auto unused = config.unused_keys.begin();
         bool first = true;
         for (auto & mapping: config.mappings) {
             if (mapping.tap_map[0] != NULL) {
                 if (unused == config.unused_keys.end()) {
                     fprintf(stderr,"ERROR: not enough unused keys specified for config\n");
                     exit(1);
                 }
                 if (!first) {
                     fprintf(hfile,",");
                 }
                 first = false;
                 fprintf(hfile,"%d:%d", mapping.keycode - 8, *unused - 8);
                 unused++;
             } else if (mapping.tap_raw[0] != -1) {
                 if (!first) {
                     fprintf(hfile,",");
                 }
                 first = false;
                 fprintf(hfile,"%d:%d", mapping.keycode - 8, mapping.tap_raw[0] - 8);
                 if (mapping.tap_raw[1] != -1) {
                     fprintf(hfile,"|%d", mapping.tap_raw[1] - 8);
                 }
             }
         }
         fprintf(hfile,"\n");
     }
     if (settings.evdoublebind_conf_output != NULL) {
         fclose(hfile); //don't close stdout
     } else {
         fflush(stdout);
     }
}

// Assembly:
subq $0x78, %rsp
movq %rdi, 0x70(%rsp)
movq %rsi, 0x68(%rsp)
movq 0x68(%rsp), %rax
cmpq $0x0, 0x40(%rax)
jne 0x411b
movq 0x5eaf(%rip), %rax      # 0x9fc0
movq (%rax), %rax
movq %rax, 0x60(%rsp)
jmp 0x4135
movq 0x68(%rsp), %rax
movq 0x40(%rax), %rdi
leaq 0x303d(%rip), %rsi      # 0x7168
callq 0x31d0
movq %rax, 0x60(%rsp)
cmpq $0x0, 0x60(%rsp)
jne 0x4149
leaq 0x3026(%rip), %rdi      # 0x716a
callq 0x31e0
movq 0x70(%rsp), %rax
addq $0x10, %rax
movq %rax, 0x58(%rsp)
movq 0x58(%rsp), %rdi
callq 0x4be0
movq %rax, 0x50(%rsp)
movq 0x58(%rsp), %rdi
callq 0x4bf0
movq %rax, 0x48(%rsp)
movq 0x50(%rsp), %rax
cmpq 0x48(%rsp), %rax
je 0x436b
movq 0x50(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x60(%rsp), %rdi
movq 0x40(%rsp), %rax
movq (%rax), %rdx
leaq 0x306d(%rip), %rsi      # 0x7210
movb $0x0, %al
callq 0x3130
movq 0x70(%rsp), %rdi
addq $0x20, %rdi
callq 0x4b80
movq %rax, 0x38(%rsp)
movb $0x1, 0x37(%rsp)
movq 0x70(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x28(%rsp), %rdi
callq 0x4b90
movq %rax, 0x20(%rsp)
movq 0x28(%rsp), %rdi
callq 0x4ba0
movq %rax, 0x18(%rsp)
movq 0x20(%rsp), %rax
cmpq 0x18(%rsp), %rax
je 0x4345
movq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rax
cmpq $0x0, 0x28(%rax)
je 0x42b1
movq 0x38(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x70(%rsp), %rdi
addq $0x20, %rdi
callq 0x4bc0
movq %rax, %rcx
movq 0x8(%rsp), %rax
cmpq %rcx, %rax
jne 0x425b
movq 0x5db8(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
leaq 0x2f92(%rip), %rsi      # 0x71dc
movb $0x0, %al
callq 0x3130
movl $0x1, %edi
callq 0x3220
testb $0x1, 0x37(%rsp)
jne 0x4275
movq 0x60(%rsp), %rdi
leaq 0x2fa6(%rip), %rsi      # 0x7214
movb $0x0, %al
callq 0x3130
movb $0x0, 0x37(%rsp)
movq 0x60(%rsp), %rdi
movq 0x10(%rsp), %rax
movl (%rax), %edx
subl $0x8, %edx
movq 0x38(%rsp), %rax
movl (%rax), %ecx
subl $0x8, %ecx
leaq 0x2f7c(%rip), %rsi      # 0x7216
movb $0x0, %al
callq 0x3130
movq 0x38(%rsp), %rax
addq $0x4, %rax
movq %rax, 0x38(%rsp)
jmp 0x4330
movq 0x10(%rsp), %rax
cmpl $-0x1, 0x48(%rax)
je 0x432e
testb $0x1, 0x37(%rsp)
jne 0x42d6
movq 0x60(%rsp), %rdi
leaq 0x2f45(%rip), %rsi      # 0x7214
movb $0x0, %al
callq 0x3130
movb $0x0, 0x37(%rsp)
movq 0x60(%rsp), %rdi
movq 0x10(%rsp), %rax
movl (%rax), %edx
subl $0x8, %edx
movq 0x10(%rsp), %rax
movl 0x48(%rax), %ecx
subl $0x8, %ecx
leaq 0x2f1a(%rip), %rsi      # 0x7216
movb $0x0, %al
callq 0x3130
movq 0x10(%rsp), %rax
cmpl $-0x1, 0x4c(%rax)
je 0x432c
movq 0x60(%rsp), %rdi
movq 0x10(%rsp), %rax
movl 0x4c(%rax), %edx
subl $0x8, %edx
leaq 0x2ef7(%rip), %rsi      # 0x721c
movb $0x0, %al
callq 0x3130
jmp 0x432e
jmp 0x4330
jmp 0x4332
movq 0x20(%rsp), %rax
addq $0x50, %rax
movq %rax, 0x20(%rsp)
jmp 0x41ea
movq 0x60(%rsp), %rdi
leaq 0x2dc1(%rip), %rsi      # 0x7112
movb $0x0, %al
callq 0x3130
movq 0x50(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x50(%rsp)
jmp 0x4175
movq 0x68(%rsp), %rax
cmpq $0x0, 0x40(%rax)
je 0x4383
movq 0x60(%rsp), %rdi
callq 0x3070
jmp 0x4392
movq 0x5c36(%rip), %rax      # 0x9fc0
movq (%rax), %rdi
callq 0x3180
addq $0x78, %rsp
retq
nopw (%rax,%rax)