user: 请从给定的汇编指令推导出C源代码：

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  sub    $0x608,%rsp
  mov    %rsi,%rbx
  mov    %fs:0x28,%rax
  mov    %rax,0x25f8(%rsp)
  xor    %eax,%eax
  cmp    $0x1,%edi
  jle    L101
  lea    0x20(%rsp),%r15
  mov    %r15,0x8(%rsp)
  mov    $0x1e00,%edx
  mov    $0x0,%esi
  mov    %r15,%rdi
  call   <memset@plt>
  mov    0x8(%rbx),%rdi
  lea    D238(%rip),%rsi
  call   <fopen@plt>
  mov    %rax,%r13
  mov    %r15,%rax
  mov    %r15,(%rsp)
  lea    0x1e20(%rsp),%rbx
L415:
  movw   $0x2222,(%rax)
  movb   $0x0,0x2(%rax)
  movw   $0x2222,0x14(%rax)
  movb   $0x0,0x16(%rax)
  movw   $0x2222,0x28(%rax)
  movb   $0x0,0x2a(%rax)
  add    $0x3c,%rax
  cmp    %rbx,%rax
  jne    L415
  lea    D240(%rip),%r15
L743:
  lea    D367(%rip),%r14
  jmp    L500
L101:
  mov    $0xa,%edi
  call   <putchar@plt>
  mov    (%rbx),%rsi
  lea    D153(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0xa,%edi
  call   <putchar@plt>
  mov    (%rbx),%rsi
  lea    D227(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  lea    D576(%rip),%rdi
  call   <puts@plt>
  jmp    L669
L431:
  lea    0x22d0(%rsp),%rbp
  lea    0x2140(%rsp),%r12
  lea    0x1c(%rsp),%rcx
  lea    0x1fb0(%rsp),%rdx
  lea    0x1e20(%rsp),%rdi
  sub    $0x8,%rsp
  lea    0x2468(%rsp),%rax
  push   %rax
  mov    %rbp,%r9
  mov    %r12,%r8
  lea    D377(%rip),%rsi
  mov    $0x0,%eax
  call   <sscanf@plt>
  movslq 0x2c(%rsp),%rdx
  mov    %rdx,%rax
  shl    $0x4,%rax
  sub    %rdx,%rax
  lea    0x30(%rsp,%rax,4),%rdi
  mov    %r12,%rdx
  mov    %r14,%rsi
  mov    $0x0,%eax
  call   <sprintf@plt>
  lea    D274(%rip),%rsi
  mov    %rbp,%rdi
  call   <strcmp@plt>
  add    $0x10,%rsp
  test   %rax,%rax
  je     L711
  cmpb   $0x0,0x22d0(%rsp)
  je     L711
  movslq 0x1c(%rsp),%rdx
  mov    %rdx,%rax
  shl    $0x4,%rax
  sub    %rdx,%rax
  lea    0x34(%rsp,%rax,4),%rdi
  mov    %rbp,%rdx
  mov    %r14,%rsi
  mov    $0x0,%eax
  call   <sprintf@plt>
  lea    0x2460(%rsp),%rdi
  lea    D274(%rip),%rsi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L711
  cmpb   $0x0,0x2460(%rsp)
  je     L711
  lea    0x2460(%rsp),%rdx
  movslq 0x1c(%rsp),%rax
  imul   $0x3c,%rax,%rax
  lea    0x48(%rsp,%rax,1),%rdi
  mov    %r14,%rsi
  mov    $0x0,%eax
  call   <sprintf@plt>
  jmp    L711
L461:
  lea    0x2140(%rsp),%rbp
  lea    0x1fb0(%rsp),%rdx
  lea    0x1e20(%rsp),%rdi
  mov    %rbp,%r9
  lea    0x1c(%rsp),%r8
  mov    %rdx,%rcx
  lea    D51(%rip),%rsi
  call   <sscanf@plt>
  movslq 0x1c(%rsp),%rdx
  mov    %rdx,%rax
  shl    $0x4,%rax
  sub    %rdx,%rax
  lea    0x20(%rsp,%rax,4),%rdi
  mov    %rbp,%rdx
  mov    %r14,%rsi
  mov    $0x0,%eax
  call   <sprintf@plt>
  jmp    L490
L625:
  lea    0x1fb0(%rsp),%rdi
  lea    D358(%rip),%rsi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L634
L500:
  mov    %r13,%rdi
  call   <feof@plt>
  test   %eax,%eax
  jne    L623
  lea    0x1e20(%rsp),%r12
  mov    %r13,%rdx
  mov    $0x190,%esi
  mov    %r12,%rdi
  call   <fgets@plt>
  lea    0x1fb0(%rsp),%rbp
  mov    %rbp,%rdx
  mov    %r15,%rsi
  mov    %r12,%rdi
  mov    $0x0,%eax
  call   <sscanf@plt>
  movb   $0x0,0x22d0(%rsp)
  movb   $0x0,0x2460(%rsp)
  lea    D135(%rip),%rsi
  mov    %rbp,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L431
L711:
  lea    0x1fb0(%rsp),%rdi
  lea    D113(%rip),%rsi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L461
L490:
  lea    0x1fb0(%rsp),%rdi
  lea    D591(%rip),%rsi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L625
  lea    0x2140(%rsp),%rbp
  lea    0x1fb0(%rsp),%rdx
  lea    0x1e20(%rsp),%rdi
  mov    %rbp,%r9
  lea    0x1c(%rsp),%r8
  mov    %rdx,%rcx
  lea    D51(%rip),%rsi
  call   <sscanf@plt>
  movslq 0x1c(%rsp),%rdx
  mov    %rdx,%rax
  shl    $0x4,%rax
  sub    %rdx,%rax
  lea    0x34(%rsp,%rax,4),%rdi
  mov    %rbp,%rdx
  mov    %r14,%rsi
  mov    $0x0,%eax
  call   <sprintf@plt>
  jmp    L625
L634:
  lea    0x2140(%rsp),%rbp
  lea    0x1fb0(%rsp),%rdx
  lea    0x1e20(%rsp),%rdi
  mov    %rbp,%r9
  lea    0x1c(%rsp),%r8
  mov    %rdx,%rcx
  lea    D51(%rip),%rsi
  call   <sscanf@plt>
  movslq 0x1c(%rsp),%rdx
  mov    %rdx,%rax
  shl    $0x4,%rax
  sub    %rdx,%rax
  lea    0x48(%rsp,%rax,4),%rdi
  mov    %rbp,%rdx
  lea    D367(%rip),%rsi
  mov    $0x0,%eax
  call   <sprintf@plt>
  jmp    L743
L623:
  mov    0x8(%rsp),%r12
  jmp    L410
L48:
  movsbl 0x0(%rbp),%edi
  call   <toupper@plt>
  mov    %al,0x0(%rbp)
  add    $0x1,%r13d
  add    $0x1,%rbp
L530:
  mov    %r14,%rdi
  call   <strlen@plt>
  cmp    %r13d,%eax
  jg     L48
  lea    0x14(%r12),%r14
  mov    %r12,%rbp
  mov    $0x0,%r13d
  jmp    L651
L373:
  movsbl 0x13(%rbp),%edi
  call   <toupper@plt>
  mov    %al,0x13(%rbp)
  add    $0x1,%r13d
L651:
  mov    %r14,%rdi
  call   <strlen@plt>
  add    $0x1,%rbp
  cmp    %r13d,%eax
  jg     L373
  lea    0x28(%r12),%r14
  mov    %r12,%rbp
  mov    $0x0,%r13d
  jmp    L75
L160:
  movsbl 0x27(%rbp),%edi
  call   <toupper@plt>
  mov    %al,0x27(%rbp)
  add    $0x1,%r13d
L75:
  mov    %r14,%rdi
  call   <strlen@plt>
  add    $0x1,%rbp
  cmp    %r13d,%eax
  jg     L160
  add    $0x3c,%r12
  cmp    %rbx,%r12
  je     L351
L410:
  mov    %r12,%r14
  mov    %r12,%rbp
  mov    $0x0,%r13d
  jmp    L530
L351:
  mov    $0x61,%r14d
  lea    0x1fb0(%rsp),%r12
  lea    D408(%rip),%r13
  jmp    L215
L147:
  mov    %r14d,%edx
  mov    %r13,%rsi
  mov    %rbp,%rdi
  call   <sprintf@plt>
  lea    0x14(%rbp),%rdi
  mov    %r15d,%edx
  mov    %r13,%rsi
  mov    $0x0,%eax
  call   <sprintf@plt>
L680:
  add    $0x3c,%rbp
  cmp    %rbx,%rbp
  je     L463
L212:
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L680
  jmp    L147
L463:
  add    $0x1,%r14d
  cmp    $0x7b,%r14d
  je     L321
L215:
  lea    -0x20(%r14),%r15d
  mov    %r15d,%edx
  mov    %r13,%rsi
  mov    %r12,%rdi
  mov    $0x0,%eax
  call   <sprintf@plt>
  mov    (%rsp),%rbp
  jmp    L212
L321:
  lea    0x34(%rsp),%r12
  mov    0x8(%rsp),%r13
  add    $0x1e14,%r13
  lea    D458(%rip),%r15
  lea    D283(%rip),%r14
  jmp    L235
L439:
  movabs $0x22545245534e4922,%rax
  mov    %rax,(%r12)
  movb   $0x0,0x8(%r12)
  jmp    L151
L504:
  movl   $0x444e4522,(%r12)
  movw   $0x22,0x4(%r12)
  jmp    L719
L269:
  movl   $0x574f4422,(%r12)
  movw   $0x224e,0x4(%r12)
  movb   $0x0,0x6(%r12)
  jmp    L608
L402:
  movabs $0x574f444547415022,%rax
  mov    %rax,(%r12)
  movw   $0x224e,0x8(%r12)
  movb   $0x0,0xa(%r12)
  jmp    L597
L257:
  movl   $0x46454c22,(%r12)
  movw   $0x2254,0x4(%r12)
  movb   $0x0,0x6(%r12)
  jmp    L658
L561:
  movw   $0x2222,(%r12)
  movb   $0x0,0x2(%r12)
  jmp    L80
L449:
  movabs $0x22544847495222,%rax
  mov    %rax,(%r12)
  jmp    L621
L654:
  movl   $0x4d4f4822,(%r12)
  movw   $0x2245,0x4(%r12)
  movb   $0x0,0x6(%r12)
  jmp    L480
L663:
  movl   $0x22505522,(%r12)
  movb   $0x0,0x4(%r12)
  jmp    L231
L306:
  movabs $0x2250554547415022,%rax
  mov    %rax,(%r12)
  movb   $0x0,0x8(%r12)
  jmp    L148
L16:
  add    $0x3c,%r12
  cmp    %r13,%r12
  je     L435
L235:
  lea    -0x14(%r12),%rbp
  mov    %r15,%rsi
  mov    %rbp,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L439
L151:
  mov    %r14,%rsi
  mov    %rbp,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L504
L719:
  lea    D116(%rip),%rsi
  mov    %rbp,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L269
L608:
  lea    D581(%rip),%rsi
  mov    %rbp,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L402
L597:
  lea    D410(%rip),%rsi
  mov    %rbp,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L257
L658:
  lea    D107(%rip),%rsi
  mov    %rbp,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L561
L80:
  lea    D111(%rip),%rsi
  mov    %rbp,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L449
L621:
  lea    D294(%rip),%rsi
  mov    %rbp,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L654
L480:
  lea    D289(%rip),%rsi
  mov    %rbp,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L663
L231:
  lea    D507(%rip),%rsi
  mov    %rbp,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L306
L148:
  lea    D337(%rip),%rsi
  mov    %rbp,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L16
  movabs $0x2245564f4d455222,%rax
  mov    %rax,(%r12)
  movb   $0x0,0x8(%r12)
  jmp    L16
L435:
  mov    $0x80,%esi
  lea    D341(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x14,%esi
  lea    D399(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x0,%esi
  lea    D359(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x1,%esi
  lea    D16(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x2,%esi
  lea    D475(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x3,%esi
  lea    D517(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0xa,%edi
  call   <putchar@plt>
  lea    D104(%rip),%rdi
  call   <puts@plt>
  mov    $0x0,%r13d
  movl   $0x0,0x8(%rsp)
  lea    D544(%rip),%r15
  jmp    L382
L24:
  lea    D357(%rip),%rdi
  call   <puts@plt>
  jmp    L189
L547:
  lea    D438(%rip),%rdi
  call   <puts@plt>
  jmp    L189
L210:
  lea    D157(%rip),%rdi
  call   <puts@plt>
  jmp    L189
L520:
  mov    %rbp,%rdi
  call   <free@plt>
  add    $0x3c,%r12
  cmp    %rbx,%r12
  je     L522
L157:
  mov    %r12,%rdi
  call   <strlen@plt>
  mov    %eax,%esi
  mov    $0x1,%edi
  call   <calloc@plt>
  mov    %rax,%rbp
  lea    0x1(%r12),%rsi
  mov    %rax,%rdi
  call   <strcpy@plt>
  mov    %rbp,%rdi
  call   <strlen@plt>
  cltq
  movb   $0x0,-0x1(%rbp,%rax,1)
  mov    %rbp,%rdi
  call   <strlen@plt>
  test   %eax,%eax
  jle    L520
  lea    0x1(%r13),%r14d
  mov    %rbp,%rdx
  mov    %r13d,%esi
  mov    %r15,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    %r14d,%r13d
  jmp    L520
L522:
  addl   $0x1,0x8(%rsp)
  mov    0x8(%rsp),%eax
  add    $0x14,%rbx
  cmp    $0x3,%eax
  je     L710
L382:
  mov    0x8(%rsp),%eax
  cmp    $0x1,%eax
  je     L547
  cmp    $0x2,%eax
  je     L210
  test   %eax,%eax
  je     L24
L189:
  lea    -0x1e00(%rbx),%r12
  jmp    L157
L710:
  mov    %r13d,%esi
  lea    D43(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  lea    D456(%rip),%rdi
  call   <puts@plt>
  mov    $0xa,%edi
  call   <putchar@plt>
  lea    D30(%rip),%rdi
  call   <puts@plt>
  lea    D304(%rip),%r8
  lea    D563(%rip),%rcx
  lea    D2(%rip),%rdx
  lea    D519(%rip),%rsi
  lea    D305(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x0,%r14d
  mov    $0x0,%r13d
  jmp    L190
L696:
  lea    D160(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L567:
  lea    -0x1(%r12),%eax
  cmp    $0x1,%eax
  jg     L15
  mov    %r15,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    %rbx,%rdi
  call   <free@plt>
L482:
  add    $0x14,%rbp
  add    $0x1,%r12d
L243:
  mov    %rbp,%rdi
  call   <strlen@plt>
  mov    %eax,%esi
  mov    $0x1,%edi
  call   <calloc@plt>
  mov    %rax,%rbx
  lea    0x1(%rbp),%rsi
  mov    %rax,%rdi
  call   <strcpy@plt>
  mov    %rbx,%rdi
  call   <strlen@plt>
  cltq
  movb   $0x0,-0x1(%rbx,%rax,1)
  mov    %rbx,%rdi
  call   <strlen@plt>
  test   %eax,%eax
  jle    L696
  mov    %rbx,%rsi
  lea    D485(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L567
L15:
  mov    %rbx,%rdi
  call   <free@plt>
  cmp    $0x2,%r12d
  jle    L482
  lea    D303(%rip),%rdi
  call   <puts@plt>
  add    $0x1,%r13d
  add    $0x3c,%r14
  cmp    $0x80,%r13d
  je     L423
L190:
  mov    %r13d,%esi
  lea    D362(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    (%rsp),%rax
  lea    (%r14,%rax,1),%rbp
  mov    $0x1,%r12d
  lea    D550(%rip),%r15
  jmp    L243
L423:
  lea    D318(%rip),%rdi
  call   <puts@plt>
  mov    $0xa,%edi
  call   <putchar@plt>
  lea    D314(%rip),%rdi
  call   <puts@plt>
  lea    D304(%rip),%r8
  lea    D563(%rip),%rcx
  lea    D2(%rip),%rdx
  lea    D519(%rip),%rsi
  lea    D305(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x0,%ebx
  lea    D75(%rip),%rbp
  mov    (%rsp),%r12
L744:
  lea    0x14(%r12),%rcx
  lea    0x28(%r12),%r8
  mov    %r12,%rdx
  mov    %ebx,%esi
  mov    %rbp,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  add    $0x1,%ebx
  add    $0x3c,%r12
  cmp    $0x80,%ebx
  jne    L744
  lea    D318(%rip),%rdi
  call   <puts@plt>
L669:
  mov    0x25f8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L717
  mov    $0x0,%eax
  add    $0x2608,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L717:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: tag: D238
datatype: string
name: retrieve_data
arguments: tag: D240
datatype: string
name: retrieve_data
arguments: tag: D367
datatype: string
name: retrieve_data
arguments: tag: D153
datatype: string
name: retrieve_data
arguments: tag: D227
datatype: string
name: retrieve_data
arguments: tag: D576
datatype: string
name: retrieve_data
arguments: tag: D377
datatype: string
name: retrieve_data
arguments: tag: D274
datatype: string
name: retrieve_data
arguments: tag: D51
datatype: string
name: retrieve_data
arguments: tag: D358
datatype: string
name: retrieve_data
arguments: tag: D135
datatype: string
name: retrieve_data
arguments: tag: D113
datatype: string
name: retrieve_data
arguments: tag: D591
datatype: string
name: retrieve_data
arguments: tag: D408
datatype: string
name: retrieve_data
arguments: tag: D458
datatype: string
name: retrieve_data
arguments: tag: D283
datatype: string
name: retrieve_data
arguments: tag: D116
datatype: string
name: retrieve_data
arguments: tag: D581
datatype: string
name: retrieve_data
arguments: tag: D410
datatype: string
name: retrieve_data
arguments: tag: D107
datatype: string
name: retrieve_data
arguments: tag: D111
datatype: string
name: retrieve_data
arguments: tag: D294
datatype: string
name: retrieve_data
arguments: tag: D289
datatype: string
name: retrieve_data
arguments: tag: D507
datatype: string
name: retrieve_data
arguments: tag: D337
datatype: string
name: retrieve_data
arguments: tag: D341
datatype: string
name: retrieve_data
arguments: tag: D399
datatype: string
name: retrieve_data
arguments: tag: D359
datatype: string
name: retrieve_data
arguments: tag: D16
datatype: string
name: retrieve_data
arguments: tag: D475
datatype: string
name: retrieve_data
arguments: tag: D517
datatype: string
name: retrieve_data
arguments: tag: D104
datatype: string
name: retrieve_data
arguments: tag: D544
datatype: string
name: retrieve_data
arguments: tag: D357
datatype: string
name: retrieve_data
arguments: tag: D438
datatype: string
name: retrieve_data
arguments: tag: D157
datatype: string
name: retrieve_data
arguments: tag: D43
datatype: string
name: retrieve_data
arguments: tag: D456
datatype: string
name: retrieve_data
arguments: tag: D30
datatype: string
name: retrieve_data
arguments: tag: D304
datatype: string
name: retrieve_data
arguments: tag: D563
datatype: string
name: retrieve_data
arguments: tag: D2
datatype: string
name: retrieve_data
arguments: tag: D519
datatype: string
name: retrieve_data
arguments: tag: D305
datatype: string
name: retrieve_data
arguments: tag: D160
datatype: string
name: retrieve_data
arguments: tag: D485
datatype: string
name: retrieve_data
arguments: tag: D303
datatype: string
name: retrieve_data
arguments: tag: D362
datatype: string
name: retrieve_data
arguments: tag: D550
datatype: string
name: retrieve_data
arguments: tag: D318
datatype: string
name: retrieve_data
arguments: tag: D314
datatype: string
name: retrieve_data
arguments: tag: D75
datatype: string

tool: D238: rt

tool: D240: %s

tool: D367: "%s"

tool: D153: %s is to prepare a hader file from a map file.


tool: D227: Ex:
	mkdir kbdmap
	files included in the us.map.gz are;
		compose.latin1
		euro1.map
		linux-keys-bare.inc
		linux-with-alt-and-altgr.inc
		qwerty-layout.inc
	copy all_of_them_and_the_us.map.gz to kbdmap
	gunzip us.map.gz
	cat * > usmap
	%s usmap > usmap.h



tool: D576: Alper Akcan, distchx@yahoo.com


tool: D377: %s %d = %s %s %s

tool: D274: #

tool: D51: %s %s %d = %s

tool: D358: altgr

tool: D135: keycode

tool: D113: plain

tool: D591: shift

tool: D408: "%c"

tool: D458: "KP_0"

tool: D283: "KP_1"

tool: D116: "KP_2"

tool: D581: "KP_3"

tool: D410: "KP_4"

tool: D107: "KP_5"

tool: D111: "KP_6"

tool: D294: "KP_7"

tool: D289: "KP_8"

tool: D507: "KP_9"

tool: D337: "KP_PERIOD"

tool: D341: #define KEYCODE_KEYS	%d


tool: D399: #define KEYCODE_MAXNAMELEN	%d


tool: D359: #define KEYCODE_PLAIN	%d


tool: D16: #define KEYCODE_SHIFT	%d


tool: D475: #define KEYCODE_ALTGR	%d


tool: D517: #define KEYCODE_FLAGS	%d


tool: D104: typedef enum {

tool: D544: /* %3d */  XYNTHK_%s,


tool: D357: /* Plain */

tool: D438: /* Shift */

tool: D157: /* ALTGR */

tool: D43: /* %3d */  XYNTHK_CODES


tool: D456: } XYNTHK_CODE;

tool: D30: static XYNTHK_CODE kbd_keycodes_[KEYCODE_KEYS][KEYCODE_FLAGS][KEYCODE_MACNAMELEN] = {

tool: D304: altgr name 

tool: D563: shift name,

tool: D2: plain name,

tool: D519: keycode,

tool: D305: /*%10s %18s %18s %17s*/


tool: D160: XYNTH_NOCODE

tool: D485: XYNTHK_%s

tool: D303: },

tool: D362: /* %3d */  {

tool: D550: ,	

tool: D318: };

tool: D314: static char kbd_keycodes[KEYCODE_KEYS][KEYCODE_FLAGS][KEYCODE_MAXNAMELEN] = {

tool: D75: /* %3d */  {%18s,%18s,%18s},


assistant: ```c
int main(int argc, char *argv[]) {
  int i;
  int j;
  int k;
  FILE *mapfile;
  char codenames[128][3][20];
  int size = sizeof(codenames);
  char buf[400];
  char buf1[400];
  char buf2[400];
  char buf3[400];
  char buf4[400];
  int int1;
  if (argc < 2) {
    printf("\n");
    printf("%s is to prepare a hader file from a map file.\n", argv[0]);
    printf("\n");
    printf("Ex:\n"
           "\tmkdir kbdmap\n"
           "\tfiles included in the us.map.gz are;\n"
           "\t\tcompose.latin1\n"
           "\t\teuro1.map\n"
           "\t\tlinux-keys-bare.inc\n"
           "\t\tlinux-with-alt-and-altgr.inc\n"
           "\t\tqwerty-layout.inc\n"
           "\tcopy all_of_them_and_the_us.map.gz to kbdmap\n"
           "\tgunzip us.map.gz\n"
           "\tcat * > usmap\n"
           "\t%s usmap > usmap.h\n\n",
           argv[0]);
    printf("Alper Akcan, distchx@yahoo.com\n\n");
    return 0;
  }
  memset(codenames, 0, size);
  mapfile = fopen(argv[1], "rt");
  for (i = 0; i < 128; i++) {
    for (j = 0; j < 3; j++) {
      sprintf(codenames[i][j], "\"\"");
    }
  }
  while (!feof(mapfile)) {
    fgets(buf, 400, mapfile);
    sscanf(buf, "%s", buf1);
    buf3[0] = '\0';
    buf4[0] = '\0';
    if (strcmp(buf1, "keycode") == 0) {
      sscanf(buf, "%s %d = %s %s %s", buf1, &int1, buf2, buf3, buf4);
      sprintf(codenames[int1][0], "\"%s\"", buf2);
      if ((strcmp(buf3, "#") != 0) && (buf3[0] != '\0')) {
        sprintf(codenames[int1][1], "\"%s\"", buf3);
        if ((strcmp(buf4, "#") != 0) && (buf4[0] != '\0')) {
          sprintf(codenames[int1][2], "\"%s\"", buf4);
        }
      }
    }
    if (strcmp(buf1, "plain") == 0) {
      sscanf(buf, "%s %s %d = %s", buf1, buf1, &int1, buf2);
      sprintf(codenames[int1][0], "\"%s\"", buf2);
    }
    if (strcmp(buf1, "shift") == 0) {
      sscanf(buf, "%s %s %d = %s", buf1, buf1, &int1, buf2);
      sprintf(codenames[int1][1], "\"%s\"", buf2);
    }
    if (strcmp(buf1, "altgr") == 0) {
      sscanf(buf, "%s %s %d = %s", buf1, buf1, &int1, buf2);
      sprintf(codenames[int1][2], "\"%s\"", buf2);
    }
  }
  for (i = 0; i < 128; i++) {
    for (j = 0; j < strlen(codenames[i][0]); j++) {
      codenames[i][0][j] = toupper(codenames[i][0][j]);
    }
    for (j = 0; j < strlen(codenames[i][1]); j++) {
      codenames[i][1][j] = toupper(codenames[i][1][j]);
    }
    for (j = 0; j < strlen(codenames[i][2]); j++) {
      codenames[i][2][j] = toupper(codenames[i][2][j]);
    }
  }
  for (j = 65; j < 91; j++) {
    sprintf(buf1, "\"%c\"", j);
    for (i = 0; i < 128; i++) {
      if (strcmp(codenames[i][0], buf1) == 0) {
        sprintf(codenames[i][0], "\"%c\"", j + 32);
        sprintf(codenames[i][1], "\"%c\"", j);
      }
    }
  }
  for (i = 0; i < 128; i++) {
    if (strcmp(codenames[i][0], "\"KP_0\"") == 0) {
      sprintf(codenames[i][1], "\"INSERT\"");
    }
    if (strcmp(codenames[i][0], "\"KP_1\"") == 0) {
      sprintf(codenames[i][1], "\"END\"");
    }
    if (strcmp(codenames[i][0], "\"KP_2\"") == 0) {
      sprintf(codenames[i][1], "\"DOWN\"");
    }
    if (strcmp(codenames[i][0], "\"KP_3\"") == 0) {
      sprintf(codenames[i][1], "\"PAGEDOWN\"");
    }
    if (strcmp(codenames[i][0], "\"KP_4\"") == 0) {
      sprintf(codenames[i][1], "\"LEFT\"");
    }
    if (strcmp(codenames[i][0], "\"KP_5\"") == 0) {
      sprintf(codenames[i][1], "\"\"");
    }
    if (strcmp(codenames[i][0], "\"KP_6\"") == 0) {
      sprintf(codenames[i][1], "\"RIGHT\"");
    }
    if (strcmp(codenames[i][0], "\"KP_7\"") == 0) {
      sprintf(codenames[i][1], "\"HOME\"");
    }
    if (strcmp(codenames[i][0], "\"KP_8\"") == 0) {
      sprintf(codenames[i][1], "\"UP\"");
    }
    if (strcmp(codenames[i][0], "\"KP_9\"") == 0) {
      sprintf(codenames[i][1], "\"PAGEUP\"");
    }
    if (strcmp(codenames[i][0], "\"KP_PERIOD\"") == 0) {
      sprintf(codenames[i][1], "\"REMOVE\"");
    }
  }
  printf("#define KEYCODE_KEYS\t%d\n", 128);
  printf("#define KEYCODE_MAXNAMELEN\t%d\n", 20);
  printf("#define KEYCODE_PLAIN\t%d\n", 0);
  printf("#define KEYCODE_SHIFT\t%d\n", 1);
  printf("#define KEYCODE_ALTGR\t%d\n", 2);
  printf("#define KEYCODE_FLAGS\t%d\n", 3);
  printf("\n");
  printf("typedef enum {\n");
  k = 0;
  for (j = 0; j < 3; j++) {
    switch (j) {
    case 0:
      printf("/* Plain */\n");
      break;
    case 1:
      printf("/* Shift */\n");
      break;
    case 2:
      printf("/* ALTGR */\n");
      break;
    }
    for (i = 0; i < 128; i++) {
      char *name;
      name = (char *)calloc(sizeof(char), strlen(codenames[i][j]));
      sprintf(name, "%s", codenames[i][j] + 1);
      name[strlen(name) - 1] = '\0';
      if (strlen(name) > 0) {
        printf("/* %3d */  XYNTHK_%s,\n", k++, name);
      }
      free(name);
    }
  }
  printf("/* %3d */  XYNTHK_CODES\n", k);
  printf("} XYNTHK_CODE;\n");
  printf("\n");
  printf("static XYNTHK_CODE kbd_keycodes_[KEYCODE_KEYS][KEYCODE_FLAGS][KEYCODE_MACNAMELEN] = {\n");
  printf("/*%10s %18s %18s %17s*/\n", "keycode,", "plain name,", "shift name,", "altgr name ");
  for (i = 0; i < 128; i++) {
    printf("/* %3d */  {", i);
    for (j = 0; j < 3; j++) {
      char *name;
      name = (char *)calloc(sizeof(char), strlen(codenames[i][j]));
      sprintf(name, "%s", codenames[i][j] + 1);
      name[strlen(name) - 1] = '\0';
      if (strlen(name) > 0) {
        printf("XYNTHK_%s", name);
      } else {
        printf("XYNTH_NOCODE");
      }
      if (j < 2) {
        printf(",\t");
      }
      free(name);
    }
    printf("},\n");
  }
  printf("};\n");
  printf("\n");
  printf("static char kbd_keycodes[KEYCODE_KEYS][KEYCODE_FLAGS][KEYCODE_MAXNAMELEN] = {\n");
  printf("/*%10s %18s %18s %17s*/\n", "keycode,", "plain name,", "shift name,", "altgr name ");
  for (i = 0; i < 128; i++) {
    printf("/* %3d */  {%18s,%18s,%18s},\n", i, codenames[i][0], codenames[i][1], codenames[i][2]);
  }
  printf("};\n");
  return 0;
}
```