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

```asm
<main>:
  endbr64
  push   %r12
  mov    $0x1,%edi
  xor    %r12d,%r12d
  push   %rbp
  push   %rbx
  call   <malloc@plt>
  mov    %rax,%rbp
  jmp    L251
  nopw   0x0(%rax,%rax,1)
L191:
  mov    %rbp,%rdi
  lea    0x1(%r12),%esi
  call   <realloc@plt>
  mov    %rax,%rbp
L251:
  xor    %eax,%eax
  lea    0x0(%rbp,%r12,1),%rbx
  add    $0x1,%r12
  call   <getchar@plt>
  mov    %al,(%rbx)
  cmp    $0xa,%al
  jne    L191
  mov    %rbp,%rdi
  call   <strlen@plt>
  movslq %eax,%r12
  lea    (%r12,%r12,1),%edi
  mov    %r12,%rbx
  call   <malloc@plt>
  mov    %rax,%rdi
  test   %r12d,%r12d
  jle    L38
  lea    (%rax,%r12,2),%rax
  lea    -0x1(%r12),%edx
  cmp    %rax,%rbp
  setae  %al
  add    %rbp,%r12
  cmp    %r12,%rdi
  setae  %cl
  or     %cl,%al
  je     L188
  cmp    $0xe,%edx
  jbe    L188
  mov    %ebx,%eax
  movdqa D4(%rip),%xmm3
  mov    %rbp,%rdx
  pxor   %xmm4,%xmm4
  shr    $0x4,%eax
  sub    $0x1,%eax
  shl    $0x4,%rax
  lea    0x10(%rbp,%rax,1),%rcx
  mov    %rdi,%rax
  nopl   (%rax)
L49:
  movdqu (%rdx),%xmm0
  movdqa %xmm4,%xmm2
  add    $0x10,%rdx
  add    $0x20,%rax
  pcmpgtb %xmm0,%xmm2
  movdqa %xmm0,%xmm1
  punpcklbw %xmm2,%xmm1
  punpckhbw %xmm2,%xmm0
  paddw  %xmm3,%xmm1
  paddw  %xmm3,%xmm0
  movups %xmm1,-0x20(%rax)
  movups %xmm0,-0x10(%rax)
  cmp    %rcx,%rdx
  jne    L49
  mov    %ebx,%eax
  and    $0xfffffff0,%eax
  test   $0xf,%bl
  je     L97
  mov    %eax,%ecx
  movsbw 0x0(%rbp,%rcx,1),%si
  lea    (%rcx,%rcx,1),%rdx
  sub    $0x30,%esi
  mov    %si,(%rdi,%rcx,2)
  lea    0x1(%rax),%ecx
  cmp    %ecx,%ebx
  jle    L97
  movslq %ecx,%rcx
  movsbw 0x0(%rbp,%rcx,1),%cx
  sub    $0x30,%ecx
  mov    %cx,0x2(%rdi,%rdx,1)
  lea    0x2(%rax),%ecx
  cmp    %ecx,%ebx
  jle    L97
  movslq %ecx,%rcx
  movsbw 0x0(%rbp,%rcx,1),%cx
  sub    $0x30,%ecx
  mov    %cx,0x4(%rdi,%rdx,1)
  lea    0x3(%rax),%ecx
  cmp    %ecx,%ebx
  jle    L97
  movslq %ecx,%rcx
  movsbw 0x0(%rbp,%rcx,1),%cx
  sub    $0x30,%ecx
  mov    %cx,0x6(%rdi,%rdx,1)
  lea    0x4(%rax),%ecx
  cmp    %ecx,%ebx
  jle    L97
  movslq %ecx,%rcx
  movsbw 0x0(%rbp,%rcx,1),%cx
  sub    $0x30,%ecx
  mov    %cx,0x8(%rdi,%rdx,1)
  lea    0x5(%rax),%ecx
  cmp    %ecx,%ebx
  jle    L97
  movslq %ecx,%rcx
  movsbw 0x0(%rbp,%rcx,1),%cx
  sub    $0x30,%ecx
  mov    %cx,0xa(%rdi,%rdx,1)
  lea    0x6(%rax),%ecx
  cmp    %ecx,%ebx
  jle    L97
  movslq %ecx,%rcx
  movsbw 0x0(%rbp,%rcx,1),%cx
  sub    $0x30,%ecx
  mov    %cx,0xc(%rdi,%rdx,1)
  lea    0x7(%rax),%ecx
  cmp    %ecx,%ebx
  jle    L97
  movslq %ecx,%rcx
  movsbw 0x0(%rbp,%rcx,1),%cx
  sub    $0x30,%ecx
  mov    %cx,0xe(%rdi,%rdx,1)
  lea    0x8(%rax),%ecx
  cmp    %ecx,%ebx
  jle    L97
  movslq %ecx,%rcx
  movsbw 0x0(%rbp,%rcx,1),%cx
  sub    $0x30,%ecx
  mov    %cx,0x10(%rdi,%rdx,1)
  lea    0x9(%rax),%ecx
  cmp    %ecx,%ebx
  jle    L97
  movslq %ecx,%rcx
  movsbw 0x0(%rbp,%rcx,1),%cx
  sub    $0x30,%ecx
  mov    %cx,0x12(%rdi,%rdx,1)
  lea    0xa(%rax),%ecx
  cmp    %ecx,%ebx
  jle    L97
  movslq %ecx,%rcx
  movsbw 0x0(%rbp,%rcx,1),%cx
  sub    $0x30,%ecx
  mov    %cx,0x14(%rdi,%rdx,1)
  lea    0xb(%rax),%ecx
  cmp    %ecx,%ebx
  jle    L97
  movslq %ecx,%rcx
  movsbw 0x0(%rbp,%rcx,1),%cx
  sub    $0x30,%ecx
  mov    %cx,0x16(%rdi,%rdx,1)
  lea    0xc(%rax),%ecx
  cmp    %ecx,%ebx
  jle    L97
  movslq %ecx,%rcx
  movsbw 0x0(%rbp,%rcx,1),%cx
  sub    $0x30,%ecx
  mov    %cx,0x18(%rdi,%rdx,1)
  lea    0xd(%rax),%ecx
  cmp    %ecx,%ebx
  jle    L97
  movslq %ecx,%rcx
  add    $0xe,%eax
  movsbw 0x0(%rbp,%rcx,1),%cx
  sub    $0x30,%ecx
  mov    %cx,0x1a(%rdi,%rdx,1)
  cmp    %eax,%ebx
  jle    L97
  cltq
  movsbw 0x0(%rbp,%rax,1),%ax
  sub    $0x30,%eax
  mov    %ax,0x1c(%rdi,%rdx,1)
  nopl   0x0(%rax)
L97:
  xor    %esi,%esi
  xor    %eax,%eax
  nopl   0x0(%rax)
L222:
  movslq %eax,%rdx
  lea    (%rdi,%rdx,2),%rdx
  nopw   0x0(%rax,%rax,1)
L101:
  movswl (%rdx),%ecx
  lea    (%rsi,%rsi,4),%esi
  add    $0x1,%eax
  add    $0x2,%rdx
  lea    (%rcx,%rsi,2),%esi
  cmp    %eax,%ebx
  jle    L73
  cmp    $0x12b,%esi
  jle    L101
L73:
  movslq %esi,%rdx
  mov    %esi,%ecx
  imul   $0x1b4e81b5,%rdx,%rdx
  sar    $0x1f,%ecx
  sar    $0x25,%rdx
  sub    %ecx,%edx
  imul   $0x12c,%edx,%edx
  sub    %edx,%esi
  cmp    %eax,%ebx
  jg     L222
L129:
  lea    D9(%rip),%rdi
  call   <printf@plt>
  pop    %rbx
  xor    %eax,%eax
  pop    %rbp
  pop    %r12
  ret
L188:
  add    %rdx,%rdx
  mov    %rdi,%rax
  lea    0x2(%rdi,%rdx,1),%rcx
  nopl   0x0(%rax,%rax,1)
L8:
  movsbw 0x0(%rbp),%dx
  add    $0x2,%rax
  add    $0x1,%rbp
  sub    $0x30,%edx
  mov    %dx,-0x2(%rax)
  cmp    %rcx,%rax
  jne    L8
  jmp    L97
L38:
  xor    %esi,%esi
  jmp    L129
```

tool_calls: name: unpack_data
arguments: tag: D4
type_infered: byte[16]
name: unpack_data
arguments: tag: D9
type_infered: string

tool: {"D4": [0xd0,0xff,0xd0,0xff,0xd0,0xff,0xd0,0xff,0xd0,0xff,0xd0,0xff,0xd0,0xff,0xd0,0xff]}

tool: D9: remainder is = %d


assistant: ```c
int main(void) {
  int i = 0;
  char *s = (char *)malloc(sizeof(char));
  while ((s[i] = getchar()) != '\n') {
    s = (char *)realloc(s, i + 2);
    i++;
  }
  short int *n;
  int length;
  int num = 0;
  length = strlen(s);
  n = (short int *)malloc(sizeof(short int) * length);
  for (i = 0; i < length; i++) {
    n[i] = s[i] - '0';
  }
  i = 0;
  while (i < length) {
    while (i < length && num < 300) {
      num = num * 10 + n[i];
      i++;
    }
    num = num % 300;
  }
  printf("remainder is = %d\n", num);
}
```