user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<main>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  lea    D56(%rip),%rdi
  call   <printf@plt>
  lea    0x4(%rsp),%rdx
  mov    %rsp,%rsi
  lea    D18(%rip),%rdi
  call   <scanf@plt>
L51:
  mov    $0x0,%eax
  call   <getchar@plt>
  cmp    $0x20,%al
  je     L51
  jmp    L115
L37:
  imul   $0x3c,(%rsp),%ebx
  add    0x4(%rsp),%ebx
  add    $0xc,%ebx
L115:
  mov    $0x0,%eax
  call   <getchar@plt>
  movsbl %al,%edi
  cmp    $0xa,%al
  je     L141
  call   <toupper@plt>
  cmp    $0x41,%al
  je     L144
  cmp    $0x50,%al
  jne    L115
  mov    $0x0,%eax
  call   <getchar@plt>
  movsbl %al,%edi
  call   <toupper@plt>
  cmp    $0x4d,%al
  je     L37
  mov    $0x0,%eax
  call   <getchar@plt>
  cmp    $0xa,%al
  jne    L115
  jmp    L37
L144:
  mov    $0x0,%eax
  call   <getchar@plt>
  movsbl %al,%edi
  call   <toupper@plt>
  cmp    $0x4d,%al
  jne    L127
L88:
  imul   $0x3c,(%rsp),%ebx
  add    0x4(%rsp),%ebx
  jmp    L115
L127:
  mov    $0x0,%eax
  call   <getchar@plt>
  cmp    $0xa,%al
  jne    L115
  jmp    L88
L141:
  mov    $0x268,%ebp
  mov    $0x1e0,%eax
  cmp    $0x213,%ebx
  jg     L23
L35:
  mov    $0x3c,%ecx
  cltd
  idiv   %ecx
  mov    %eax,%esi
  lea    D63(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  lea    D75(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x8,%edx
  mov    $0x10,%esi
  lea    D0(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  cmp    $0x2cf,%ebp
  jg     L17
  lea    D75(%rip),%rdi
  call   <puts@plt>
L65:
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L104
  mov    $0x0,%eax
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  ret
L23:
  cmp    $0x27c,%ebx
  jle    L45
  cmp    $0x2d7,%ebx
  jle    L196
  cmp    $0x323,%ebx
  mov    $0x2ff,%eax
  mov    $0x348,%edx
  cmovge %edx,%eax
  mov    $0x3c,%ecx
  cltd
  idiv   %ecx
  mov    %eax,%esi
  lea    D63(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  lea    D58(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x8,%edx
  mov    $0x10,%esi
  lea    D0(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L17:
  lea    D58(%rip),%rdi
  call   <puts@plt>
  jmp    L65
L45:
  mov    $0x2c8,%ebp
  mov    $0x249,%eax
  jmp    L35
L196:
  mov    $0x32b,%ebp
  mov    $0x2b1,%eax
  jmp    L35
L104:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: data_tag: D56
type_infered: string
name: retrieve_data
arguments: data_tag: D18
type_infered: string
name: retrieve_data
arguments: data_tag: D63
type_infered: string
name: retrieve_data
arguments: data_tag: D75
type_infered: string
name: retrieve_data
arguments: data_tag: D0
type_infered: string
name: retrieve_data
arguments: data_tag: D58
type_infered: string

tool: D56: Enter a 12-hour time: 

tool: D18: %d:%d

tool: D63: Closest departure time is %.2d:%.2d 

tool: D75: a.m.

tool: D0: , arriving at %.2d:%.2d 

tool: D58: p.m

assistant: ```c
int main(void) {
  int time_closest, a = 480, b = 585, c = 689, d = 767, e = 840;
  int time_arrival, a1 = 616, b1 = 712, c1 = 811, d1 = 900, e1 = 968;
  int hours, minutes, time, ch;
  printf("Enter a 12-hour time: ");
  scanf("%d:%d", &hours, &minutes);
  while (getchar() == ' ')
    ;
  while ((ch = getchar()) != '\n') {
    switch (toupper(ch)) {
    case 'P':
      if (toupper(getchar()) == 'M' || getchar() == '\n')
        time = 60 * hours + minutes + 12;
      break;
    case 'A':
      if (toupper(getchar()) == 'M' || getchar() == '\n')
        time = 60 * hours + minutes;
      break;
    default:
      break;
    }
  }
  if (time < a || time < (a + b) / 2) {
    time_closest = a;
    time_arrival = a1;
  } else if (time < (b + c) / 2) {
    time_closest = b;
    time_arrival = b1;
  } else if (time < (c + d) / 2) {
    time_closest = c;
    time_arrival = c1;
  } else if (time < (d + e) / 2) {
    time_closest = d;
    time_arrival = d1;
  } else {
    time_closest = e;
    time_arrival = e1;
  }
  printf("Closest departure time is %.2d:%.2d ", time_closest / 60, time_closest % 60);
  if (time_closest / 60 < 12)
    printf("a.m.");
  else
    printf("p.m");
  printf(", arriving at %.2d:%.2d ", e1 / 60, e1 % 60);
  if (time_arrival / 60 < 12)
    printf("a.m.\n");
  else
    printf("p.m\n");
  return 0;
}
```