#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 matchNumber(char *ar, int *ip) {
  int n = 0;
  while (isdigit(ar[*ip])) {
    n = 10 * n + (ar[*ip] - '0');
    (*ip)++;
  }
  return n;
}


x86 assembly (clang, -O0):
<matchNumber>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movslq (%rcx),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     1170 <matchNumber+0x60>
imul   $0xa,-0x14(%rbp),%eax
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%rdx
movslq (%rdx),%rdx
movsbl (%rcx,%rdx,1),%ecx
sub    $0x30,%ecx
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    1127 <matchNumber+0x17>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<matchNumber>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
movslq (%rsi),%rax
movsbl (%rdi,%rax,1),%edi
call   1030 <isdigit@plt>
xor    %ebx,%ebx
test   %rax,%rax
je     1158 <matchNumber+0x48>
xchg   %ax,%ax
lea    (%rbx,%rbx,4),%eax
movslq (%r14),%rcx
movsbl (%r15,%rcx,1),%edx
lea    (%rdx,%rax,2),%ebx
add    $0xffffffd0,%ebx
lea    0x1(%rcx),%rax
mov    %eax,(%r14)
movsbl 0x1(%r15,%rcx,1),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
jne    1130 <matchNumber+0x20>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

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