user: Translate the below assembly code into C programming language:

```asm
<scan_integer>:
  endbr64
  push   %rbx
  mov    $0x4,%edx
  mov    %rdi,%rbx
  xor    %edi,%edi
  sub    $0x20,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  lea    0xe(%rsp),%rsi
  xor    %eax,%eax
  movq   $0x0,0xe(%rsp)
  mov    %ax,0x16(%rsp)
  call   <read@plt>
  movzbl 0xe(%rsp),%eax
  test   %al,%al
  je     L206
  cmp    $0xa,%al
  je     L206
  movzbl 0xf(%rsp),%edx
  test   %dl,%dl
  je     L256
  cmp    $0xa,%dl
  je     L256
  movzbl 0x10(%rsp),%eax
  test   %al,%al
  je     L102
  cmp    $0xa,%al
  je     L102
  movzbl 0x11(%rsp),%eax
  test   %al,%al
  je     L121
  cmp    $0xa,%al
  je     L121
  movzbl 0x12(%rsp),%eax
  test   %al,%al
  je     L250
  cmp    $0xa,%al
  je     L250
  movzbl 0x13(%rsp),%eax
  test   %al,%al
  je     L26
  cmp    $0xa,%al
  je     L26
  movzbl 0x14(%rsp),%eax
  test   %al,%al
  je     L236
  cmp    $0xa,%al
  je     L236
  movzbl 0x15(%rsp),%eax
  test   %al,%al
  je     L10
  cmp    $0xa,%al
  je     L10
  movzbl 0x16(%rsp),%eax
  test   %al,%al
  setne  %cl
  xor    %edx,%edx
  cmp    $0xa,%al
  setne  %dl
  and    %ecx,%edx
  add    $0x7,%edx
L132:
  movslq %edx,%rax
  lea    -0x1(%rdx),%esi
  movzbl 0xe(%rsp,%rax,1),%edi
  movslq %esi,%rsi
  lea    -0x30(%rdi),%ecx
  mov    %cl,0xe(%rsp,%rax,1)
  movzbl 0xe(%rsp,%rsi,1),%eax
  movsbl %cl,%ecx
  sub    $0x30,%eax
  mov    %al,0xe(%rsp,%rsi,1)
  movsbl %al,%eax
  lea    -0x2(%rdx),%esi
  lea    (%rax,%rax,4),%eax
  lea    (%rcx,%rax,2),%eax
  cmp    $0x1,%edx
  je     L157
  movslq %esi,%rsi
  movzbl 0xe(%rsp,%rsi,1),%edi
  lea    -0x30(%rdi),%ecx
  mov    %cl,0xe(%rsp,%rsi,1)
  movsbl %cl,%ecx
  lea    -0x3(%rdx),%esi
  imul   $0x64,%ecx,%ecx
  add    %ecx,%eax
  cmp    $0x2,%edx
  je     L157
  movslq %esi,%rsi
  movzbl 0xe(%rsp,%rsi,1),%edi
  lea    -0x30(%rdi),%ecx
  mov    %cl,0xe(%rsp,%rsi,1)
  movsbl %cl,%ecx
  lea    -0x4(%rdx),%esi
  imul   $0x3e8,%ecx,%ecx
  add    %ecx,%eax
  cmp    $0x3,%edx
  je     L157
  movslq %esi,%rsi
  movzbl 0xe(%rsp,%rsi,1),%edi
  lea    -0x30(%rdi),%ecx
  mov    %cl,0xe(%rsp,%rsi,1)
  movsbl %cl,%ecx
  lea    -0x5(%rdx),%esi
  imul   $0x2710,%ecx,%ecx
  add    %ecx,%eax
  cmp    $0x4,%edx
  je     L157
  movslq %esi,%rsi
  movzbl 0xe(%rsp,%rsi,1),%edi
  lea    -0x30(%rdi),%ecx
  mov    %cl,0xe(%rsp,%rsi,1)
  movsbl %cl,%ecx
  lea    -0x6(%rdx),%esi
  imul   $0x186a0,%ecx,%ecx
  add    %ecx,%eax
  cmp    $0x5,%edx
  je     L157
  movslq %esi,%rsi
  movzbl 0xe(%rsp,%rsi,1),%edi
  lea    -0x30(%rdi),%ecx
  mov    %cl,0xe(%rsp,%rsi,1)
  movsbl %cl,%ecx
  imul   $0xf4240,%ecx,%ecx
  add    %ecx,%eax
  lea    -0x7(%rdx),%ecx
  cmp    $0x6,%edx
  je     L157
  movslq %ecx,%rsi
  movzbl 0xe(%rsp,%rsi,1),%edi
  lea    -0x30(%rdi),%edx
  mov    %dl,0xe(%rsp,%rsi,1)
  movsbl %dl,%edx
  imul   $0x989680,%edx,%edx
  add    %edx,%eax
  test   %ecx,%ecx
  je     L157
  movzbl 0xe(%rsp),%edi
  lea    -0x30(%rdi),%edx
  movsbl %dl,%edx
  imul   $0x5f5e100,%edx,%edx
  add    %edx,%eax
L157:
  mov    %eax,(%rbx)
  mov    0x18(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L58
  add    $0x20,%rsp
  pop    %rbx
  ret
L26:
  mov    $0x4,%edx
  jmp    L132
  nopw   0x0(%rax,%rax,1)
L206:
  xor    %eax,%eax
  jmp    L157
  nopl   0x0(%rax)
L256:
  sub    $0x30,%eax
  movsbl %al,%eax
  jmp    L157
L102:
  mov    $0x1,%edx
  jmp    L132
L121:
  mov    $0x2,%edx
  jmp    L132
L250:
  mov    $0x3,%edx
  jmp    L132
L236:
  mov    $0x5,%edx
  jmp    L132
L10:
  mov    $0x6,%edx
  jmp    L132
L58:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int scan_integer(int *str) {
  int pos = 0;
  char buffer[10] = {'\0'};
  read(0, buffer, sizeof(int));
  while ((buffer[pos] != '\0') && (buffer[pos] != '\n')) {
    pos++;
  }
  pos--;
  int val = 0;
  int io = 1;
  while (pos >= 0) {
    buffer[pos] = buffer[pos] - 48;
    val = val + buffer[pos] * io;
    pos--;
    io = io * 10;
  }
  *str = val;
  return val;
}
```