user: Demonstrate the C code that generates the assembly output below:

```asm
<parse_sfo_content>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x58,%rsp
  mov    %esi,0x8(%rsp)
  mov    %rdx,0x28(%rsp)
  mov    %rcx,0x40(%rsp)
  mov    %r8,0x20(%rsp)
  mov    %r9,0x18(%rsp)
  call   <get32le@plt>
  cmp    $0x46535000,%eax
  je     L380
  lea    D27(%rip),%rdi
  call   <sys_error@plt>
L380:
  lea    0x20(%rbx),%rdi
  lea    0x40(%rbx),%rbp
  call   <get32le@plt>
  lea    0x30(%rbx),%rdi
  mov    %eax,%r13d
  call   <get32le@plt>
  mov    %rbp,%rdi
  mov    %eax,0x48(%rsp)
  call   <get32le@plt>
  cmpq   $0x0,0x20(%rsp)
  setne  0x4d(%rsp)
  cmpq   $0x0,0x18(%rsp)
  setne  0x4e(%rsp)
  cmpq   $0x0,0x90(%rsp)
  mov    %eax,(%rsp)
  setne  0x4f(%rsp)
  test   %eax,%eax
  jle    L124
  movslq %r13d,%rax
  movl   $0xffffffff,0x38(%rsp)
  lea    0x50(%rbx),%rbp
  xor    %r13d,%r13d
  mov    %rax,0x10(%rsp)
  mov    $0xffffffff,%r12d
  lea    D45(%rip),%r15
  movl   $0xffffffff,0x34(%rsp)
  movl   $0xffffffff,0x3c(%rsp)
  movl   $0xffffffff,0x30(%rsp)
  jmp    L53
  nopw   0x0(%rax,%rax,1)
L55:
  mov    %rbp,%rdi
  call   <get16le@plt>
  mov    %r15,%rsi
  movslq %eax,%rdi
  add    0x10(%rsp),%rdi
  lea    (%rbx,%rdi,1),%r14
  mov    %r14,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L473
  cmp    $0xffffffff,%r12d
  cmove  %r13d,%r12d
L468:
  add    $0x1,%r13d
  add    $0x40,%rbp
  cmp    %r13d,(%rsp)
  je     L313
L53:
  mov    %r13d,%eax
  shl    $0x4,%eax
  add    $0x15,%eax
  cmp    0x8(%rsp),%eax
  jl     L55
  lea    D72(%rip),%rdi
  call   <sys_error@plt>
  jmp    L55
  nopw   0x0(%rax,%rax,1)
L473:
  lea    D71(%rip),%rsi
  mov    %r14,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L293
  mov    %r13d,%r12d
  add    $0x40,%rbp
  add    $0x1,%r13d
  cmp    %r13d,(%rsp)
  jne    L53
L313:
  mov    %r12d,%eax
  movzbl 0x4f(%rsp),%r14d
  shl    $0x4,%eax
  cltq
  lea    0x80(%rbx,%rax,4),%rbp
  mov    0x30(%rsp),%eax
  not    %eax
  shr    $0x1f,%eax
  and    0x4d(%rsp),%al
  mov    %al,0x10(%rsp)
  mov    0x34(%rsp),%eax
  not    %eax
  shr    $0x1f,%eax
  and    0x4e(%rsp),%al
  mov    %al,0x4d(%rsp)
  mov    0x38(%rsp),%eax
  not    %eax
  shr    $0x1f,%eax
  and    %eax,%r14d
  cmp    $0xffffffff,%r12d
  je     L312
L180:
  movslq 0x48(%rsp),%r15
  mov    %rbp,%rdi
  xor    %r12d,%r12d
  lea    D31(%rip),%r13
  mov    %r15,(%rsp)
  call   <get32le@plt>
  mov    %rbx,0x8(%rsp)
  movslq %eax,%rdx
  add    %r15,%rdx
  mov    $0xff,%r15d
  lea    (%rbx,%rdx,1),%rbp
  mov    %r15,%rbx
  mov    0x40(%rsp),%r15
  jmp    L85
  nopl   0x0(%rax)
L348:
  cmp    $0xa,%sil
  jne    L477
  movb   $0x20,(%r15)
  add    $0x1,%r15
L477:
  add    $0x1,%r12
  cmp    %r12,%rbx
  jbe    L149
L85:
  movsbl 0x0(%rbp,%r12,1),%esi
  test   %sil,%sil
  je     L149
  lea    -0x20(%rsi),%eax
  cmp    $0x5e,%al
  ja     L348
  mov    %r13,%rdi
  call   <strchr@plt>
  test   %rax,%rax
  je     L311
  movzbl 0x0(%rbp,%r12,1),%esi
  jmp    L348
  nopw   0x0(%rax,%rax,1)
L149:
  cmpb   $0x0,0x10(%rsp)
  mov    0x8(%rsp),%rbx
  movb   $0x0,(%r15)
  jne    L314
L417:
  mov    0x3c(%rsp),%eax
  cmp    $0xffffffff,%eax
  jne    L271
L32:
  mov    0x28(%rsp),%rax
  cmpb   $0x0,0x4d(%rsp)
  movb   $0x0,(%rax)
  jne    L359
L60:
  test   %r14b,%r14b
  jne    L349
L231:
  add    $0x58,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L293:
  lea    D87(%rip),%rsi
  mov    %r14,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L131
  mov    %r13d,0x30(%rsp)
  jmp    L468
  nopw   0x0(%rax,%rax,1)
L311:
  movzbl 0x0(%rbp,%r12,1),%eax
  cmp    $0x3a,%al
  je     L215
  mov    %al,(%r15)
  add    $0x1,%r15
  jmp    L477
  nopw   0x0(%rax,%rax,1)
L271:
  shl    $0x4,%eax
  cltq
  lea    0x80(%rbx,%rax,4),%rdi
  call   <get32le@plt>
  cltq
  add    (%rsp),%rax
  add    %rbx,%rax
  movzbl (%rax),%edx
  test   %dl,%dl
  je     L32
  mov    0x28(%rsp),%rcx
  nopl   0x0(%rax,%rax,1)
L50:
  add    $0x1,%rax
  mov    %dl,(%rcx)
  add    $0x1,%rcx
  movzbl (%rax),%edx
  test   %dl,%dl
  jne    L50
  mov    %rcx,0x28(%rsp)
  mov    0x28(%rsp),%rax
  cmpb   $0x0,0x4d(%rsp)
  movb   $0x0,(%rax)
  je     L60
L359:
  mov    0x34(%rsp),%eax
  shl    $0x4,%eax
  cltq
  lea    0x80(%rbx,%rax,4),%rdi
  call   <get32le@plt>
  movslq %eax,%rdx
  add    (%rsp),%rdx
  add    %rbx,%rdx
  movzbl (%rdx),%eax
  cmp    $0x30,%al
  jne    L142
  movzbl 0x1(%rdx),%eax
  add    $0x1,%rdx
L142:
  test   %al,%al
  je     L267
  mov    0x18(%rsp),%rsi
  nopl   (%rax)
L20:
  add    $0x1,%rdx
  mov    %eax,%ecx
  mov    %al,(%rsi)
  add    $0x1,%rsi
  movzbl (%rdx),%eax
  test   %al,%al
  jne    L20
  mov    %rsi,0x18(%rsp)
L167:
  mov    0x18(%rsp),%rax
  cmp    $0x30,%cl
  je     L344
  movb   $0x0,(%rax)
  test   %r14b,%r14b
  je     L231
L349:
  mov    0x38(%rsp),%eax
  shl    $0x4,%eax
  cltq
  lea    0x80(%rbx,%rax,4),%rdi
  call   <get32le@plt>
  cltq
  add    (%rsp),%rax
  add    %rax,%rbx
  movzbl (%rbx),%eax
  cmp    $0x30,%al
  jne    L347
  movzbl 0x1(%rbx),%eax
  add    $0x1,%rbx
L347:
  test   %al,%al
  je     L21
  mov    0x90(%rsp),%rdx
  nopl   0x0(%rax)
L337:
  add    $0x1,%rbx
  mov    %al,(%rdx)
  add    $0x1,%rdx
  movzbl (%rbx),%eax
  test   %al,%al
  jne    L337
  mov    %rdx,0x90(%rsp)
L21:
  mov    0x90(%rsp),%rax
  movb   $0x0,(%rax)
  add    $0x58,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L314:
  mov    0x30(%rsp),%eax
  shl    $0x4,%eax
  cltq
  lea    0x80(%rbx,%rax,4),%rdi
  call   <get32le@plt>
  cltq
  add    (%rsp),%rax
  add    %rbx,%rax
  movzbl (%rax),%edx
  test   %dl,%dl
  je     L409
  mov    0x20(%rsp),%rcx
  nopl   0x0(%rax,%rax,1)
L43:
  add    $0x1,%rax
  mov    %dl,(%rcx)
  add    $0x1,%rcx
  movzbl (%rax),%edx
  test   %dl,%dl
  jne    L43
  mov    %rcx,0x20(%rsp)
L409:
  mov    0x20(%rsp),%rax
  movb   $0x0,(%rax)
  jmp    L417
  nopl   0x0(%rax,%rax,1)
L131:
  lea    D74(%rip),%rsi
  mov    %r14,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L47
  mov    %r13d,0x3c(%rsp)
  jmp    L468
  xchg   %ax,%ax
L215:
  mov    $0x2d20,%eax
  sub    $0x1,%rbx
  add    $0x2,%r15
  mov    %ax,-0x2(%r15)
  jmp    L477
  nopw   0x0(%rax,%rax,1)
L124:
  movb   $0x0,0x4d(%rsp)
  xor    %r14d,%r14d
  movb   $0x0,0x10(%rsp)
  movl   $0xffffffff,0x30(%rsp)
  movl   $0xffffffff,0x38(%rsp)
  movl   $0xffffffff,0x3c(%rsp)
  movl   $0xffffffff,0x34(%rsp)
L312:
  lea    D43(%rip),%rdi
  call   <sys_error@plt>
  jmp    L180
  xchg   %ax,%ax
L47:
  lea    D84(%rip),%rsi
  mov    %r14,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L465
  mov    %r13d,0x34(%rsp)
  jmp    L468
  xchg   %ax,%ax
L344:
  movb   $0x0,-0x1(%rax)
  jmp    L60
L267:
  mov    0x18(%rsp),%rax
  movzbl -0x1(%rax),%ecx
  jmp    L167
L465:
  lea    D90(%rip),%rsi
  mov    %r14,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  mov    0x38(%rsp),%eax
  cmove  %r13d,%eax
  mov    %eax,0x38(%rsp)
  jmp    L468
```

