user: Translate the below assembly code into C programming language:

```asm
<doUpgrade>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  test   %esi,%esi
  jne    L61
  xor    %eax,%eax
  call   <getDbVersion@plt>
  mov    %eax,%r12d
L11:
  mov    %r12d,%edx
  lea    D35(%rip),%rsi
  xor    %eax,%eax
  xor    %r13d,%r13d
  mov    $0x2,%edi
  call   <logMsg@plt>
L5:
  mov    %r13d,%eax
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  nopl   0x0(%rax,%rax,1)
L61:
  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     L11
  cmp    %eax,%r14d
  jl     L54
  je     L74
  cmp    $0x7,%r14d
  jle    L13
  mov    %r14d,%edx
  xor    %r13d,%r13d
  mov    $0x7,%ecx
  mov    $0x2,%edi
  lea    D28(%rip),%rsi
  xor    %eax,%eax
  call   <logMsg@plt>
  mov    %r13d,%eax
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  nopl   0x0(%rax)
L54:
  mov    %eax,%ecx
  mov    %r14d,%edx
  xor    %r13d,%r13d
  mov    $0x2,%edi
  lea    D36(%rip),%rsi
  xor    %eax,%eax
  call   <logMsg@plt>
  mov    %r13d,%eax
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  nopl   (%rax)
L13:
  xor    %edi,%edi
  cmp    %eax,%r14d
  setg   %dil
  add    $0x1,%r14d
  call   <assert@plt>
  lea    0x1(%r12),%edi
  jmp    L55
  nopl   0x0(%rax)
L8:
  lea    0x1(%rdi),%r12d
  call   <upgradeTo@plt>
  mov    %eax,%r13d
  test   %eax,%eax
  je     L5
  mov    %r12d,%edi
L55:
  cmp    %r14d,%edi
  jne    L8
  mov    %r13d,%eax
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  xchg   %ax,%ax
L74:
  mov    %r14d,%edx
  xor    %r13d,%r13d
  lea    D17(%rip),%rsi
  xor    %eax,%eax
  mov    $0x2,%edi
  call   <logMsg@plt>
  mov    %r13d,%eax
  pop    %r12
  pop    %r13
  pop    %r14
  ret
```

tool_calls: name: disassemble_data
arguments: data_tag: D35
type_guessed: string
name: disassemble_data
arguments: data_tag: D28
type_guessed: string
name: disassemble_data
arguments: data_tag: D36
type_guessed: string
name: disassemble_data
arguments: data_tag: D17
type_guessed: string

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

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

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

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