user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<sqlite_swap>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %rdi,%rbp
  mov    %rsi,%r12
  mov    %rdx,%rcx
  mov    %rdx,0x18(%rsp)
  mov    %rsi,%rdx
  lea    D9(%rip),%rsi
  mov    $0x3,%edi
  mov    $0x0,%eax
  call   <logprintf@plt>
  lea    D67(%rip),%rsi
  mov    %rbp,%rdi
  call   <database_prepare@plt>
  mov    %rax,%rbx
  lea    D4(%rip),%rsi
  mov    %rbp,%rdi
  call   <database_prepare@plt>
  test   %rbx,%rbx
  je     L137
  mov    %rax,%r13
  test   %rax,%rax
  je     L137
  mov    %r12,%rdx
  mov    $0x1,%esi
  mov    %rbx,%rdi
  call   <sqlite3_bind_int@plt>
  test   %rax,%rax
  jne    L137
  mov    %rbx,%rdi
  call   <sqlite3_step@plt>
  cmp    $0x80,%eax
  je     L174
  cmp    $0x82,%eax
  je     L0
  mov    %rbp,%rdi
  call   <sqlite3_errmsg@plt>
  mov    %rax,%rdx
  lea    D3(%rip),%rsi
  mov    $0x0,%edi
  mov    $0x0,%eax
  call   <logprintf@plt>
  movq   $0x0,0x10(%rsp)
  mov    $0x0,%r15d
  mov    $0x0,%r14d
L112:
  mov    %rbx,%rdi
  call   <sqlite3_finalize@plt>
  mov    $0x0,%r8d
  mov    $0x0,%ecx
  mov    $0x0,%edx
  lea    D26(%rip),%rsi
  mov    %rbp,%rdi
  call   <sqlite3_exec@plt>
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <sqlite_delete_address@plt>
  movl   $0x15,0xc(%rsp)
  test   %rax,%rax
  je     L63
L191:
  mov    %r13,%rdi
  call   <sqlite3_step@plt>
  sub    $0x81,%eax
  cmp    $0x1,%eax
  ja     L81
L110:
  mov    $0x0,%r8d
  mov    $0x0,%ecx
  mov    $0x0,%edx
  lea    D21(%rip),%rsi
  mov    %rbp,%rdi
  call   <sqlite3_exec@plt>
  jmp    L232
L137:
  lea    D41(%rip),%rsi
  mov    $0x0,%edi
  mov    $0x0,%eax
  call   <logprintf@plt>
  movl   $0xffffffff,0xc(%rsp)
  jmp    L194
L174:
  mov    $0x0,%esi
  mov    %rbx,%rdi
  call   <sqlite3_column_text@plt>
  mov    %rax,%rdi
  call   <common_strdup@plt>
  mov    %rax,%r14
  mov    $0x1,%esi
  mov    %rbx,%rdi
  call   <sqlite3_column_text@plt>
  mov    %rax,%rdi
  call   <common_strdup@plt>
  mov    %rax,%r15
  mov    $0x2,%esi
  mov    %rbx,%rdi
  call   <sqlite3_column_text@plt>
  movq   $0x0,0x10(%rsp)
  test   %rax,%rax
  jne    L159
L29:
  test   %r14,%r14
  je     L141
  test   %r15,%r15
  jne    L112
L141:
  movl   $0x13,0xc(%rsp)
  jmp    L20
L159:
  mov    $0x2,%esi
  mov    %rbx,%rdi
  call   <sqlite3_column_text@plt>
  mov    %rax,%rdi
  call   <common_strdup@plt>
  mov    %rax,0x10(%rsp)
  jmp    L29
L0:
  mov    %r12,%rdx
  lea    D76(%rip),%rsi
  mov    $0x0,%edi
  mov    $0x0,%eax
  call   <logprintf@plt>
  movq   $0x0,0x10(%rsp)
  mov    $0x0,%r15d
  mov    $0x0,%r14d
  movl   $0x14,0xc(%rsp)
L20:
  mov    %rbx,%rdi
  call   <sqlite3_finalize@plt>
L232:
  mov    %r13,%rdi
  call   <sqlite3_finalize@plt>
  test   %r14,%r14
  je     L21
  mov    %r14,%rdi
  call   <free@plt>
L21:
  test   %r15,%r15
  je     L118
  mov    %r15,%rdi
  call   <free@plt>
L118:
  mov    0x10(%rsp),%rax
  test   %rax,%rax
  je     L194
  mov    %rax,%rdi
  call   <free@plt>
L194:
  mov    0xc(%rsp),%eax
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L63:
  mov    %r12,%rdx
  mov    $0x1,%esi
  mov    %r13,%rdi
  call   <sqlite3_bind_int@plt>
  movl   $0x16,0xc(%rsp)
  cmp    $0x81,%rax
  jne    L191
  mov    0x18(%rsp),%rdx
  mov    $0x2,%esi
  mov    %r13,%rdi
  call   <sqlite3_bind_int@plt>
  cmp    $0x81,%rax
  je     L49
  movl   $0x16,0xc(%rsp)
  jmp    L191