tool_calls: name: retrieve_data
arguments: label: D27
type_guessed: string
name: retrieve_data
arguments: label: D45
type_guessed: string
name: retrieve_data
arguments: label: D72
type_guessed: string
name: retrieve_data
arguments: label: D71
type_guessed: string
name: retrieve_data
arguments: label: D31
type_guessed: string
name: retrieve_data
arguments: label: D87
type_guessed: string
name: retrieve_data
arguments: label: D74
type_guessed: string
name: retrieve_data
arguments: label: D43
type_guessed: string
name: retrieve_data
arguments: label: D84
type_guessed: string
name: retrieve_data
arguments: label: D90
type_guessed: string

tool: D27: ERROR: incorrect sfo signature


tool: D45: TITLE

tool: D72: ERROR: sfo information is too small


tool: D71: STITLE

tool: D31: <>"/\|?*

tool: D87: CONTENT_ID

tool: D74: CATEGORY

tool: D43: ERROR: cannot find title from sfo file, pkg is probably corrupted


tool: D84: PSP2_DISP_VER

tool: D90: APP_VER

assistant: ```c
void parse_sfo_content(const uint8_t *sfo, uint32_t sfo_size, char *category, char *title, char *content, char *min_version, char *pkg_version) {
  if (get32le(sfo) != 0x46535000) {
    sys_error("ERROR: incorrect sfo signature\n");
  }
  uint32_t keys = get32le(sfo + 8);
  uint32_t values = get32le(sfo + 12);
  uint32_t count = get32le(sfo + 16);
  int title_index = -1;
  int content_index = -1;
  int category_index = -1;
  int minver_index = -1;
  int pkgver_index = -1;
  for (uint32_t i = 0; i < count; i++) {
    if (i * 16 + 20 + 2 > sfo_size) {
      sys_error("ERROR: sfo information is too small\n");
    }
    char *key = (char *)sfo + keys + get16le(sfo + i * 16 + 20);
    if (strcmp(key, "TITLE") == 0) {
      if (title_index < 0) {
        title_index = (int)i;
      }
    } else if (strcmp(key, "STITLE") == 0) {
      title_index = (int)i;
    } else if (strcmp(key, "CONTENT_ID") == 0) {
      content_index = (int)i;
    } else if (strcmp(key, "CATEGORY") == 0) {
      category_index = (int)i;
    } else if (strcmp(key, "PSP2_DISP_VER") == 0) {
      minver_index = (int)i;
    } else if (strcmp(key, "APP_VER") == 0) {
      pkgver_index = (int)i;
    }
  }
  if (title_index < 0) {
    sys_error("ERROR: cannot find title from sfo file, pkg is probably corrupted\n");
  }
  char *value = (char *)sfo + values + get32le(sfo + title_index * 16 + 20 + 12);
  size_t i;
  size_t max = 255;
  for (i = 0; i < max && *value; i++, value++) {
    if ((*value >= 32 && *value < 127 && strchr("<>\"/\\|?*", *value) == NULL) || (uint8_t)*value >= 128) {
      if (*value == ':') {
        *title++ = ' ';
        *title++ = '-';
        max--;
      } else {
        *title++ = *value;
      }
    } else if (*value == 10) {
      *title++ = ' ';
    }
  }
  *title = 0;
  if (content_index >= 0 && content) {
    value = (char *)sfo + values + get32le(sfo + content_index * 16 + 20 + 12);
    while (*value) {
      *content++ = *value++;
    }
    *content = 0;
  }
  if (category_index >= 0) {
    value = (char *)sfo + values + get32le(sfo + category_index * 16 + 20 + 12);
    while (*value) {
      *category++ = *value++;
    }
  }
  *category = 0;
  if (minver_index >= 0 && min_version) {
    value = (char *)sfo + values + get32le(sfo + minver_index * 16 + 20 + 12);
    if (*value == '0') {
      value++;
    }
    while (*value) {
      *min_version++ = *value++;
    }
    if (min_version[-1] == '0') {
      min_version[-1] = 0;
    } else {
      *min_version = 0;
    }
  }
  if (pkgver_index >= 0 && pkg_version) {
    value = (char *)sfo + values + get32le(sfo + pkgver_index * 16 + 20 + 12);
    if (*value == '0') {
      value++;
    }
    while (*value) {
      *pkg_version++ = *value++;
    }
    *pkg_version = 0;
  }
}
```