#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 */
typedef int /*<<< orphan*/ a;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
scalar_t__ isdigit(char);
int strlen(char *);
int getNumberToken(char a[], int *cursor) {
  int value = 0;
  assert((*cursor) >= 0 && (*cursor) < strlen(a));
  do {
    value = value * 10 + (int)(a[*cursor]) - (int)('0');
    (*cursor)++;
  } while (isdigit(a[*cursor]));
  return value;
}


x86 assembly (clang, -O0):
<getNumberToken>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rcx
xor    %eax,%eax
cmpl   $0x0,(%rcx)
mov    %al,-0x15(%rbp)
jl     1178 <getNumberToken+0x48>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
setl   %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
imul   $0xa,-0x14(%rbp),%eax
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%rdx
movslq (%rdx),%rdx
movsbl (%rcx,%rdx,1),%ecx
add    %ecx,%eax
sub    $0x30,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movslq (%rcx),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
jne    1185 <getNumberToken+0x55>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getNumberToken>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
mov    (%rsi),%ebp
xor    %ebx,%ebx
mov    $0x0,%edi
test   %ebp,%ebp
js     115a <getNumberToken+0x2a>
mov    %r15,%rdi
call   1040 <strlen@plt>
xor    %edi,%edi
cmp    %eax,%ebp
setl   %dil
call   1050 <assert@plt>
nop
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    1160 <getNumberToken+0x30>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @getNumberToken(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
%6 = load i32*, i32** %4
%7 = load i32, i32* %6
%8 = icmp sge i32 %7, 0
br i1 %8, label %9, label %15
9: ; preds = %2
%10 = load i32*, i32** %4
%11 = load i32, i32* %10
%12 = load i8*, i8** %3
%13 = call i32 @strlen(i8* %12)
%14 = icmp slt i32 %11, %13
br label %15
15: ; preds = %9, %2
%16 = phi i1 [ false, %2 ], [ %14, %9 ]
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
br label %19
19: ; preds = %34, %15
%20 = load i32, i32* %5
%21 = mul nsw i32 %20, 10
%22 = load i8*, i8** %3
%23 = load i32*, i32** %4
%24 = load i32, i32* %23
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %22, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = add nsw i32 %21, %28
%30 = sub nsw i32 %29, 48
store i32 %30, i32* %5
%31 = load i32*, i32** %4
%32 = load i32, i32* %31
%33 = add nsw i32 %32, 1
store i32 %33, i32* %31
br label %34
34: ; preds = %19
%35 = load i8*, i8** %3
%36 = load i32*, i32** %4
%37 = load i32, i32* %36
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %35, i64 %38
%40 = load i8, i8* %39
%41 = call i64 @isdigit(i8 signext %40)
%42 = icmp ne i64 %41, 0
br i1 %42, label %19, label %43
43: ; preds = %34
%44 = load i32, i32* %5
ret i32 %44
}

LLVM IR (-O2):
define i32 @getNumberToken(i8* %0, i32* nocapture %1) {
%3 = load i32, i32* %1
%4 = icmp sgt i32 %3, -1
br i1 %4, label %5, label %9
5: ; preds = %2
%6 = tail call i32 @strlen(i8* %0)
%7 = icmp slt i32 %3, %6
%8 = zext i1 %7 to i32
br label %9
9: ; preds = %5, %2
%10 = phi i32 [ 0, %2 ], [ %8, %5 ]
%11 = tail call i32 @assert(i32 %10)
br label %12
12: ; preds = %12, %9
%13 = phi i32 [ 0, %9 ], [ %21, %12 ]
%14 = mul nsw i32 %13, 10
%15 = load i32, i32* %1
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %0, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = add i32 %14, -48
%21 = add i32 %20, %19
%22 = add nsw i32 %15, 1
store i32 %22, i32* %1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %0, i64 %23
%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 %12
28: ; preds = %12
ret i32 %21
}