#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 parseNumber(char **q) {
  int value = 0;
  if (!isdigit(**q)) {
    return -1;
  }
  while (isdigit(**q)) {
    value = value * 10 + **q - '0';
    (*q)++;
  }
  return value;
}


x86 assembly (clang, -O0):
<parseNumber>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
jne    1148 <parseNumber+0x38>
movl   $0xffffffff,-0x4(%rbp)
jmp    1195 <parseNumber+0x85>
jmp    114d <parseNumber+0x3d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     118f <parseNumber+0x7f>
imul   $0xa,-0x14(%rbp),%eax
mov    -0x10(%rbp),%rcx
mov    (%rcx),%rcx
movsbl (%rcx),%ecx
add    %ecx,%eax
sub    $0x30,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
jmp    114d <parseNumber+0x3d>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseNumber>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    (%rdi),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     1166 <parseNumber+0x56>
mov    (%r14),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
xor    %ebx,%ebx
test   %rax,%rax
je     116b <parseNumber+0x5b>
nopl   0x0(%rax)
lea    (%rbx,%rbx,4),%eax
mov    (%r14),%rcx
movsbl (%rcx),%edx
lea    (%rdx,%rax,2),%ebx
add    $0xffffffd0,%ebx
lea    0x1(%rcx),%rax
mov    %rax,(%r14)
movsbl 0x1(%rcx),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
jne    1140 <parseNumber+0x30>
jmp    116b <parseNumber+0x5b>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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