#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 */
scalar_t__ isdigit(char);
int parse_option_arg_unsigned_int(char *arg, unsigned int *value) {
  *value = 0;
  while (!isdigit(*arg))
    arg++;
  while (isdigit(*arg))
    *value = *value * 10 + (*arg++ - '0');
  return 0;
}


x86 assembly (clang, -O0):
<parse_option_arg_unsigned_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    114c <parse_option_arg_unsigned_int+0x3c>
jmp    115d <parse_option_arg_unsigned_int+0x4d>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    112a <parse_option_arg_unsigned_int+0x1a>
jmp    1162 <parse_option_arg_unsigned_int+0x52>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     11a1 <parse_option_arg_unsigned_int+0x91>
mov    -0x10(%rbp),%rax
imul   $0xa,(%rax),%ecx
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
movsbl (%rax),%eax
sub    $0x30,%eax
add    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    1162 <parse_option_arg_unsigned_int+0x52>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_option_arg_unsigned_int>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
movl   $0x0,(%rsi)
movsbl (%rbx),%edi
call   1030 <isdigit@plt>
add    $0x1,%rbx
test   %rax,%rax
je     1120 <parse_option_arg_unsigned_int+0x10>
movsbl -0x1(%rbx),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     1164 <parse_option_arg_unsigned_int+0x54>
nop
mov    (%r14),%eax
lea    (%rax,%rax,4),%eax
movsbl -0x1(%rbx),%ecx
lea    (%rcx,%rax,2),%eax
add    $0xffffffd0,%eax
mov    %eax,(%r14)
movsbl (%rbx),%edi
call   1030 <isdigit@plt>
add    $0x1,%rbx
test   %rax,%rax
jne    1140 <parse_option_arg_unsigned_int+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @parse_option_arg_unsigned_int(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
store i8* %0, i8** %3
store i32* %1, i32** %4
%5 = load i32*, i32** %4
store i32 0, i32* %5
br label %6
6: ; preds = %12, %2
%7 = load i8*, i8** %3
%8 = load i8, i8* %7
%9 = call i64 @isdigit(i8 signext %8)
%10 = icmp ne i64 %9, 0
%11 = xor i1 %10, true
br i1 %11, label %12, label %15
12: ; preds = %6
%13 = load i8*, i8** %3
%14 = getelementptr inbounds i8, i8* %13, i32 1
store i8* %14, i8** %3
br label %6
15: ; preds = %6
br label %16
16: ; preds = %21, %15
%17 = load i8*, i8** %3
%18 = load i8, i8* %17
%19 = call i64 @isdigit(i8 signext %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %32
21: ; preds = %16
%22 = load i32*, i32** %4
%23 = load i32, i32* %22
%24 = mul i32 %23, 10
%25 = load i8*, i8** %3
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %3
%27 = load i8, i8* %25
%28 = sext i8 %27 to i32
%29 = sub nsw i32 %28, 48
%30 = add i32 %24, %29
%31 = load i32*, i32** %4
store i32 %30, i32* %31
br label %16
32: ; preds = %16
ret i32 0
}

LLVM IR (-O2):
define i32 @parse_option_arg_unsigned_int(i8* nocapture %0, i32* nocapture %1) {
store i32 0, i32* %1
br label %3
3: ; preds = %3, %2
%4 = phi i8* [ %0, %2 ], [ %8, %3 ]
%5 = load i8, i8* %4
%6 = tail call i64 @isdigit(i8 signext %5)
%7 = icmp eq i64 %6, 0
%8 = getelementptr inbounds i8, i8* %4, i64 1
br i1 %7, label %3, label %9
9: ; preds = %3
%10 = load i8, i8* %4
%11 = tail call i64 @isdigit(i8 signext %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %25, label %13
13: ; preds = %9, %13
%14 = phi i8* [ %17, %13 ], [ %4, %9 ]
%15 = load i32, i32* %1
%16 = mul i32 %15, 10
%17 = getelementptr inbounds i8, i8* %14, i64 1
%18 = load i8, i8* %14
%19 = sext i8 %18 to i32
%20 = add i32 %16, -48
%21 = add i32 %20, %19
store i32 %21, i32* %1
%22 = load i8, i8* %17
%23 = tail call i64 @isdigit(i8 signext %22)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %13
25: ; preds = %13, %9
ret i32 0
}