user: Please show me the C implementation that matches the assembly code listed below:

```asm
<write_pass_one>:
  endbr64
  push   %r14
  mov    %rdi,%r14
  push   %r13
  mov    %rdx,%r13
  push   %r12
  mov    %ecx,%r12d
  push   %rbp
  mov    %rsi,%rbp
  lea    D111(%rip),%rsi
  mov    %rbp,%rdi
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L20
  cmp    $0x2,%r12d
  je     L6
L18:
  xor    %eax,%eax
L37:
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L26
  add    $0x18,%rsp
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  nopl   0x0(%rax,%rax,1)
L6:
  mov    0x8(%r13),%rsi
  mov    %rsp,%rdi
  mov    $0xffffffff,%ecx
  mov    $0x80000000,%edx
  call   <translate_num@plt>
  cmp    $0xffffffff,%eax
  je     L18
  mov    (%rsp),%r9
  mov    0x0(%r13),%rcx
  cmp    $0xffff,%r9
  jbe    L81
  lea    0x8000(%r9),%rax
  cmp    $0xffff,%rax
  ja     L73
L81:
  lea    D44(%rip),%r8
  lea    D1(%rip),%rdx
L101:
  lea    D15(%rip),%rsi
  mov    %r14,%rdi
  xor    %eax,%eax
  call   <fprintf@plt>
  mov    $0x2,%eax
  jmp    L37
  nopl   0x0(%rax,%rax,1)
L20:
  lea    D8(%rip),%rsi
  mov    %rbp,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L36
  cmp    $0x3,%r12d
  jne    L37
  mov    0x8(%r13),%r9
  mov    0x0(%r13),%r8
  lea    D4(%rip),%r12
  lea    D124(%rip),%rbp
  mov    %r12,%rcx
  lea    D78(%rip),%rdx
  mov    %rbp,%rsi
  mov    %r14,%rdi
  call   <fprintf@plt>
  mov    0x10(%r13),%r9
  mov    %r12,%rcx
  mov    %rbp,%rsi
  lea    D44(%rip),%r8
  lea    D60(%rip),%rdx
  mov    %r14,%rdi
  xor    %eax,%eax
  call   <fprintf@plt>
  mov    $0x2,%eax
  jmp    L37
  nopl   (%rax)
L36:
  mov    %r12d,%ecx
  mov    %r13,%rdx
  mov    %rbp,%rsi
  mov    %r14,%rdi
  call   <write_inst_string@plt>
  mov    $0x1,%eax
  jmp    L37
  nopl   0x0(%rax,%rax,1)
L73:
  mov    %r9,%r8
  lea    D129(%rip),%rdx
  mov    %r14,%rdi
  xor    %eax,%eax
  sar    $0x10,%r8
  lea    D22(%rip),%rsi
  call   <fprintf@plt>
  mov    0x0(%r13),%rcx
  movzwl (%rsp),%r9d
  lea    D90(%rip),%rdx
  mov    %rcx,%r8
  jmp    L101
L26:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: label: D111
data_type: string
name: unpack_data
arguments: label: D44
data_type: string
name: unpack_data
arguments: label: D1
data_type: string
name: unpack_data
arguments: label: D15
data_type: string
name: unpack_data
arguments: label: D8
data_type: string
name: unpack_data
arguments: label: D4
data_type: string
name: unpack_data
arguments: label: D124
data_type: string
name: unpack_data
arguments: label: D78
data_type: string
name: unpack_data
arguments: label: D60
data_type: string
name: unpack_data
arguments: label: D129
data_type: string
name: unpack_data
arguments: label: D22
data_type: string
name: unpack_data
arguments: label: D90
data_type: string

tool: D111: li

tool: D44: $zero

tool: D1: addiu

tool: D15: %s %s %s %ld


tool: D8: blt

tool: D4: $at

tool: D124: %s %s %s %s


tool: D78: slt

tool: D60: bne

tool: D129: lui

tool: D22: %s %s %ld


tool: D90: ori

assistant: ```c
unsigned write_pass_one(FILE *output, const char *name, char **args, int num_args) {
  if (strcmp(name, "li") == 0) {
    if (num_args != 2) {
      return 0;
    }
    long int immediate;
    int result = translate_num(&immediate, args[1], -2147483648, 4294967295);
    if (result == -1)
      return 0;
    if ((immediate <= 65535 && immediate >= 0) || (immediate >= -32768 && immediate <= 32767)) {
      char *instr = "addiu";
      char *zero_reg = "$zero";
      fprintf(output, "%s %s %s %ld\n", instr, args[0], zero_reg, immediate);
    } else {
      char *loadUpper = "lui";
      char *loadLower = "ori";
      long int topBits = immediate >> 16;
      fprintf(output, "%s %s %ld\n", loadUpper, args[0], topBits);
      long int lowBits = immediate & 0xffff;
      fprintf(output, "%s %s %s %ld\n", loadLower, args[0], args[0], lowBits);
    }
    return 2;
  } else if (strcmp(name, "blt") == 0) {
    if (num_args != 3) {
      return 0;
    }
    fprintf(output, "%s %s %s %s\n", "slt", "$at", args[0], args[1]);
    fprintf(output, "%s %s %s %s\n", "bne", "$at", "$zero", args[2]);
    return 2;
  } else {
    write_inst_string(output, name, args, num_args);
    return 1;
  }
}
```