user: Please show me the C implementation that matches the assembly code listed below:

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x4d8,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x4c8(%rsp)
  xor    %eax,%eax
  lea    0xc(%rsp),%rsi
  lea    D57(%rip),%rdi
  call   <scanf@plt>
  cmpl   $0x0,0xc(%rsp)
  jle    L236
  mov    $0x0,%ebx
  mov    $0x0,%r12d
  lea    D38(%rip),%r13
L40:
  lea    0x1a0(%rsp),%rbp
  lea    0x330(%rsp,%rbx,1),%rcx
  lea    0x0(%rbp,%rbx,1),%rdx
  lea    0x10(%rsp,%rbx,1),%rsi
  mov    %r13,%rdi
  mov    $0x0,%eax
  call   <scanf@plt>
  add    $0x1,%r12d
  mov    0xc(%rsp),%eax
  add    $0x4,%rbx
  cmp    %r12d,%eax
  jg     L40
  test   %eax,%eax
  jle    L236
  mov    $0x0,%ebx
  lea    D28(%rip),%r14
  lea    D56(%rip),%r15
  jmp    L216
L295:
  mov    %r15,%rdi
  call   <puts@plt>
  jmp    L259
L157:
  test   %r12d,%r12d
  je     L101
  cmp    %edi,%r12d
  jne    L244
L164:
  mov    %r14,%rdi
  call   <puts@plt>
L259:
  add    $0x1,%rbx
  add    $0x4,%rbp
  cmp    %ebx,0xc(%rsp)
  jle    L236
L216:
  mov    0x330(%rsp,%rbx,4),%r12d
  mov    0x10(%rsp,%rbx,4),%edi
  cmp    %edi,%r12d
  jle    L157
  cmp    0x0(%rbp),%r12d
  jg     L295
  test   %r12d,%r12d
  je     L101
L244:
  mov    %rbp,%r13
  mov    0x0(%rbp),%esi
  cmp    %esi,%r12d
  je     L164
  call   <gcd@plt>
  mov    %eax,%ecx
  mov    %r12d,%eax
  cltd
  idiv   %ecx
  test   %edx,%edx
  jne    L174
  mov    0x330(%rsp,%rbx,4),%ecx
  mov    %edx,%r8d
  mov    %edx,%eax
  mov    $0x1,%edi
  mov    %ecx,%esi
  mov    %ecx,%r9d
  test   %ecx,%ecx
  jne    L135
L143:
  cmp    %r9d,%esi
  cmovg  %r9d,%esi
  lea    D9(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L259
L101:
  lea    D4(%rip),%rdi
  call   <puts@plt>
  jmp    L259
L174:
  mov    %r15,%rdi
  call   <puts@plt>
  jmp    L259
L208:
  mov    0x0(%r13),%esi
  cmp    %r8d,%esi
  je     L100
  add    %r8d,%eax
  cmp    %eax,%esi
  cmovg  %eax,%esi
  mov    %esi,%r8d
  sub    %esi,%eax
  mov    %edi,%esi
L185:
  add    $0x1,%edi
  cmp    %ecx,%r8d
  je     L218
  cmp    %ecx,%eax
  je     L218
L135:
  test   %eax,%eax
  jne    L208
  mov    0x10(%rsp,%rbx,4),%eax
  mov    %edi,%esi
  jmp    L185
L100:
  mov    %edi,%esi
  mov    %edx,%r8d
  jmp    L185
L218:
  mov    %edx,%eax
  mov    %edx,%r8d
  mov    $0x1,%edi
  jmp    L148
L39:
  mov    0x10(%rsp,%rbx,4),%r9d
  cmp    %r8d,%r9d
  je     L162
  add    %r8d,%eax
  cmp    %eax,%r9d
  cmovg  %eax,%r9d
  mov    %r9d,%r8d
  sub    %r9d,%eax
  mov    %edi,%r9d
L10:
  add    $0x1,%edi
  cmp    %ecx,%eax
  je     L143
  cmp    %ecx,%r8d
  je     L143
L148:
  test   %eax,%eax
  jne    L39
  mov    0x0(%r13),%eax
  mov    %edi,%r9d
  jmp    L10
L162:
  mov    %edi,%r9d
  mov    %edx,%r8d
  jmp    L10
L236:
  mov    0x4c8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L309
  mov    $0x0,%eax
  add    $0x4d8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L309:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: tag: D57
datatype: string
name: parse_data
arguments: tag: D38
datatype: string
name: parse_data
arguments: tag: D28
datatype: string
name: parse_data
arguments: tag: D56
datatype: string
name: parse_data
arguments: tag: D9
datatype: string
name: parse_data
arguments: tag: D4
datatype: string

tool: D57: %d

tool: D38: %d %d %d

tool: D28: 1

tool: D56: -1

tool: D9: %d


tool: D4: 0

assistant: ```c
int main(void) {
  int t, i, min, max, steps, moves, moves1, ca, cb, sum;
  int a[100], b[100], c[100];
  scanf("%d", &t);
  for (i = 0; i < t; i++)
    scanf("%d %d %d", &a[i], &b[i], &c[i]);
  for (i = 0; i < t; i++) {
    if (c[i] > a[i] && c[i] > b[i]) {
      printf("-1\n");
      continue;
    } else if (c[i] == 0) {
      printf("0\n");
      continue;
    } else if (c[i] == a[i] || c[i] == b[i]) {
      printf("1\n");
      continue;
    } else if (c[i] % gcd(a[i], b[i]) != 0) {
      printf("-1\n");
      continue;
    } else {
      moves = 0;
      moves1 = 0;
      ca = 0;
      cb = 0;
      while (ca != c[i] && cb != c[i]) {
        if (ca == 0) {
          ca = a[i];
          moves++;
        } else if (cb == b[i]) {
          cb = 0;
          moves++;
        } else {
          sum = ca + cb;
          cb = (((sum) < (b[i])) ? (sum) : (b[i]));
          ca = sum - cb;
          moves++;
        }
      }
      ca = 0;
      cb = 0;
      while (ca != c[i] && cb != c[i]) {
        if (cb == 0) {
          cb = b[i];
          moves1++;
        } else if (ca == a[i]) {
          ca = 0;
          moves1++;
        } else {
          sum = ca + cb;
          ca = (((sum) < (a[i])) ? (sum) : (a[i]));
          cb = sum - ca;
          moves1++;
        }
      }
      printf("%d\n", (((moves) < (moves1)) ? (moves) : (moves1)));
    }
  }
  return (0);
}
```