#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';
  }
  if (c != '\0')
    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>
movsbl -0x19(%rbp),%eax
cmp    $0x0,%eax
je     11a3 <sqlUnsigned+0x93>
mov    -0x8(%rbp),%rsi
lea    0xe62(%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     114b <sqlUnsigned+0x3b>
lea    0x1(%rsi),%rcx
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
movzbl %al,%eax
lea    (%rbx,%rbx,4),%edx
lea    (%rax,%rdx,2),%ebx
add    $0xffffffd0,%ebx
movzbl (%rcx),%eax
lea    -0x30(%rax),%edx
add    $0x1,%rcx
cmp    $0xa,%dl
jb     1130 <sqlUnsigned+0x20>
test   %al,%al
je     115b <sqlUnsigned+0x4b>
lea    0xeaa(%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* %5
%29 = sext i8 %28 to i32
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %27
%32 = load i8*, i8** %2
%33 = call i32 @errAbort(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %32)
br label %34
34: ; preds = %31, %27
%35 = load i32, i32* %3
ret i32 %35
}

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 %17
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, %1
%18 = phi i32 [ 0, %1 ], [ %13, %5 ]
%19 = phi i8 [ %2, %1 ], [ %14, %5 ]
%20 = icmp eq i8 %19, 0
br i1 %20, label %23, label %21
21: ; preds = %17
%22 = tail call i32 @errAbort(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %23
23: ; preds = %21, %17
ret i32 %18
}