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

```asm
<vga_mode>:
  endbr64
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  lea    0x8(%rsp),%rbp
  mov    %rbp,%rdi
  call   <FS460_get_vga_mode@plt>
  test   %eax,%eax
  jne    L53
  lea    0x10(%rsp),%rdi
  call   <FS460_get_available_vga_modes@plt>
  test   %eax,%eax
  jne    L54
  cmpq   $0x0,0x10(%rsp)
  jne    L185
L173:
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L36
  add    $0x28,%rsp
  pop    %rbp
  pop    %r12
  ret
  nopl   (%rax)
L53:
  mov    %eax,%esi
  lea    D42(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  jmp    L173
  nopw   0x0(%rax,%rax,1)
L185:
  lea    D77(%rip),%rsi
  mov    %r12,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L0
  mov    0x8(%rsp),%rdi
  mov    0x10(%rsp),%rdx
  nopw   0x0(%rax,%rax,1)
L23:
  add    %rdi,%rdi
  mov    $0x1,%eax
  cmove  %rax,%rdi
  test   %rdi,%rdx
  je     L23
L67:
  mov    %rdi,0x8(%rsp)
L76:
  call   <FS460_set_vga_mode@plt>
  mov    %eax,%esi
  test   %eax,%eax
  je     L129
  lea    D56(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  jmp    L173
  nopl   0x0(%rax)
L54:
  mov    %eax,%esi
  lea    D44(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  jmp    L173
  nopl   (%rax)
L129:
  mov    %rbp,%rdi
  call   <FS460_get_vga_mode@plt>
  mov    %eax,%esi
  test   %eax,%eax
  je     L61
  lea    D25(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  jmp    L173
  nopl   0x0(%rax)
L0:
  lea    D71(%rip),%rsi
  mov    %r12,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L16
  mov    0x8(%rsp),%rdi
  mov    0x10(%rsp),%rdx
  mov    $0x80000000,%eax
  nopl   0x0(%rax,%rax,1)
L40:
  shr    %rdi
  cmove  %rax,%rdi
  test   %rdi,%rdx
  je     L40
  jmp    L67
  nopl   0x0(%rax)
L61:
  mov    0x8(%rsp),%rdi
  call   <str_VgaMode@plt>
  lea    D70(%rip),%rdi
  mov    %rax,%rsi
  xor    %eax,%eax
  call   <printf@plt>
  jmp    L173
L16:
  lea    D55(%rip),%rsi
  mov    %r12,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L116
  mov    0x8(%rsp),%rdi
  jmp    L76
L116:
  lea    D32(%rip),%rdi
  call   <puts@plt>
  jmp    L173
L36:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: label: D42
datatype: string
name: retrieve_data
arguments: label: D77
datatype: string
name: retrieve_data
arguments: label: D56
datatype: string
name: retrieve_data
arguments: label: D44
datatype: string
name: retrieve_data
arguments: label: D25
datatype: string
name: retrieve_data
arguments: label: D71
datatype: string
name: retrieve_data
arguments: label: D70
datatype: string
name: retrieve_data
arguments: label: D55
datatype: string
name: retrieve_data
arguments: label: D32
datatype: string

tool: D42: error %u getting vga mode.


tool: D77: +

tool: D56: error %u setting vga mode.


tool: D44: error %u getting available vga modes.


tool: D25: error %u getting vga mode after set.


tool: D71: -

tool: D70:   vga mode=%s


tool: 

tool: D32: Invalid command.

assistant: ```c
void vga_mode(char *mod) {
  int err;
  unsigned long vga_mode, available_vga_modes;
  err = FS460_get_vga_mode(&vga_mode);
  if (err) {
    printf("error %u getting vga mode.\n", err);
    return;
  }
  err = FS460_get_available_vga_modes(&available_vga_modes);
  if (err) {
    printf("error %u getting available vga modes.\n", err);
    return;
  }
  if (available_vga_modes) {
    if (0 == strcmp(mod, "+")) {
      do {
        vga_mode <<= 1;
        if (!vga_mode)
          vga_mode = 1;
      } while (!(vga_mode & available_vga_modes));
    } else if (0 == strcmp(mod, "-")) {
      do {
        vga_mode >>= 1;
        if (!vga_mode)
          vga_mode = 0x80000000;
      } while (!(vga_mode & available_vga_modes));
    } else if (0 == strcmp(mod, "")) {
    } else {
      printf("Invalid command.\n");
      return;
    }
    err = FS460_set_vga_mode(vga_mode);
    if (err)
      printf("error %u setting vga mode.\n", err);
    else {
      err = FS460_get_vga_mode(&vga_mode);
      if (err)
        printf("error %u getting vga mode after set.\n", err);
      else
        printf("  vga mode=%s\n", str_VgaMode(vga_mode));
    }
  }
}
```