#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 */
int /*<<< orphan*/ assert(int);
scalar_t__ isdigit(unsigned char);
int FindNextNumber(char *buffer, unsigned long *startindex) {
  unsigned long index;
  (assert((buffer != NULL) && (startindex != NULL)));
  index = *startindex;
  while (buffer[index] != '\0') {
    if (isdigit((unsigned char)buffer[index]))
      break;
    else
      index++;
  }
  if (isdigit((unsigned char)buffer[index])) {
    (*startindex) = index;
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<FindNextNumber>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x10(%rbp)
mov    %al,-0x21(%rbp)
je     114b <FindNextNumber+0x2b>
cmpq   $0x0,-0x18(%rbp)
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11a9 <FindNextNumber+0x89>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movzbl (%rax,%rcx,1),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     1198 <FindNextNumber+0x78>
jmp    11a9 <FindNextNumber+0x89>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1163 <FindNextNumber+0x43>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movzbl (%rax,%rcx,1),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     11db <FindNextNumber+0xbb>
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    11e2 <FindNextNumber+0xc2>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FindNextNumber>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%rbp
test   %rdi,%rdi
setne  %al
test   %rsi,%rsi
setne  %cl
and    %al,%cl
movzbl %cl,%edi
call   1040 <assert@plt>
mov    (%r15),%rbx
mov    0x0(%rbp,%rbx,1),%al
xor    %r14d,%r14d
test   %al,%al
je     117a <FindNextNumber+0x5a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl %al,%edi
call   1030 <isdigit@plt>
test   %rax,%rax
jne    117e <FindNextNumber+0x5e>
movzbl 0x1(%rbp,%rbx,1),%eax
add    $0x1,%rbx
test   %al,%al
jne    1160 <FindNextNumber+0x40>
xor    %eax,%eax
jmp    1182 <FindNextNumber+0x62>
mov    0x0(%rbp,%rbx,1),%al
movzbl %al,%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     1198 <FindNextNumber+0x78>
mov    %rbx,(%r15)
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @FindNextNumber(i8* %0, i64* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64*
%6 = alloca i64
store i8* %0, i8** %4
store i64* %1, i64** %5
%7 = load i8*, i8** %4
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i64*, i64** %5
%11 = icmp ne i64* %10, null
br label %12
12: ; preds = %9, %2
%13 = phi i1 [ false, %2 ], [ %11, %9 ]
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = load i64*, i64** %5
%17 = load i64, i64* %16
store i64 %17, i64* %6
br label %18
18: ; preds = %36, %12
%19 = load i8*, i8** %4
%20 = load i64, i64* %6
%21 = getelementptr inbounds i8, i8* %19, i64 %20
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %37
25: ; preds = %18
%26 = load i8*, i8** %4
%27 = load i64, i64* %6
%28 = getelementptr inbounds i8, i8* %26, i64 %27
%29 = load i8, i8* %28
%30 = call i64 @isdigit(i8 zeroext %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %25
br label %37
33: ; preds = %25
%34 = load i64, i64* %6
%35 = add i64 %34, 1
store i64 %35, i64* %6
br label %36
36: ; preds = %33
br label %18
37: ; preds = %32, %18
%38 = load i8*, i8** %4
%39 = load i64, i64* %6
%40 = getelementptr inbounds i8, i8* %38, i64 %39
%41 = load i8, i8* %40
%42 = call i64 @isdigit(i8 zeroext %41)
%43 = icmp ne i64 %42, 0
br i1 %43, label %44, label %47
44: ; preds = %37
%45 = load i64, i64* %6
%46 = load i64*, i64** %5
store i64 %45, i64* %46
store i32 1, i32* %3
br label %48
47: ; preds = %37
store i32 0, i32* %3
br label %48
48: ; preds = %47, %44
%49 = load i32, i32* %3
ret i32 %49
}

LLVM IR (-O2):
define i32 @FindNextNumber(i8* %0, i64* %1) {
%3 = icmp ne i8* %0, null
%4 = icmp ne i64* %1, null
%5 = and i1 %3, %4
%6 = zext i1 %5 to i32
%7 = tail call i32 @assert(i32 %6)
%8 = load i64, i64* %1
%9 = getelementptr inbounds i8, i8* %0, i64 %8
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 0
br i1 %11, label %25, label %12
12: ; preds = %2, %20
%13 = phi i8 [ %23, %20 ], [ %10, %2 ]
%14 = phi i64 [ %21, %20 ], [ %8, %2 ]
%15 = tail call i64 @isdigit(i8 zeroext %13)
%16 = icmp eq i64 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %12
%18 = getelementptr inbounds i8, i8* %0, i64 %14
%19 = load i8, i8* %18
br label %25
20: ; preds = %12
%21 = add i64 %14, 1
%22 = getelementptr inbounds i8, i8* %0, i64 %21
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 0
br i1 %24, label %25, label %12
25: ; preds = %20, %17, %2
%26 = phi i8 [ 0, %2 ], [ %19, %17 ], [ 0, %20 ]
%27 = phi i64 [ %8, %2 ], [ %14, %17 ], [ %21, %20 ]
%28 = tail call i64 @isdigit(i8 zeroext %26)
%29 = icmp eq i64 %28, 0
br i1 %29, label %31, label %30
30: ; preds = %25
store i64 %27, i64* %1
br label %31
31: ; preds = %25, %30
%32 = phi i32 [ 1, %30 ], [ 0, %25 ]
ret i32 %32
}