user: 请从给定的汇编指令推导出C源代码：

```asm
<fb_drawimage>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x1a8,%rsp
  mov    %rdi,%r15
  mov    %rdi,0x10(%rsp)
  mov    %rsi,%rbx
  mov    %edx,%r12d
  mov    %ecx,0x28(%rsp)
  mov    %r8d,0x2c(%rsp)
  mov    %r9d,0x24(%rsp)
  mov    0x1e8(%rsp),%rax
  mov    %rax,0x8(%rsp)
  mov    0x1f0(%rsp),%rbp
  mov    %fs:0x28,%rax
  mov    %rax,0x198(%rsp)
  xor    %eax,%eax
  lea    0x90(%rsp),%rdi
  mov    $0x100,%edx
  mov    $0x0,%esi
  call   <memset@plt>
  lea    D21(%rip),%rsi
  mov    %r15,%rdi
  call   <fopen@plt>
  mov    %rax,(%rsp)
  lea    0x40(%rsp),%r14
  lea    0x90(%rsp),%r15
  jmp    L158
L39:
  mov    0x10(%rsp),%rsi
  lea    D30(%rip),%rdi
  call   <printf@plt>
  mov    $0x1,%edi
  call   <exit@plt>
  jmp    L176
L64:
  mov    0x10(%rsp),%rsi
  lea    D30(%rip),%rdi
  call   <printf@plt>
  mov    $0x1,%edi
  call   <exit@plt>
  jmp    L94
L3:
  mov    0x10(%rsp),%rsi
  lea    D30(%rip),%rdi
  call   <printf@plt>
  mov    $0x1,%edi
  call   <exit@plt>
L130:
  lea    0x3c(%rsp),%r8
  mov    0x8(%rsp),%rcx
  mov    %rbp,%rdx
  lea    D19(%rip),%rsi
  mov    %r15,%rdi
  call   <sscanf@plt>
  cmp    $0x3,%eax
  je     L61
L158:
  mov    (%rsp),%rdx
  mov    $0x50,%esi
  mov    %r14,%rdi
  call   <fgets@plt>
  test   %rax,%rax
  je     L39
L176:
  cmpb   $0x23,0x40(%rsp)
  je     L158
  mov    %r15,%rdi
  call   <strlen@plt>
  mov    %eax,%r13d
  mov    %r14,%rdi
  call   <strlen@plt>
  add    %eax,%r13d
  cmp    $0xff,%r13d
  ja     L64
L94:
  mov    %r14,%rsi
  mov    %r15,%rdi
  call   <strcat@plt>
  cmpb   $0x50,0x90(%rsp)
  jne    L3
  cmpb   $0x36,0x91(%rsp)
  jne    L3
  jmp    L130
L61:
  mov    0x0(%rbp),%eax
  lea    (%rax,%rax,2),%eax
  mov    %eax,0x20(%rsp)
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,0x18(%rsp)
  mov    0x8(%rsp),%rax
  cmpl   $0x0,(%rax)
  je     L154
  mov    0x2c(%rsp),%eax
  lea    0x7(%rax),%r14d
  test   %eax,%eax
  cmovns %eax,%r14d
  sar    $0x3,%r14d
  mov    0x28(%rsp),%r13d
  imul   0x24(%rsp),%r13d
  mov    $0x0,%r15d
  jmp    L144
L114:
  movl   $0x0,0x3c(%rsp)
  mov    0x0(%rbp),%esi
  test   %esi,%esi
  je     L97
  mov    0x18(%rsp),%rcx
  mov    $0x0,%edx
L119:
  add    $0x3,%rcx
  mov    %r12d,%eax
  sub    %esi,%eax
  add    0x1e0(%rsp),%eax
  add    %edx,%eax
  imul   %r14d,%eax
  lea    (%rax,%r13,1),%eax
  movzbl (%rcx),%esi
  mov    %sil,(%rbx,%rax,1)
  movzbl 0x1(%rcx),%esi
  mov    %sil,0x1(%rbx,%rax,1)
  movzbl 0x2(%rcx),%esi
  mov    %sil,0x2(%rbx,%rax,1)
  movb   $0xff,0x3(%rbx,%rax,1)
  add    $0x1,%edx
  mov    %edx,0x3c(%rsp)
  mov    0x0(%rbp),%esi
  cmp    %esi,%edx
  jb     L119
L97:
  add    $0x1,%r15d
  add    0x24(%rsp),%r13d
  mov    0x8(%rsp),%rax
  cmp    %r15d,(%rax)
  jbe    L154
L144:
  mov    (%rsp),%rcx
  mov    0x20(%rsp),%edx
  mov    $0x1,%esi
  mov    0x18(%rsp),%rdi
  call   <fread@plt>
  cmp    0x20(%rsp),%eax
  je     L114
  mov    0x10(%rsp),%rsi
  lea    D30(%rip),%rdi
  call   <printf@plt>
  mov    $0x1,%edi
  call   <exit@plt>
  jmp    L114
L154:
  mov    0x18(%rsp),%rdi
  call   <free@plt>
  mov    (%rsp),%rdi
  call   <fclose@plt>
  mov    0x198(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L15
  add    $0x1a8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L15:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: label: D21
datatype: string
name: disassemble_data
arguments: label: D30
datatype: string
name: disassemble_data
arguments: label: D19
datatype: string

tool: D21: r

tool: D30: bad PPM file '%s'

tool: D19: 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);
}
```