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    L42
  lea    0x10(%rsp),%rdi
  call   <FS460_get_available_vga_modes@plt>
  test   %eax,%eax
  jne    L142
  cmpq   $0x0,0x10(%rsp)
  jne    L114
L20:
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L190
  add    $0x28,%rsp
  pop    %rbp
  pop    %r12
  ret
  nopl   (%rax)
L42:
  mov    %eax,%esi
  lea    D5(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  jmp    L20
  nopw   0x0(%rax,%rax,1)
L114:
  lea    D62(%rip),%rsi
  mov    %r12,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L235
  mov    0x8(%rsp),%rdi
  mov    0x10(%rsp),%rax
  nopw   0x0(%rax,%rax,1)
L177:
  add    %rdi,%rdi
  je     L174
  test   %rdi,%rax
  je     L177
L11:
  mov    %rdi,0x8(%rsp)
L58:
  call   <FS460_set_vga_mode@plt>
  mov    %eax,%esi
  test   %eax,%eax
  je     L136
  lea    D60(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  jmp    L20
  nopl   (%rax)
L174:
  mov    %rax,%rdi
  and    $0x1,%edi
  jne    L11
  mov    $0x1,%edi
  jmp    L177
  nopw   0x0(%rax,%rax,1)
L142:
  mov    %eax,%esi
  lea    D68(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  jmp    L20
  nopl   (%rax)
L136:
  mov    %rbp,%rdi
  call   <FS460_get_vga_mode@plt>
  mov    %eax,%esi
  test   %eax,%eax
  je     L144
  lea    D15(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  jmp    L20
  nopl   0x0(%rax)
L235:
  lea    D88(%rip),%rsi
  mov    %r12,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L18
  mov    0x10(%rsp),%rax
  mov    0x8(%rsp),%rdi
  mov    %rax,%rdx
  and    $0x80000000,%edx
  nopw   0x0(%rax,%rax,1)
L234:
  shr    %rdi
  je     L32
L249:
  test   %rdi,%rax
  jne    L11
  shr    %rdi
  jne    L249
L32:
  mov    $0x80000000,%edi
  test   %rdx,%rdx
  je     L234
  jmp    L11
  nopw   0x0(%rax,%rax,1)
L144:
  mov    0x8(%rsp),%rdi
  call   <str_VgaMode@plt>
  lea    D30(%rip),%rdi
  mov    %rax,%rsi
  xor    %eax,%eax
  call   <printf@plt>
  jmp    L20
  nopl   0x0(%rax,%rax,1)
L18:
  lea    D56(%rip),%rsi
  mov    %r12,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L179
  mov    0x8(%rsp),%rdi
  jmp    L58
L179:
  lea    D64(%rip),%rdi
  call   <puts@plt>
  jmp    L20
L190:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: label: D5
datatype: string
name: parse_data
arguments: label: D62
datatype: string
name: parse_data
arguments: label: D60
datatype: string
name: parse_data
arguments: label: D68
datatype: string
name: parse_data
arguments: label: D15
datatype: string
name: parse_data
arguments: label: D88
datatype: string
name: parse_data
arguments: label: D30
datatype: string
name: parse_data
arguments: label: D56
datatype: string
name: parse_data
arguments: label: D64
datatype: string

tool: D5: error %u getting vga mode.


tool: D62: +

tool: D60: error %u setting vga mode.


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


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


tool: D88: -

tool: D30:   vga mode=%s


tool: 

tool: D64: 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));
    }
  }
}
```