L81:
  mov    %rbp,%rdi
  call   <sqlite3_errmsg@plt>
  mov    %rax,%rdx
  lea    D42(%rip),%rsi
  mov    $0x0,%edi
  mov    $0x0,%eax
  call   <logprintf@plt>
  movl   $0x17,0xc(%rsp)
  jmp    L110
L182:
  mov    $0x0,%r8d
  mov    $0x0,%ecx
  mov    $0x0,%edx
  lea    D94(%rip),%rsi
  mov    %rbp,%rdi
  call   <sqlite3_exec@plt>
  movl   $0x0,0xc(%rsp)
  jmp    L232
L49:
  mov    %r13,%rdi
  call   <sqlite3_step@plt>
  sub    $0x81,%eax
  cmp    $0x1,%eax
  ja     L81
  mov    0x10(%rsp),%r8
  mov    %r15,%rcx
  mov    0x18(%rsp),%rdx
  mov    %r14,%rsi
  mov    %rbp,%rdi
  call   <sqlite_add_address_order@plt>
  test   %rax,%rax
  je     L182
  movl   $0x18,0xc(%rsp)
  jmp    L110
```

tool_calls: name: retrieve_data
arguments: data_tag: D9
type: string
name: retrieve_data
arguments: data_tag: D67
type: string
name: retrieve_data
arguments: data_tag: D4
type: string
name: retrieve_data
arguments: data_tag: D3
type: string
name: retrieve_data
arguments: data_tag: D26
type: string
name: retrieve_data
arguments: data_tag: D21
type: string
name: retrieve_data
arguments: data_tag: D41
type: string
name: retrieve_data
arguments: data_tag: D76
type: string
name: retrieve_data
arguments: data_tag: D42
type: string
name: retrieve_data
arguments: data_tag: D94
type: string

tool: D9: order1: %d, order2: %d


tool: D67: SELECT address_expression, address_router, address_route FROM addresses WHERE address_order = ?;

tool: D4: UPDATE addresses SET address_order = ? WHERE address_order = ?;

tool: D3: Unhandled failure: %s


tool: D26: BEGIN TRANSACTION

tool: D21: ROLLBACK

tool: D41: Failed to prepare or bind statement


tool: D76: No expression with order %d


tool: D42: Failed to update address record: %s


tool: D94: COMMIT

assistant: ```c
int sqlite_swap(sqlite3 *db, long first, long second) {
  int status = 0;
  char *expression = NULL;
  char *router = NULL;
  char *route = NULL;
  logprintf(3, "order1: %d, order2: %d\n", first, second);
  sqlite3_stmt *fetch = database_prepare(db, "SELECT address_expression, address_router, address_route FROM addresses WHERE address_order = ?;");
  sqlite3_stmt *update = database_prepare(db, "UPDATE addresses SET address_order = ? WHERE address_order = ?;");
  if (!fetch || !update || sqlite3_bind_int(fetch, 1, first)) {
    logprintf(0, "Failed to prepare or bind statement\n");
    return -1;
  }
  switch (sqlite3_step(fetch)) {
  case SQLITE_ROW:
    expression = common_strdup((char *)sqlite3_column_text(fetch, 0));
    router = common_strdup((char *)sqlite3_column_text(fetch, 1));
    if (sqlite3_column_text(fetch, 2)) {
      route = common_strdup((char *)sqlite3_column_text(fetch, 2));
    }
    if (!expression || !router) {
      status = 19;
    }
    break;
  case SQLITE_DONE:
    logprintf(0, "No expression with order %d\n", first);
    status = 20;
    break;
  default:
    logprintf(0, "Unhandled failure: %s\n", sqlite3_errmsg(db));
    break;
  }
  sqlite3_finalize(fetch);
  if (!status) {
    sqlite3_exec(db, "BEGIN TRANSACTION", NULL, NULL, NULL);
    if (sqlite_delete_address(db, first) != 0) {
      status = 21;
    }
    if (!status && (sqlite3_bind_int(update, 1, first) != SQLITE_OK || sqlite3_bind_int(update, 2, second) != SQLITE_OK)) {
      status = 22;
    }
    switch (sqlite3_step(update)) {
    case SQLITE_DONE:
    case SQLITE_OK:
      break;
    default:
      logprintf(0, "Failed to update address record: %s\n", sqlite3_errmsg(db));
      status = 23;
      break;
    }
    if (!status && sqlite_add_address_order(db, expression, second, router, route) != 0) {
      status = 24;
    }
    if (status) {
      sqlite3_exec(db, "ROLLBACK", NULL, NULL, NULL);
    } else {
      sqlite3_exec(db, "COMMIT", NULL, NULL, NULL);
    }
  }
  sqlite3_finalize(update);
  if (expression) {
    free(expression);
  }
  if (router) {
    free(router);
  }
  if (route) {
    free(route);
  }
  return status;
}
```