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

```asm
<main>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %edi,%r12d
  mov    %rsi,%rbp
  mov    $0x0,%eax
  call   <initEc@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  je     L44
L58:
  cmp    $0x3,%r12d
  je     L2
  mov    $0xa3,%edx
  mov    $0x1,%esi
  mov    %rbx,%rdi
  call   <write8@plt>
  mov    0x0(%rbp),%rsi
  lea    D138(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    0x0(%rbp),%rsi
  lea    D186(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  lea    D220(%rip),%rdi
  call   <puts@plt>
  mov    $0x5,%edx
  mov    $0x1,%esi
  mov    %rbx,%rdi
  call   <read1@plt>
  mov    %eax,%esi
  lea    D12(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x2,%edx
  mov    $0x7,%esi
  mov    %rbx,%rdi
  call   <read1@plt>
  mov    %eax,%esi
  lea    D69(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x6,%edx
  mov    $0x1,%esi
  mov    %rbx,%rdi
  call   <read1@plt>
  mov    %eax,%esi
  lea    D99(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x7,%edx
  mov    $0x1,%esi
  mov    %rbx,%rdi
  call   <read1@plt>
  mov    %eax,%esi
  lea    D132(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x6,%edx
  mov    $0x2,%esi
  mov    %rbx,%rdi
  call   <read1@plt>
  mov    %eax,%esi
  lea    D109(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x5,%edx
  mov    $0x3,%esi
  mov    %rbx,%rdi
  call   <read1@plt>
  mov    %eax,%esi
  lea    D102(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x66,%esi
  mov    %rbx,%rdi
  call   <read8@plt>
  mov    %eax,%esi
  lea    D226(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x3,%edx
  mov    $0x9,%esi
  mov    %rbx,%rdi
  call   <read1@plt>
  mov    %eax,%esi
  lea    D38(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0xd7,%esi
  mov    %rbx,%rdi
  call   <read8@plt>
  mov    %eax,%esi
  lea    D48(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x60,%esi
  mov    %rbx,%rdi
  call   <read8@plt>
  mov    %eax,%esi
  lea    D101(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x61,%esi
  mov    %rbx,%rdi
  call   <read8@plt>
  mov    %eax,%esi
  lea    D221(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x62,%esi
  mov    %rbx,%rdi
  call   <read8@plt>
  mov    %eax,%esi
  lea    D56(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0xfc,%esi
  mov    %rbx,%rdi
  call   <read16@plt>
  mov    %eax,%esi
  lea    D42(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0xfe,%esi
  mov    %rbx,%rdi
  call   <read16@plt>
  mov    %eax,%esi
  lea    D255(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x3,%edx
  mov    $0x13,%esi
  mov    %rbx,%rdi
  call   <read1@plt>
  mov    %eax,%esi
  lea    D180(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x6,%edx
  mov    $0x8,%esi
  mov    %rbx,%rdi
  call   <read1@plt>
  mov    %eax,%esi
  lea    D204(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x4,%edx
  mov    $0x12,%esi
  mov    %rbx,%rdi
  call   <read1@plt>
  mov    %eax,%esi
  lea    D106(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x0,%edx
  mov    $0x13,%esi
  mov    %rbx,%rdi
  call   <read1@plt>
  mov    %eax,%esi
  lea    D158(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0xb0,%esi
  mov    %rbx,%rdi
  call   <read8@plt>
  pxor   %xmm0,%xmm0
  cvtsi2sd %eax,%xmm0
  divsd  D265(%rip),%xmm0
  call   <round@plt>
  mov    %eax,%esi
  lea    D190(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0xb1,%esi
  mov    %rbx,%rdi
  call   <read8@plt>
  pxor   %xmm0,%xmm0
  cvtsi2sd %eax,%xmm0
  divsd  D265(%rip),%xmm0
  call   <round@plt>
  mov    %eax,%esi
  lea    D88(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x64,%esi
  mov    %rbx,%rdi
  call   <read8@plt>
  mov    %eax,%esi
  lea    D201(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L17:
  mov    %rbx,%rdi
  call   <closeEc@plt>
  mov    $0x0,%edi
  call   <exit@plt>
  mov    $0x0,%eax
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L44:
  lea    D216(%rip),%rdi
  call   <fail@plt>
  jmp    L58
L2:
  mov    0x8(%rbp),%rdi
  mov    $0x2e,%esi
  call   <strchr@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L36
  movb   $0x0,(%rax)
  mov    0x8(%rbp),%rdi
  mov    $0x0,%edx
  mov    $0x0,%esi
  call   <strtol@plt>
  mov    %rax,%r13
  lea    0x1(%r12),%rdi
  call   <atoi@plt>
  mov    %rax,%r12
  mov    0x10(%rbp),%rdi
  mov    $0x0,%edx
  mov    $0x0,%esi
  call   <strtol@plt>
  movzbl %al,%ecx
  movzbl %r12b,%edx
  movzbl %r13b,%esi
  mov    %rbx,%rdi
  call   <write1@plt>
  jmp    L17
L36:
  mov    0x8(%rbp),%rdi
  mov    $0x0,%edx
  mov    $0x0,%esi
  call   <strtol@plt>
  mov    %rax,%r12
  mov    0x10(%rbp),%rdi
  mov    $0x0,%edx
  mov    $0x0,%esi
  call   <strtol@plt>
  movzbl %al,%edx
  movzbl %r12b,%esi
  mov    %rbx,%rdi
  call   <write8@plt>
  jmp    L17
```

