user: Converte this assembly snippet into its equivalent C code:

```asm
<hpgs_parse_papersize>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x30,%rsp
  mov    %rdi,%rbx
  mov    %rsi,%r12
  mov    %rdx,%rbp
  mov    %fs:0x28,%rax
  mov    %rax,0x28(%rsp)
  xor    %eax,%eax
  lea    D33(%rip),%rsi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L182
  mov    D124(%rip),%rax
  mov    %rax,(%r12)
  mov    D75(%rip),%rax
  mov    %rax,0x0(%rbp)
  mov    $0x0,%eax
L175:
  mov    0x28(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L6
  add    $0x30,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L182:
  lea    D17(%rip),%rsi
  mov    %rbx,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L27
  mov    D75(%rip),%rax
  mov    %rax,(%r12)
  mov    D160(%rip),%rax
  mov    %rax,0x0(%rbp)
  mov    $0x0,%eax
  jmp    L175
L27:
  lea    D239(%rip),%rsi
  mov    %rbx,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L210
  mov    D160(%rip),%rax
  mov    %rax,(%r12)
  mov    D291(%rip),%rax
  mov    %rax,0x0(%rbp)
  mov    $0x0,%eax
  jmp    L175
L210:
  lea    D19(%rip),%rsi
  mov    %rbx,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L133
  mov    D291(%rip),%rax
  mov    %rax,(%r12)
  mov    D284(%rip),%rax
  mov    %rax,0x0(%rbp)
  mov    $0x0,%eax
  jmp    L175
L133:
  lea    D129(%rip),%rsi
  mov    %rbx,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L177
  mov    D284(%rip),%rax
  mov    %rax,(%r12)
  mov    D121(%rip),%rax
  mov    %rax,0x0(%rbp)
  mov    $0x0,%eax
  jmp    L175
L177:
  lea    D15(%rip),%rsi
  mov    %rbx,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L51
  mov    D124(%rip),%rax
  mov    %rax,0x0(%rbp)
  mov    D75(%rip),%rax
  mov    %rax,(%r12)
  mov    $0x0,%eax
  jmp    L175
L51:
  lea    D43(%rip),%rsi
  mov    %rbx,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L149
  mov    D75(%rip),%rax
  mov    %rax,0x0(%rbp)
  mov    D160(%rip),%rax
  mov    %rax,(%r12)
  mov    $0x0,%eax
  jmp    L175
L149:
  lea    D78(%rip),%rsi
  mov    %rbx,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L160
  mov    D160(%rip),%rax
  mov    %rax,0x0(%rbp)
  mov    D291(%rip),%rax
  mov    %rax,(%r12)
  mov    $0x0,%eax
  jmp    L175
L160:
  lea    D287(%rip),%rsi
  mov    %rbx,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L85
  mov    D291(%rip),%rax
  mov    %rax,0x0(%rbp)
  mov    D284(%rip),%rax
  mov    %rax,(%r12)
  mov    $0x0,%eax
  jmp    L175
L85:
  lea    D172(%rip),%rsi
  mov    %rbx,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L45
  mov    D284(%rip),%rax
  mov    %rax,0x0(%rbp)
  mov    D121(%rip),%rax
  mov    %rax,(%r12)
  mov    $0x0,%eax
  jmp    L175
L45:
  mov    $0x78,%esi
  mov    %rbx,%rdi
  call   <strchr@plt>
  mov    %rax,%r13
  test   %rax,%rax
  je     L47
  sub    %rbx,%r13
  mov    %r13d,%edx
  cmp    $0x1f,%r13d
  jg     L47
  mov    %rsp,%r14
  mov    %rbx,%rsi
  mov    %r14,%rdi
  call   <strncpy@plt>
  movslq %r13d,%rax
  movb   $0x0,(%rsp,%rax,1)
  mov    %r12,%rsi
  mov    %r14,%rdi
  call   <hpgs_parse_length@plt>
  test   %rax,%rax
  jne    L47
  movslq %r13d,%r13
  lea    0x1(%rbx,%r13,1),%rdi
  mov    %rbp,%rsi
  call   <hpgs_parse_length@plt>
  test   %rax,%rax
  je     L175
L47:
  mov    $0xffffffff,%eax
  jmp    L175
L6:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: data_label: D33
type_infered: string
name: unpack_data
arguments: data_label: D124
type_infered: f64
name: unpack_data
arguments: data_label: D75
type_infered: f64
name: unpack_data
arguments: data_label: D17
type_infered: string
name: unpack_data
arguments: data_label: D160
type_infered: f64
name: unpack_data
arguments: data_label: D239
type_infered: string
name: unpack_data
arguments: data_label: D291
type_infered: f64
name: unpack_data
arguments: data_label: D19
type_infered: string
name: unpack_data
arguments: data_label: D284
type_infered: f64
name: unpack_data
arguments: data_label: D129
type_infered: string
name: unpack_data
arguments: data_label: D121
type_infered: f64
name: unpack_data
arguments: data_label: D15
type_infered: string
name: unpack_data
arguments: data_label: D43
type_infered: string
name: unpack_data
arguments: data_label: D78
type_infered: string
name: unpack_data
arguments: data_label: D287
type_infered: string
name: unpack_data
arguments: data_label: D172
type_infered: string

tool: D33: A4

tool: D124: 595.9108454553883

tool: D75: 842.7451996082275

tool: D17: A3

tool: D160: 1191.8216909107766

tool: D239: A2

tool: D291: 1685.490399216455

tool: D19: A1

tool: D284: 2383.6433818215532

tool: D129: A0

tool: D121: 3370.98079843291

tool: D15: A4l

tool: D43: A3l

tool: D78: A2l

tool: D287: A1l

tool: D172: A0l

assistant: ```c
int hpgs_parse_papersize(const char *str, double *pt_width, double *pt_height) {
  if (strcmp(str, "A4") == 0) {
    *pt_width = 595.91084545538825881889;
    *pt_height = 842.74519960822752756850;
  } else if (strcmp(str, "A3") == 0) {
    *pt_width = 842.74519960822752756850;
    *pt_height = 1191.82169091077651766614;
  } else if (strcmp(str, "A2") == 0) {
    *pt_width = 1191.82169091077651766614;
    *pt_height = 1685.49039921645505516535;
  } else if (strcmp(str, "A1") == 0) {
    *pt_width = 1685.49039921645505516535;
    *pt_height = 2383.64338182155303536062;
  } else if (strcmp(str, "A0") == 0) {
    *pt_width = 2383.64338182155303536062;
    *pt_height = 3370.98079843291011035905;
  } else if (strcmp(str, "A4l") == 0) {
    *pt_height = 595.91084545538825881889;
    *pt_width = 842.74519960822752756850;
  } else if (strcmp(str, "A3l") == 0) {
    *pt_height = 842.74519960822752756850;
    *pt_width = 1191.82169091077651766614;
  } else if (strcmp(str, "A2l") == 0) {
    *pt_height = 1191.82169091077651766614;
    *pt_width = 1685.49039921645505516535;
  } else if (strcmp(str, "A1l") == 0) {
    *pt_height = 1685.49039921645505516535;
    *pt_width = 2383.64338182155303536062;
  } else if (strcmp(str, "A0l") == 0) {
    *pt_height = 2383.64338182155303536062;
    *pt_width = 3370.98079843291011035905;
  } else {
    const char *x = strchr(str, 'x');
    char wstr[32];
    int l;
    if (!x)
      return -1;
    l = x - str;
    if (l > 31)
      return -1;
    strncpy(wstr, str, l);
    wstr[l] = '\0';
    if (hpgs_parse_length(wstr, pt_width))
      return -1;
    if (hpgs_parse_length(str + l + 1, pt_height))
      return -1;
  }
  return 0;
}
```