user: 请将以下的汇编代码转换成C语言代码:

```asm
<doUpgrade>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  test   %esi,%esi
  jne    L11
  xor    %eax,%eax
  call   <getDbVersion@plt>
  mov    %eax,%r12d
L28:
  mov    %r12d,%edx
  lea    D17(%rip),%rsi
  xor    %eax,%eax
  xor    %r13d,%r13d
  mov    $0x2,%edi
  call   <logMsg@plt>
L3:
  mov    %r13d,%eax
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  nopl   0x0(%rax,%rax,1)
L11:
  mov    (%rdx),%rdi
  mov    $0xffffffff,%esi
  call   <strToInt@plt>
  mov    %eax,%r14d
  xor    %eax,%eax
  call   <getDbVersion@plt>
  mov    %eax,%r12d
  cmp    $0xffffffff,%r14d
  je     L28
  cmp    %eax,%r14d
  jl     L36
  je     L55
  cmp    $0x7,%r14d
  jle    L29
  mov    %r14d,%edx
  xor    %r13d,%r13d
  mov    $0x7,%ecx
  mov    $0x2,%edi
  lea    D1(%rip),%rsi
  xor    %eax,%eax
  call   <logMsg@plt>
  mov    %r13d,%eax
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  nopl   0x0(%rax)
L36:
  mov    %eax,%ecx
  mov    %r14d,%edx
  xor    %r13d,%r13d
  mov    $0x2,%edi
  lea    D21(%rip),%rsi
  xor    %eax,%eax
  call   <logMsg@plt>
  mov    %r13d,%eax
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  nopl   (%rax)
L29:
  xor    %edi,%edi
  cmp    %eax,%r14d
  setg   %dil
  add    $0x1,%r14d
  call   <assert@plt>
  lea    0x1(%r12),%edi
  jmp    L73
  nopl   0x0(%rax)
L77:
  lea    0x1(%rdi),%r12d
  call   <upgradeTo@plt>
  mov    %eax,%r13d
  test   %eax,%eax
  je     L3
  mov    %r12d,%edi
L73:
  cmp    %r14d,%edi
  jne    L77
  mov    %r13d,%eax
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  xchg   %ax,%ax
L55:
  mov    %r14d,%edx
  xor    %r13d,%r13d
  lea    D2(%rip),%rsi
  xor    %eax,%eax
  mov    $0x2,%edi
  call   <logMsg@plt>
  mov    %r13d,%eax
  pop    %r12
  pop    %r13
  pop    %r14
  ret
```

tool_calls: name: read_data
arguments: data_label: D17
type_guessed: string
name: read_data
arguments: data_label: D1
type_guessed: string
name: read_data
arguments: data_label: D21
type_guessed: string
name: read_data
arguments: data_label: D2
type_guessed: string

tool: D17: Please specify a valid database level for the upgrade, the database is currently at level %d.

tool: D1: Cannot upgrade database to level %d, the maximum available upgrade level is %d.

tool: D21: Cannot upgrade database to level %d, the database is already at level %d.

tool: D2: Database is already at level %d, nothing to do.

assistant: ```c
int doUpgrade(FILE *file, int argc, char **argv) {
  int requestLevel;
  if (argc == 0) {
    requestLevel = -1;
  } else {
    requestLevel = strToInt(argv[0], -1);
  }
  int status;
  int currentLevel = getDbVersion();
  if (requestLevel == -1) {
    logMsg(2, "Please specify a valid database level for the upgrade, the database is currently at level %d.", currentLevel);
    status = 0;
  } else if (requestLevel < currentLevel) {
    logMsg(2, "Cannot upgrade database to level %d, the database is already at level %d.", requestLevel, currentLevel);
    status = 0;
  } else if (requestLevel == currentLevel) {
    logMsg(2, "Database is already at level %d, nothing to do.", requestLevel);
    status = 0;
  } else if (requestLevel > 7) {
    logMsg(2, "Cannot upgrade database to level %d, the maximum available upgrade level is %d.", requestLevel, 7);
    status = 0;
  } else {
    assert(currentLevel < requestLevel);
    int level = currentLevel + 1;
    while (level <= requestLevel) {
      status = upgradeTo(level++);
      if (status == 0) {
        break;
      }
    }
  }
  return status;
}
```