tool_calls: name: parse_data
arguments: tag: D138
datatype: string
name: parse_data
arguments: tag: D186
datatype: string
name: parse_data
arguments: tag: D220
datatype: string
name: parse_data
arguments: tag: D12
datatype: string
name: parse_data
arguments: tag: D69
datatype: string
name: parse_data
arguments: tag: D99
datatype: string
name: parse_data
arguments: tag: D132
datatype: string
name: parse_data
arguments: tag: D109
datatype: string
name: parse_data
arguments: tag: D102
datatype: string
name: parse_data
arguments: tag: D226
datatype: string
name: parse_data
arguments: tag: D38
datatype: string
name: parse_data
arguments: tag: D48
datatype: string
name: parse_data
arguments: tag: D101
datatype: string
name: parse_data
arguments: tag: D221
datatype: string
name: parse_data
arguments: tag: D56
datatype: string
name: parse_data
arguments: tag: D42
datatype: string
name: parse_data
arguments: tag: D255
datatype: string
name: parse_data
arguments: tag: D180
datatype: string
name: parse_data
arguments: tag: D204
datatype: string
name: parse_data
arguments: tag: D106
datatype: string
name: parse_data
arguments: tag: D158
datatype: string
name: parse_data
arguments: tag: D265
datatype: f64
name: parse_data
arguments: tag: D190
datatype: string
name: parse_data
arguments: tag: D88
datatype: string
name: parse_data
arguments: tag: D201
datatype: string
name: parse_data
arguments: tag: D216
datatype: string

tool: D138: Usage: sudo %s [<hex-offset[.bit]> <hex-value>]


tool: D186:    Ex: sudo %s 0x01.6 0x07



tool: D220: Current Embedded Controller Values:

tool: D12:   USB Charge During Sleep     [0x01.5]: %d


tool: D69:   USB Charge During Hibernate [0x07.2]: %d


tool: D99:   Camera Enabled              [0x01.6]: %d


tool: D132:   Bluetooth Enabled           [0x01.7]: %d


tool: D109:   WiFi Enabled                [0x02.6]: %d


tool: D102:   Touchpad Enabled            [0x03.5]: %d


tool: D226:   Ambient Light               [0x66]:   %d%%


tool: D38:   Screen Enabled              [0x09.3]: %d


tool: D48:   Keyboard Backlight Mode     [0xD7]:   %d


tool: D101:   CPU Temp                    [0x60]:   %d C


tool: D221:   GPU Temp                    [0x61]:   %d C


tool: D56:   MLB Temp                    [0x62]:   %d C


tool: D42:   Fan0 Speed                  [0xFC]:   %d RPM


tool: D255:   Fan1 Speed                  [0xFE]:   %d RPM


tool: D180:   Fan Control Enabled         [0x13.3]: %d


