user: Converte this assembly snippet into its equivalent C code:

```asm
<f_set_int2>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    0x70(%rsp),%rax
  mov    0x78(%rsp),%rbp
  mov    0x80(%rsp),%rbx
  mov    %rax,0x18(%rsp)
  mov    %rax,%rcx
  mov    %fs:0x28,%rax
  mov    %rax,0x28(%rsp)
  xor    %eax,%eax
  test   %edi,%edi
  js     L76
  mov    %rcx,%rdi
  mov    %rsi,%r15
  call   <atoi@plt>
  mov    %rbp,%rdi
  movslq %eax,%r12
  call   <atoi@plt>
  mov    %eax,0x8(%rsp)
  cmp    $0x8,%r12d
  ja     L121
  mov    0x8(%rsp),%eax
  test   %eax,%eax
  jle    L15
L100:
  movl   $0x10,0xc(%rsp)
  test   %r12d,%r12d
  jne    L110
L115:
  lea    0x20(%rsp),%r13
  lea    0x24(%rsp),%r14
  mov    %rbx,%rdi
  mov    %r13,%rcx
  mov    %r14,%rdx
  lea    D39(%rip),%rsi
  call   <sscanf@plt>
  cmp    $0x1,%eax
  jne    L76
  lea    (%r15,%r12,8),%rax
  movslq 0x8(%rsp),%r12
  lea    D1(%rip),%r15
  mov    %rax,0x10(%rsp)
  sub    $0x1,%r12
  mov    %r12,%rbp
  jmp    L42
  nopl   0x0(%rax,%rax,1)
L146:
  mov    0x10(%rsp),%rax
  mov    0x24(%rsp),%edi
  mov    (%rax),%rsi
  add    %rbp,%rsi
  add    $0x2,%rbp
  call   <int2_char@plt>
  movslq 0x20(%rsp),%rax
  mov    %r13,%rcx
  mov    %r14,%rdx
  mov    %r15,%rsi
  add    %rax,%rbx
  mov    %rbx,%rdi
  call   <sscanf@plt>
  cmp    $0x1,%eax
  jne    L76
L42:
  mov    0x8(%rsp),%eax
  sub    %r12d,%eax
  add    %ebp,%eax
  cmp    %eax,0xc(%rsp)
  jg     L146
  mov    0x18(%rsp),%rsi
  lea    D9(%rip),%rdi
  call   <fatal_error@plt>
  jmp    L146
  nopl   0x0(%rax,%rax,1)
L76:
  mov    0x28(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L97
  add    $0x38,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L121:
  mov    0x18(%rsp),%rsi
  lea    D55(%rip),%rdi
  call   <fatal_error@plt>
  mov    0x8(%rsp),%edx
  test   %edx,%edx
  jle    L15
L35:
  movslq %r12d,%rax
  mov    (%r15,%rax,8),%rdi
  call   <uint4@plt>
  mov    %eax,0xc(%rsp)
  jmp    L115
  cs nopw 0x0(%rax,%rax,1)
L110:
  cmp    $0x8,%r12d
  jne    L35
  movl   $0x4,0xc(%rsp)
  jmp    L115
  nopl   0x0(%rax,%rax,1)
L15:
  lea    D54(%rip),%rsi
  lea    D46(%rip),%rdi
  call   <fatal_error@plt>
  jmp    L100
L97:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: label: D39
type: string
name: disassemble_data
arguments: label: D1
type: string
name: disassemble_data
arguments: label: D9
type: string
name: disassemble_data
arguments: label: D55
type: string
name: disassemble_data
arguments: label: D54
type: string
name: disassemble_data
arguments: label: D46
type: string

tool: D39: %d%n

tool: D1: :%d%n

tool: D9: set_int2 out of bounds section %s

tool: D55: set_int2: bad section number %s

tool: 

tool: D46: set_int2: octet number must >= 1

assistant: ```c
int f_set_int2(int mode, unsigned char **sec, float *data, unsigned int ndata, char *inv_out, void **local, const char *arg1, const char *arg2, const char *arg3) {
  int i, j, k, m, val, seclen;
  if (mode < 0)
    return 0;
  i = atoi(arg1);
  j = atoi(arg2);
  if (i < 0 || i > 8)
    fatal_error("set_int2: bad section number %s", arg1);
  if (j <= 0)
    fatal_error("set_int2: octet number must >= 1", "");
  if (i == 0)
    seclen = 16;
  else if (i == 8)
    seclen = 4;
  else
    seclen = uint4(sec[i]);
  k = sscanf(arg3, "%d%n", &val, &m);
  while (k == 1) {
    if (j + 1 > seclen)
      fatal_error("set_int2 out of bounds section %s", arg1);
    int2_char(val, sec[i] + j - 1);
    j += 2;
    arg3 += m;
    k = sscanf(arg3, ":%d%n", &val, &m);
  }
  return 0;
}
```