#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 const);
char const L_(int /*<<< orphan*/);
unsigned int read_int(const char **pstr) {
  unsigned int retval = **pstr - L_('0');
  while (ISDIGIT(*++(*pstr))) {
    retval *= 10;
    retval += **pstr - L_('0');
  }
  return retval;
}


x86 assembly (clang, -O0):
<read_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    $0x30,%edi
call   1030 <L_@plt>
mov    %al,%cl
mov    -0x10(%rbp),%eax
movsbl %cl,%ecx
sub    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rcx
mov    (%rcx),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,(%rcx)
movsbl 0x1(%rax),%edi
call   1040 <ISDIGIT@plt>
cmp    $0x0,%rax
je     11a7 <read_int+0x87>
imul   $0xa,-0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    $0x30,%edi
call   1030 <L_@plt>
mov    %al,%cl
mov    -0x14(%rbp),%eax
movsbl %cl,%ecx
sub    %ecx,%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    1150 <read_int+0x30>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_int>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
mov    (%rdi),%rax
movsbl (%rax),%ebx
mov    $0x30,%edi
call   1030 <L_@plt>
movsbl %al,%eax
nopl   0x0(%rax,%rax,1)
sub    %eax,%ebx
mov    (%r14),%rax
lea    0x1(%rax),%rcx
mov    %rcx,(%r14)
movsbl 0x1(%rax),%edi
call   1040 <ISDIGIT@plt>
test   %rax,%rax
je     1177 <read_int+0x57>
lea    (%rbx,%rbx,4),%r15d
mov    (%r14),%rax
movsbl (%rax),%ebx
mov    $0x30,%edi
call   1030 <L_@plt>
movsbl %al,%eax
lea    (%rbx,%r15,2),%ebx
jmp    1140 <read_int+0x20>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

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