user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<f_set_hex>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    0x70(%rsp),%rbx
  mov    0x78(%rsp),%rbp
  mov    0x80(%rsp),%r13
  mov    %rbx,0x10(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x28(%rsp)
  xor    %eax,%eax
  test   %edi,%edi
  js     L41
  mov    %rbx,%rdi
  mov    %rsi,%r14
  call   <atoi@plt>
  mov    %rbp,%rdi
  mov    %eax,%r15d
  call   <atoi@plt>
  mov    %eax,%ebx
  cmp    $0x8,%r15d
  ja     L161
  test   %eax,%eax
  jle    L112
L14:
  movl   $0x10,0xc(%rsp)
  test   %r15d,%r15d
  jne    L206
L204:
  mov    %r13,%rax
  jmp    L102
  nopl   0x0(%rax)
L25:
  add    $0x1,%rax
  cmp    $0x3a,%dl
  je     L29
L102:
  movzbl (%rax),%edx
  test   %dl,%dl
  jne    L25
  lea    0x20(%rsp),%r12
  lea    0x24(%rsp),%rbp
  mov    %r13,%rdi
  mov    %r12,%rcx
  mov    %rbp,%rdx
  lea    D68(%rip),%rsi
  call   <sscanf@plt>
  cmp    $0x1,%eax
  jne    L41
  movslq %r15d,%rax
  lea    (%r14,%rax,8),%r15
  movslq %ebx,%rax
  sub    $0x1,%rax
  mov    %rax,0x18(%rsp)
  mov    %rax,%r14
  jmp    L160
  nopl   0x0(%rax,%rax,1)
L181:
  mov    (%r15),%rax
  mov    0x24(%rsp),%edx
  mov    %r12,%rcx
  lea    D68(%rip),%rsi
  mov    %dl,(%rax,%r14,1)
  movslq 0x20(%rsp),%rax
  mov    %rbp,%rdx
  add    $0x1,%r14
  add    %rax,%r13
  mov    %r13,%rdi
  call   <sscanf@plt>
  cmp    $0x1,%eax
  jne    L41
L160:
  mov    %ebx,%eax
  sub    0x18(%rsp),%eax
  add    %r14d,%eax
  cmp    0xc(%rsp),%eax
  jle    L181
  mov    0x10(%rsp),%rsi
  lea    D78(%rip),%rdi
  call   <fatal_error@plt>
  jmp    L181
  nopl   0x0(%rax,%rax,1)
L41:
  mov    0x28(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L73
  add    $0x38,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L29:
  lea    0x20(%rsp),%r12
  lea    0x24(%rsp),%rbp
  mov    %r13,%rdi
  mov    %r12,%rcx
  mov    %rbp,%rdx
  lea    D87(%rip),%rsi
  call   <sscanf@plt>
  cmp    $0x1,%eax
  jne    L41
  movslq %r15d,%rax
  lea    (%r14,%rax,8),%r14
  movslq %ebx,%rax
  sub    $0x1,%rax
  mov    %rax,0x18(%rsp)
  mov    %rax,%r15
  jmp    L212
  nopl   0x0(%rax)
L7:
  mov    (%r14),%rax
  mov    0x24(%rsp),%edx
  mov    %r12,%rcx
  lea    D52(%rip),%rsi
  mov    %dl,(%rax,%r15,1)
  movslq 0x20(%rsp),%rax
  mov    %rbp,%rdx
  add    $0x1,%r15
  add    %rax,%r13
  mov    %r13,%rdi
  call   <sscanf@plt>
  cmp    $0x1,%eax
  jne    L41
L212:
  mov    %ebx,%eax
  sub    0x18(%rsp),%eax
  add    %r15d,%eax
  cmp    %eax,0xc(%rsp)
  jge    L7
  mov    0x10(%rsp),%rsi
  lea    D78(%rip),%rdi
  call   <fatal_error@plt>
  jmp    L7
  nopw   0x0(%rax,%rax,1)
L161:
  mov    0x10(%rsp),%rsi
  lea    D1(%rip),%rdi
  call   <fatal_error@plt>
  test   %ebx,%ebx
  jle    L112
L26:
  movslq %r15d,%rax
  mov    (%r14,%rax,8),%rdi
  call   <uint4@plt>
  mov    %eax,0xc(%rsp)
  jmp    L204
  nopw   0x0(%rax,%rax,1)
L206:
  cmp    $0x8,%r15d
  jne    L26
  movl   $0x4,0xc(%rsp)
  jmp    L204
  nopl   0x0(%rax,%rax,1)
L112:
  lea    D80(%rip),%rsi
  lea    D81(%rip),%rdi
  call   <fatal_error@plt>
  jmp    L14
L73:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: tag: D68
type_guessed: string
name: read_data
arguments: tag: D78
type_guessed: string
name: read_data
arguments: tag: D87
type_guessed: string
name: read_data
arguments: tag: D52
type_guessed: string
name: read_data
arguments: tag: D1
type_guessed: string
name: read_data
arguments: tag: D80
type_guessed: string
name: read_data
arguments: tag: D81
type_guessed: string

tool: D68: %2x%n

tool: D78: set_byte out of bounds section %s

tool: D87: %x%n

tool: D52: :%x%n

tool: D1: set_byte: bad section number %s

tool: 

tool: D81: set_hex: octet number must >= 1

assistant: ```c
int f_set_hex(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, seclen, has_colon;
  unsigned int val;
  const char *str;
  if (mode < 0)
    return 0;
  i = atoi(arg1);
  j = atoi(arg2);
  if (i < 0 || i > 8)
    fatal_error("set_byte: bad section number %s", arg1);
  if (j <= 0)
    fatal_error("set_hex: octet number must >= 1", "");
  if (i == 0)
    seclen = 16;
  else if (i == 8)
    seclen = 4;
  else
    seclen = uint4(sec[i]);
  str = arg3;
  has_colon = 0;
  while (*str) {
    if (*str++ == ':') {
      has_colon = 1;
      break;
    }
  }
  if (has_colon) {
    k = sscanf(arg3, "%x%n", &val, &m);
    while (k == 1) {
      if (j > seclen)
        fatal_error("set_byte out of bounds section %s", arg1);
      sec[i][j++ - 1] = val;
      arg3 += m;
      k = sscanf(arg3, ":%x%n", &val, &m);
    }
  } else {
    k = sscanf(arg3, "%2x%n", &val, &m);
    while (k == 1) {
      if (j > seclen)
        fatal_error("set_byte out of bounds section %s", arg1);
      sec[i][j++ - 1] = val;
      arg3 += m;
      k = sscanf(arg3, "%2x%n", &val, &m);
    }
  }
  return 0;
}
```