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

```asm
<main>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x820,%rsp
  mov    %edi,%ebp
  mov    %rsi,%r12
  mov    %fs:0x28,%rax
  mov    %rax,0x818(%rsp)
  xor    %eax,%eax
  call   <getuid@plt>
  test   %rax,%rax
  jne    L1
  lea    D109(%rip),%rsi
  lea    D87(%rip),%rdi
  call   <fopen@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  je     L81
  lea    0x410(%rsp),%rcx
  lea    0x10(%rsp),%r13
  mov    %r13,%rdx
  lea    D133(%rip),%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <fscanf@plt>
  mov    %rbx,%rdi
  call   <fclose@plt>
  lea    D81(%rip),%rsi
  mov    %r13,%rdi
  call   <fopen@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  je     L80
  lea    0x410(%rsp),%rdi
  lea    D109(%rip),%rsi
  call   <fopen@plt>
  mov    %rax,%r13
  test   %rax,%rax
  je     L129
  lea    0x4(%rsp),%rdx
  lea    D0(%rip),%r14
  mov    %r14,%rsi
  mov    %rbx,%rdi
  mov    $0x0,%eax
  call   <fscanf@plt>
  lea    0x8(%rsp),%rdx
  mov    %r14,%rsi
  mov    %r13,%rdi
  mov    $0x0,%eax
  call   <fscanf@plt>
  mov    %r13,%rdi
  call   <fclose@plt>
  pxor   %xmm0,%xmm0
  cvtsi2ssl 0x4(%rsp),%xmm0
  pxor   %xmm1,%xmm1
  cvtsi2ssl 0x8(%rsp),%xmm1
  divss  %xmm1,%xmm0
  cvtss2sd %xmm0,%xmm0
  mulsd  D155(%rip),%xmm0
  addsd  D78(%rip),%xmm0
  cvttsd2si %xmm0,%r13d
  cmp    $0x1,%ebp
  jle    L69
  cmp    $0x2,%ebp
  je     L168
L87:
  pxor   %xmm0,%xmm0
  cvtsi2ss %r13d,%xmm0
  cvtss2sd %xmm0,%xmm0
  divsd  D155(%rip),%xmm0
  pxor   %xmm1,%xmm1
  cvtsi2ssl 0x8(%rsp),%xmm1
  cvtss2sd %xmm1,%xmm1
  mulsd  %xmm1,%xmm0
  cvttsd2si %xmm0,%edx
  mov    $0x32,%eax
  cmp    %eax,%edx
  cmovl  %eax,%edx
  lea    D33(%rip),%rsi
  mov    %rbx,%rdi
  call   <fprintf@plt>
  mov    %rbx,%rdi
  call   <fclose@plt>
  mov    $0x0,%eax
L47:
  mov    0x818(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L206
  add    $0x820,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L1:
  lea    D9(%rip),%rdi
  call   <puts@plt>
  mov    $0x5,%eax
  jmp    L47
L69:
  mov    %r13d,%esi
  lea    D33(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x0,%eax
  jmp    L47
L168:
  mov    0x8(%r12),%rdi
  lea    D62(%rip),%rsi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L143
  lea    0xc(%rsp),%rdx
  mov    0x8(%r12),%rdi
  lea    D0(%rip),%rsi
  call   <sscanf@plt>
  test   %rax,%rax
  je     L147
  mov    0x8(%r12),%rax
  movzbl (%rax),%eax
  cmp    $0x2b,%al
  je     L104
  cmp    $0x2d,%al
  je     L3
  mov    0xc(%rsp),%r13d
  mov    $0x64,%eax
  cmp    %eax,%r13d
  cmovg  %eax,%r13d
  test   %r13d,%r13d
  mov    $0x1,%eax
  cmovle %eax,%r13d
  jmp    L87
L143:
  mov    (%r12),%rsi
  lea    D61(%rip),%rdi
  call   <printf@plt>
  mov    $0x0,%eax
  jmp    L47
L104:
  add    0xc(%rsp),%r13d
  mov    $0x64,%eax
  cmp    %eax,%r13d
  cmovg  %eax,%r13d
  jmp    L87
L3:
  add    0xc(%rsp),%r13d
  test   %r13d,%r13d
  mov    $0x1,%eax
  cmovle %eax,%r13d
  jmp    L87
L147:
  lea    D139(%rip),%rdi
  call   <puts@plt>
  mov    $0x1,%eax
  jmp    L47
L81:
  mov    $0x2,%eax
  jmp    L47
L80:
  mov    $0x3,%eax
  jmp    L47
L129:
  mov    $0x4,%eax
  jmp    L47
L206:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: tag: D109
type: string
name: retrieve_data
arguments: tag: D87
type: string
name: retrieve_data
arguments: tag: D133
type: string
name: retrieve_data
arguments: tag: D81
type: string
name: retrieve_data
arguments: tag: D0
type: string
name: retrieve_data
arguments: tag: D155
type: f64
name: retrieve_data
arguments: tag: D78
type: byte[8]
name: retrieve_data
arguments: tag: D33
type: string
name: retrieve_data
arguments: tag: D9
type: string
name: retrieve_data
arguments: tag: D62
type: string
name: retrieve_data
arguments: tag: D61
type: string
name: retrieve_data
arguments: tag: D139
type: string

tool: D109: r

tool: D87: /etc/backlightctl.conf

tool: D133: %s
%s

tool: D81: r+

tool: D0: %d

tool: D155: 100

tool: {"D78": [0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x3f]}

tool: D33: %d


tool: D9: You need to be a superuser to use this program.

tool: D62: -h

tool: D61: Usage: %s [[{+,-}]PERCENTAGE]
	 when no parameters are given, the current percentage is printed out.


tool: D139: invalid parameter

assistant: ```c
int main(int argc, char **argv) {
  if (getuid() != 0) {
    printf("You need to be a superuser to use this program.\n");
    return 5;
  }
  static const char *CONFIG_PATH = "/etc/backlightctl.conf";
  FILE *config, *brightness, *max_brightness;
  char brightness_path[1024];
  char max_brightness_path[1024];
  int cur_br, max_br, delta_perc, set_perc, set_br;
  config = fopen(CONFIG_PATH, "r");
  if (config == NULL) {
    return 2;
  }
  fscanf(config, "%s\n%s", brightness_path, max_brightness_path);
  fclose(config);
  brightness = fopen(brightness_path, "r+");
  if (brightness == NULL) {
    return 3;
  }
  max_brightness = fopen(max_brightness_path, "r");
  if (max_brightness == NULL) {
    return 4;
  }
  fscanf(brightness, "%d", &cur_br);
  fscanf(max_brightness, "%d", &max_br);
  fclose(max_brightness);
  set_perc = (int)(((float)cur_br / (float)max_br) * 100.0 + 0.5f);
  if (argc < 2) {
    printf("%d\n", set_perc);
    return 0;
  } else if (argc == 2) {
    if (strcmp(argv[1], "-h") == 0) {
      printf("Usage: %s [[{+,-}]PERCENTAGE]\n\t when no parameters are given, the current percentage is printed out.\n", argv[0]);
      return 0;
    } else if (sscanf(argv[1], "%d", &delta_perc) != 0) {
      if (argv[1][0] == '+') {
        set_perc += delta_perc;
        set_perc = (set_perc > 100) ? 100 : set_perc;
      } else if (argv[1][0] == '-') {
        set_perc += delta_perc;
        set_perc = (set_perc < 1) ? 1 : set_perc;
      } else {
        set_perc = delta_perc;
        set_perc = (set_perc > 100) ? 100 : set_perc;
        set_perc = (set_perc < 1) ? 1 : set_perc;
      }
    } else {
      printf("invalid parameter\n");
      return 1;
    }
  }
  set_br = (int)((((float)set_perc) / 100.0) * ((float)max_br));
  set_br = (set_br < 50) ? 50 : set_br;
  fprintf(brightness, "%d\n", set_br);
  fclose(brightness);
  return 0;
}
```