#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ errAbort(char *, char *);
unsigned sqlUnsigned(char *s) {
  unsigned res = 0;
  char *p = s;
  char c;
  while (((c = *(p++)) >= '0') && (c <= '9')) {
    res *= 10;
    res += c - '0';
  }
  --p;
  if ((c != '\0') || (p == s))
    errAbort("invalid unsigned integer: \"%s\"", s);
  return res;
}


x86 assembly (clang, -O0):
<sqlUnsigned>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
mov    (%rax),%al
mov    %al,-0x19(%rbp)
movsbl %al,%ecx
xor    %eax,%eax
cmp    $0x30,%ecx
mov    %al,-0x1a(%rbp)
jl     115d <sqlUnsigned+0x4d>
movsbl -0x19(%rbp),%eax
cmp    $0x39,%eax
setle  %al
mov    %al,-0x1a(%rbp)
mov    -0x1a(%rbp),%al
test   $0x1,%al
jne    116d <sqlUnsigned+0x5d>
jmp    1186 <sqlUnsigned+0x76>
imul   $0xa,-0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
movsbl -0x19(%rbp),%eax
sub    $0x30,%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    112b <sqlUnsigned+0x1b>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
movsbl -0x19(%rbp),%eax
cmp    $0x0,%eax
jne    11ad <sqlUnsigned+0x9d>
mov    -0x18(%rbp),%rax
cmp    -0x8(%rbp),%rax
jne    11bd <sqlUnsigned+0xad>
mov    -0x8(%rbp),%rsi
lea    0xe48(%rip),%rdi
call   1030 <errAbort@plt>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sqlUnsigned>:
push   %rbx
mov    %rdi,%rsi
mov    (%rdi),%al
lea    -0x30(%rax),%ecx
xor    %ebx,%ebx
cmp    $0x9,%cl
ja     1156 <sqlUnsigned+0x46>
xor    %ecx,%ecx
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl %al,%eax
lea    (%rbx,%rbx,4),%edx
lea    (%rax,%rdx,2),%ebx
add    $0xffffffd0,%ebx
movzbl 0x1(%rsi,%rcx,1),%eax
lea    -0x30(%rax),%edx
add    $0x1,%rcx
cmp    $0xa,%dl
jb     1130 <sqlUnsigned+0x20>
test   %rcx,%rcx
je     1156 <sqlUnsigned+0x46>
test   %al,%al
je     1162 <sqlUnsigned+0x52>
lea    0xea3(%rip),%rdi
call   1030 <errAbort@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [31 x i8] c"invalid unsigned integer: \22%s\22\00"
define i32 @sqlUnsigned(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8
store i8* %0, i8** %2
store i32 0, i32* %3
%6 = load i8*, i8** %2
store i8* %6, i8** %4
br label %7
7: ; preds = %19, %1
%8 = load i8*, i8** %4
%9 = getelementptr inbounds i8, i8* %8, i32 1
store i8* %9, i8** %4
%10 = load i8, i8* %8
store i8 %10, i8* %5
%11 = sext i8 %10 to i32
%12 = icmp sge i32 %11, 48
br i1 %12, label %13, label %17
13: ; preds = %7
%14 = load i8, i8* %5
%15 = sext i8 %14 to i32
%16 = icmp sle i32 %15, 57
br label %17
17: ; preds = %13, %7
%18 = phi i1 [ false, %7 ], [ %16, %13 ]
br i1 %18, label %19, label %27
19: ; preds = %17
%20 = load i32, i32* %3
%21 = mul i32 %20, 10
store i32 %21, i32* %3
%22 = load i8, i8* %5
%23 = sext i8 %22 to i32
%24 = sub nsw i32 %23, 48
%25 = load i32, i32* %3
%26 = add i32 %25, %24
store i32 %26, i32* %3
br label %7
27: ; preds = %17
%28 = load i8*, i8** %4
%29 = getelementptr inbounds i8, i8* %28, i32 -1
store i8* %29, i8** %4
%30 = load i8, i8* %5
%31 = sext i8 %30 to i32
%32 = icmp ne i32 %31, 0
br i1 %32, label %37, label %33
33: ; preds = %27
%34 = load i8*, i8** %4
%35 = load i8*, i8** %2
%36 = icmp eq i8* %34, %35
br i1 %36, label %37, label %40
37: ; preds = %33, %27
%38 = load i8*, i8** %2
%39 = call i32 @errAbort(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %38)
br label %40
40: ; preds = %37, %33
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
@.str = [31 x i8] c"invalid unsigned integer: \22%s\22\00"
define i32 @sqlUnsigned(i8* %0) {
%2 = load i8, i8* %0
%3 = add i8 %2, -48
%4 = icmp ult i8 %3, 10
br i1 %4, label %5, label %21
5: ; preds = %1, %5
%6 = phi i8 [ %14, %5 ], [ %2, %1 ]
%7 = phi i32 [ %13, %5 ], [ 0, %1 ]
%8 = phi i8* [ %10, %5 ], [ %0, %1 ]
%9 = zext i8 %6 to i32
%10 = getelementptr inbounds i8, i8* %8, i64 1
%11 = mul i32 %7, 10
%12 = add i32 %11, -48
%13 = add i32 %12, %9
%14 = load i8, i8* %10
%15 = add i8 %14, -48
%16 = icmp ult i8 %15, 10
br i1 %16, label %5, label %17
17: ; preds = %5
%18 = icmp ne i8 %14, 0
%19 = icmp eq i8* %10, %0
%20 = or i1 %19, %18
br i1 %20, label %21, label %24
21: ; preds = %1, %17
%22 = phi i32 [ %13, %17 ], [ 0, %1 ]
%23 = tail call i32 @errAbort(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %24
24: ; preds = %17, %21
%25 = phi i32 [ %13, %17 ], [ %22, %21 ]
ret i32 %25
}