#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 strtol(char *, char **, int);
int extractInteger(char *str, int number[]) {
  char *endp;
  int c = 0;
  while (*str) {
    if (isdigit(*str)) {
      number[c++] = strtol(str, &endp, 10);
      while (isdigit(*str))
        str++;
    } else
      str++;
  }
  return c;
}


x86 assembly (clang, -O0):
<extractInteger>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     11c0 <extractInteger+0xa0>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     11af <extractInteger+0x8f>
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,%edx
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x1c(%rbp)
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     11aa <extractInteger+0x8a>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1183 <extractInteger+0x63>
jmp    11bb <extractInteger+0x9b>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1137 <extractInteger+0x17>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extractInteger>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    (%rdi),%al
test   %al,%al
je     1197 <extractInteger+0x77>
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %ebp,%ebp
mov    %rsp,%r15
jmp    114a <extractInteger+0x2a>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
mov    (%rbx),%al
test   %al,%al
je     1199 <extractInteger+0x79>
movsbl %al,%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     1140 <extractInteger+0x20>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
movslq %ebp,%rcx
mov    %eax,(%r14,%rcx,4)
add    $0xffffffffffffffff,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl 0x1(%rbx),%edi
add    $0x1,%rbx
call   1030 <isdigit@plt>
test   %rax,%rax
jne    1180 <extractInteger+0x60>
add    $0x1,%ebp
jmp    1144 <extractInteger+0x24>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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