user: 请将以下的汇编代码转换成C语言代码:

```asm
<strtoul>:
  endbr64
  movq   $0x0,(%rsi)
  xor    %eax,%eax
  cmpb   $0x30,(%rdi)
  mov    %rdi,%rcx
  je     L22
L79:
  movzbl (%rcx,%rax,1),%edi
  lea    -0x30(%rdi),%edx
  cmp    $0x9,%dl
  ja     L117
  imul   $0xa,(%rsi),%rdi
  mov    %rdi,(%rsi)
  movsbl (%rcx,%rax,1),%edx
  cmp    $0x39,%dl
  jg     L26
  sub    $0x30,%edx
  movslq %edx,%rdx
  add    %rdx,%rdi
L169:
  add    $0x1,%rax
  mov    %rdi,(%rsi)
  cmp    $0x10,%rax
  jne    L79
L30:
  mov    $0x1,%eax
  ret
  nopl   0x0(%rax)
L117:
  test   %rax,%rax
  setne  %al
  movzbl %al,%eax
  ret
  nopw   0x0(%rax,%rax,1)
L22:
  movzbl 0x1(%rdi),%edx
  and    $0xffffffdf,%edx
  cmp    $0x58,%dl
  jne    L120
  mov    $0x2,%eax
  jmp    L83
  nopl   0x0(%rax,%rax,1)
L63:
  sub    $0x30,%edx
  movslq %edx,%rdx
  add    %rdx,%rdi
L238:
  add    $0x1,%rax
  mov    %rdi,(%rsi)
  cmp    $0x10,%rax
  je     L30
L83:
  movzbl (%rcx,%rax,1),%edx
  lea    -0x30(%rdx),%edi
  cmp    $0x9,%dil
  jbe    L130
  and    $0xffffffdf,%edx
  sub    $0x41,%edx
  cmp    $0x5,%dl
  ja     L117
L130:
  mov    (%rsi),%rdi
  shl    $0x4,%rdi
  mov    %rdi,(%rsi)
  movsbl (%rcx,%rax,1),%edx
  cmp    $0x39,%dl
  jle    L63
  cmp    $0x5a,%dl
  jg     L162
  sub    $0x37,%edx
  movsbq %dl,%rdx
  add    %rdx,%rdi
  jmp    L238
L120:
  cmp    $0x42,%dl
  jne    L79
  mov    $0x2,%eax
  jmp    L170
  cs nopw 0x0(%rax,%rax,1)
L45:
  sub    $0x30,%edx
  movslq %edx,%rdx
  add    %rdx,%rdi
L148:
  add    $0x1,%rax
  mov    %rdi,(%rsi)
  cmp    $0x10,%rax
  je     L30
L170:
  movzbl (%rcx,%rax,1),%edi
  lea    -0x30(%rdi),%edx
  cmp    $0x1,%dl
  ja     L117
  mov    (%rsi),%rdi
  add    %rdi,%rdi
  mov    %rdi,(%rsi)
  movsbl (%rcx,%rax,1),%edx
  cmp    $0x39,%dl
  jle    L45
  cmp    $0x5a,%dl
  jg     L158
  sub    $0x37,%edx
  movsbq %dl,%rdx
  add    %rdx,%rdi
  jmp    L148
  nopl   (%rax)
L158:
  sub    $0x57,%edx
  movsbq %dl,%rdx
  add    %rdx,%rdi
  jmp    L148
  nopl   0x0(%rax)
L162:
  sub    $0x57,%edx
  movsbq %dl,%rdx
  add    %rdx,%rdi
  jmp    L238
L26:
  cmp    $0x5a,%dl
  jg     L46
  sub    $0x37,%edx
  movsbq %dl,%rdx
  add    %rdx,%rdi
  jmp    L169
L46:
  sub    $0x57,%edx
  movsbq %dl,%rdx
  add    %rdx,%rdi
  jmp    L169
```

assistant: ```c
int strtoul(const char *number, unsigned long *result) {
  unsigned long n, n_num, weight;
  *result = 0;
  if (((number[0] == '0') && (number[1] == 'x')) || ((number[0] == '0') && (number[1] == 'X'))) {
    weight = 16;
    n = 2;
  } else if (((number[0] == '0') && (number[1] == 'b')) || ((number[0] == '0') && (number[1] == 'B'))) {
    weight = 2;
    n = 2;
  } else {
    weight = 10;
    n = 0;
  }
  for (; n < 16; n++) {
    if ((weight == 02) && ((number[n] < '0') || (number[n] > '1')))
      break;
    if ((weight == 10) && ((number[n] < '0') || (number[n] > '9')))
      break;
    if ((weight == 16) && ((number[n] < '0') || (number[n] > '9')) && ((number[n] < 'a') || (number[n] > 'f')) && ((number[n] < 'A') || (number[n] > 'F')))
      break;
    *result = *result * weight;
    if (number[n] <= '9') {
      *result = *result + (number[n] - '0');
    } else if (number[n] <= 'Z') {
      *result = *result + (number[n] - 'A' + 10);
    } else {
      *result = *result + (number[n] - 'a' + 10);
    }
  }
  if (n == 0)
    return 0;
  return 1;
}
```