user: 请将以下的汇编代码转换成C语言代码:

```asm
<fb_drawimage>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  sub    $0x1c8,%rsp
  mov    %rdi,-0x1a8(%rbp)
  mov    %rsi,-0x1b0(%rbp)
  mov    %edx,-0x1b4(%rbp)
  mov    %ecx,-0x1b8(%rbp)
  mov    %r8d,-0x1bc(%rbp)
  mov    %r9d,-0x1c0(%rbp)
  mov    0x18(%rbp),%rax
  mov    %rax,-0x1c8(%rbp)
  mov    0x20(%rbp),%rax
  mov    %rax,-0x1d0(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x18(%rbp)
  xor    %eax,%eax
  lea    -0x120(%rbp),%rax
  mov    $0x100,%edx
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <memset@plt>
  mov    -0x1a8(%rbp),%rax
  lea    D28(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x188(%rbp)
L9:
  mov    -0x188(%rbp),%rdx
  lea    -0x170(%rbp),%rax
  mov    $0x50,%esi
  mov    %rax,%rdi
  call   <fgets@plt>
  test   %rax,%rax
  jne    L124
  mov    -0x1a8(%rbp),%rax
  mov    %rax,%rsi
  lea    D11(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  mov    $0x1,%edi
  call   <exit@plt>
L124:
  movzbl -0x170(%rbp),%eax
  cmp    $0x23,%al
  je     L114
  lea    -0x120(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,%ebx
  lea    -0x170(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  add    %ebx,%eax
  cmp    $0xff,%eax
  jbe    L62
  mov    -0x1a8(%rbp),%rax
  mov    %rax,%rsi
  lea    D11(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  mov    $0x1,%edi
  call   <exit@plt>
L62:
  lea    -0x170(%rbp),%rdx
  lea    -0x120(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcat@plt>
  movzbl -0x120(%rbp),%eax
  cmp    $0x50,%al
  jne    L54
  movzbl -0x11f(%rbp),%eax
  cmp    $0x36,%al
  je     L1
L54:
  mov    -0x1a8(%rbp),%rax
  mov    %rax,%rsi
  lea    D11(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  mov    $0x1,%edi
  call   <exit@plt>
L1:
  lea    -0x19c(%rbp),%rsi
  mov    -0x1c8(%rbp),%rcx
  mov    -0x1d0(%rbp),%rdx
  lea    -0x120(%rbp),%rax
  mov    %rsi,%r8
  lea    D31(%rip),%rsi
  mov    %rax,%rdi
  call   <sscanf@plt>
  cmp    $0x3,%eax
  je     L132
  jmp    L9
L114:
  nop
  jmp    L9
L132:
  nop
  mov    -0x1d0(%rbp),%rax
  mov    (%rax),%edx
  mov    %edx,%eax
  add    %eax,%eax
  add    %edx,%eax
  mov    %eax,-0x194(%rbp)
  movq   $0x0,-0x180(%rbp)
  mov    -0x194(%rbp),%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x178(%rbp)
  movl   $0x0,-0x198(%rbp)
  jmp    L86
L69:
  mov    -0x178(%rbp),%rax
  mov    %rax,-0x190(%rbp)
  mov    -0x188(%rbp),%rcx
  mov    -0x194(%rbp),%edx
  mov    -0x178(%rbp),%rax
  mov    $0x1,%esi
  mov    %rax,%rdi
  call   <fread@plt>
  cmp    %eax,-0x194(%rbp)
  je     L110
  mov    -0x1a8(%rbp),%rax
  mov    %rax,%rsi
  lea    D11(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  mov    $0x1,%edi
  call   <exit@plt>
L110:
  movl   $0x0,-0x19c(%rbp)
  jmp    L85
L31:
  addq   $0x3,-0x190(%rbp)
  mov    0x10(%rbp),%edx
  mov    -0x1d0(%rbp),%rax
  mov    (%rax),%eax
  sub    %eax,%edx
  mov    -0x19c(%rbp),%eax
  add    %eax,%edx
  mov    -0x1b4(%rbp),%eax
  lea    (%rdx,%rax,1),%ecx
  mov    -0x1bc(%rbp),%eax
  lea    0x7(%rax),%edx
  test   %eax,%eax
  cmovs  %edx,%eax
  sar    $0x3,%eax
  imul   %eax,%ecx
  mov    -0x1b8(%rbp),%edx
  mov    -0x198(%rbp),%eax
  add    %eax,%edx
  mov    -0x1c0(%rbp),%eax
  imul   %edx,%eax
  add    %ecx,%eax
  mov    %eax,%eax
  mov    %rax,-0x180(%rbp)
  mov    -0x190(%rbp),%rax
  movzbl (%rax),%edx
  mov    -0x180(%rbp),%rcx
  mov    -0x1b0(%rbp),%rax
  add    %rcx,%rax
  mov    %dl,(%rax)
  mov    -0x190(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%edx
  mov    -0x180(%rbp),%rax
  lea    0x1(%rax),%rcx
  mov    -0x1b0(%rbp),%rax
  add    %rcx,%rax
  mov    %dl,(%rax)
  mov    -0x190(%rbp),%rax
  add    $0x2,%rax
  movzbl (%rax),%edx
  mov    -0x180(%rbp),%rax
  lea    0x2(%rax),%rcx
  mov    -0x1b0(%rbp),%rax
  add    %rcx,%rax
  mov    %dl,(%rax)
  mov    -0x180(%rbp),%rax
  lea    0x3(%rax),%rdx
  mov    -0x1b0(%rbp),%rax
  add    %rdx,%rax
  movb   $0xff,(%rax)
  mov    -0x19c(%rbp),%eax
  add    $0x1,%eax
  mov    %eax,-0x19c(%rbp)
L85:
  mov    -0x1d0(%rbp),%rax
  mov    (%rax),%edx
  mov    -0x19c(%rbp),%eax
  cmp    %eax,%edx
  ja     L31
  addl   $0x1,-0x198(%rbp)
L86:
  mov    -0x1c8(%rbp),%rax
  mov    (%rax),%eax
  cmp    %eax,-0x198(%rbp)
  jb     L69
  mov    -0x178(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    -0x188(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  nop
  mov    -0x18(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L10
  call   <__stack_chk_fail@plt>
L10:
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

tool_calls: name: disassemble_data
arguments: tag: D28
type_infered: string
name: disassemble_data
arguments: tag: D11
type_infered: string
name: disassemble_data
arguments: tag: D31
type_infered: string

tool: D28: r

tool: D11: bad PPM file '%s'

tool: D31: P6 %u %u %u

assistant: ```c
void fb_drawimage(const char *filename, char *fbp, int xo, int yo, int bpp, int length, int xres, unsigned *img_height, unsigned *img_width) {
  char head[256];
  char s[80];
  FILE *theme_file;
  unsigned char *pixline;
  unsigned i, j, line_size;
  memset(head, 0, sizeof(head));
  theme_file = fopen(filename, "r");
  while (1) {
    if (fgets(s, sizeof(s), theme_file) == NULL) {
      printf("bad PPM file '%s'", filename);
      exit(1);
    }
    if (s[0] == '#')
      continue;
    if (strlen(head) + strlen(s) >= sizeof(head)) {
      printf("bad PPM file '%s'", filename);
      exit(1);
    }
    strcat(head, s);
    if (head[0] != 'P' || head[1] != '6') {
      printf("bad PPM file '%s'", filename);
      exit(1);
    }
    if (sscanf(head, "P6 %u %u %u", img_width, img_height, &i) == 3)
      break;
  }
  line_size = *img_width * 3;
  long int location = 0;
  pixline = malloc(line_size);
  for (j = 0; j < *img_height; j++) {
    unsigned char *pixel = pixline;
    if (fread(pixline, 1, line_size, theme_file) != line_size) {
      printf("bad PPM file '%s'", filename);
      exit(1);
    }
    for (i = 0; i < *img_width; i++) {
      pixel += 3;
      location = ((xres - *img_width) + i + xo) * (bpp / 8) + (j + yo) * length;
      *(fbp + location) = (((unsigned)pixel[0]));
      *(fbp + location + 1) = (((unsigned)pixel[1]));
      *(fbp + location + 2) = (((unsigned)pixel[2]));
      *(fbp + location + 3) = -1;
    }
  }
  free(pixline);
  fclose(theme_file);
}
```