tool: D204:   Fan Quiet Mode Enabled      [0x08.6]: %d


tool: D106:   Fan Gaming Mode Enabled     [0x12.4]: %d


tool: D158:   Fan Custom Mode Enabled     [0x13.0]: %d


tool: D265: 2.55

tool: D190:   Fan0 Custom Speed Setting   [0xB0]:   %d%%


tool: D88:   Fan1 Custom Speed Setting   [0xB1]:   %d%%


tool: D201:   Current Speed Setting       [0x64]:   %d


tool: D216: Unable to initialize embedded controller; did you forget to use sudo?

assistant: ```c
int main(int argc, char **args) {
  FILE *ec = initEc();
  if (!ec)
    fail("Unable to initialize embedded controller; did you forget to use sudo?");
  if (argc == 3) {
    char *dotIdx = strchr(args[1], '.');
    if (dotIdx != NULL) {
      *dotIdx = '\0';
      dotIdx++;
      unsigned char offset = (unsigned char)strtol(args[1], NULL, 0);
      unsigned char bit = (unsigned char)atoi(dotIdx);
      unsigned char value = (unsigned char)strtol(args[2], NULL, 0);
      write1(ec, offset, bit, value);
    } else {
      unsigned char offset = (unsigned char)strtol(args[1], NULL, 0);
      unsigned char value = (unsigned char)strtol(args[2], NULL, 0);
      write8(ec, offset, value);
    }
  } else {
    write8(ec, 0x01, 0xA3);
    printf("Usage: sudo %s [<hex-offset[.bit]> <hex-value>]\n", args[0]);
    printf("   Ex: sudo %s 0x01.6 0x07\n\n", args[0]);
    printf("Current Embedded Controller Values:\n");
    printf("  USB Charge During Sleep     [0x01.5]: %d\n", read1(ec, 0x01, 5));
    printf("  USB Charge During Hibernate [0x07.2]: %d\n", read1(ec, 0x07, 2));
    printf("  Camera Enabled              [0x01.6]: %d\n", read1(ec, 0x01, 6));
    printf("  Bluetooth Enabled           [0x01.7]: %d\n", read1(ec, 0x01, 7));
    printf("  WiFi Enabled                [0x02.6]: %d\n", read1(ec, 0x02, 6));
    printf("  Touchpad Enabled            [0x03.5]: %d\n", read1(ec, 0x03, 5));
    printf("  Ambient Light               [0x66]:   %d%%\n", read8(ec, 0x66));
    printf("  Screen Enabled              [0x09.3]: %d\n", read1(ec, 0x09, 3));
    printf("  Keyboard Backlight Mode     [0xD7]:   %d\n", read8(ec, 0xD7));
    printf("  CPU Temp                    [0x60]:   %d C\n", read8(ec, 0x60));
    printf("  GPU Temp                    [0x61]:   %d C\n", read8(ec, 0x61));
    printf("  MLB Temp                    [0x62]:   %d C\n", read8(ec, 0x62));
    printf("  Fan0 Speed                  [0xFC]:   %d RPM\n", read16(ec, 0xFC));
    printf("  Fan1 Speed                  [0xFE]:   %d RPM\n", read16(ec, 0xFE));
    printf("  Fan Control Enabled         [0x13.3]: %d\n", read1(ec, 0x13, 3));
    printf("  Fan Quiet Mode Enabled      [0x08.6]: %d\n", read1(ec, 0x08, 6));
    printf("  Fan Gaming Mode Enabled     [0x12.4]: %d\n", read1(ec, 0x12, 4));
    printf("  Fan Custom Mode Enabled     [0x13.0]: %d\n", read1(ec, 0x13, 0));
    printf("  Fan0 Custom Speed Setting   [0xB0]:   %d%%\n", (int)round(read8(ec, 0xB0) / 2.55));
    printf("  Fan1 Custom Speed Setting   [0xB1]:   %d%%\n", (int)round(read8(ec, 0xB1) / 2.55));
    printf("  Current Speed Setting       [0x64]:   %d\n", read8(ec, 0x64));
  }
  closeEc(ec);
  exit(0);
}
```