#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 atoi(char *);
scalar_t__ isdigit(char const);
char *malloc(int);
int /*<<< orphan*/ memcpy(char *, char const *, size_t);
int strlen(char const *);
size_t strspn(char const *, char *);
int getNumber(const char *str) {
  int pos;
  for (pos = 0; pos < strlen(str); pos++) {
    if (str[pos] == '\"' && isdigit(str[pos + 1]))
      break;
  }
  size_t size = strspn(&str[pos + 1], "1234567890");
  char *number = malloc(sizeof(char) * size);
  memcpy(number, &str[pos + 1], size);
  return atoi(number);
}


x86 assembly (clang, -O0):
<getNumber>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cmp    %ecx,%eax
jge    11dc <getNumber+0x7c>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x22,%eax
jne    11c9 <getNumber+0x69>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     11c9 <getNumber+0x69>
jmp    11dc <getNumber+0x7c>
jmp    11ce <getNumber+0x6e>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1173 <getNumber+0x13>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%eax
add    $0x1,%eax
cltq
add    %rax,%rdi
lea    0xe0e(%rip),%rsi
call   1050 <strspn@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%eax
add    $0x1,%eax
cltq
add    %rax,%rsi
mov    -0x18(%rbp),%rdx
call   1060 <memcpy@plt>
mov    -0x20(%rbp),%rdi
call   1080 <atoi@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getNumber>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r12
call   1040 <strlen@plt>
xor    %ebx,%ebx
test   %eax,%eax
jg     1193 <getNumber+0x33>
jmp    11aa <getNumber+0x4a>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
mov    %r12,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbx
jge    11aa <getNumber+0x4a>
cmpb   $0x22,(%r12,%rbx,1)
jne    1180 <getNumber+0x20>
movsbl 0x1(%r12,%rbx,1),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     1180 <getNumber+0x20>
add    $0x1,%ebx
add    %rbx,%r12
lea    0xe49(%rip),%rsi
mov    %r12,%rdi
call   1050 <strspn@plt>
mov    %rax,%r14
mov    %r14d,%edi
call   1070 <malloc@plt>
mov    %rax,%r15
mov    %rax,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
call   1060 <memcpy@plt>
mov    %r15,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1080 <atoi@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"1234567890\00"
define i32 @getNumber(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i64
%5 = alloca i8*
store i8* %0, i8** %2
store i32 0, i32* %3
br label %6
6: ; preds = %30, %1
%7 = load i32, i32* %3
%8 = load i8*, i8** %2
%9 = call i32 @strlen(i8* %8)
%10 = icmp slt i32 %7, %9
br i1 %10, label %11, label %33
11: ; preds = %6
%12 = load i8*, i8** %2
%13 = load i32, i32* %3
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 34
br i1 %18, label %19, label %29
19: ; preds = %11
%20 = load i8*, i8** %2
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %20, i64 %23
%25 = load i8, i8* %24
%26 = call i64 @isdigit(i8 signext %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %19
br label %33
29: ; preds = %19, %11
br label %30
30: ; preds = %29
%31 = load i32, i32* %3
%32 = add nsw i32 %31, 1
store i32 %32, i32* %3
br label %6
33: ; preds = %28, %6
%34 = load i8*, i8** %2
%35 = load i32, i32* %3
%36 = add nsw i32 %35, 1
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %34, i64 %37
%39 = call i64 @strspn(i8* %38, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
store i64 %39, i64* %4
%40 = load i64, i64* %4
%41 = mul i64 1, %40
%42 = trunc i64 %41 to i32
%43 = call i8* @malloc(i32 %42)
store i8* %43, i8** %5
%44 = load i8*, i8** %5
%45 = load i8*, i8** %2
%46 = load i32, i32* %3
%47 = add nsw i32 %46, 1
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %45, i64 %48
%50 = load i64, i64* %4
%51 = call i32 @memcpy(i8* %44, i8* %49, i64 %50)
%52 = load i8*, i8** %5
%53 = call i32 @atoi(i8* %52)
ret i32 %53
}

LLVM IR (-O2):
@.str = [11 x i8] c"1234567890\00"
define i32 @getNumber(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %19
4: ; preds = %1, %15
%5 = phi i64 [ %9, %15 ], [ 0, %1 ]
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 34
%9 = add nuw nsw i64 %5, 1
br i1 %8, label %10, label %15
10: ; preds = %4
%11 = getelementptr inbounds i8, i8* %0, i64 %9
%12 = load i8, i8* %11
%13 = tail call i64 @isdigit(i8 signext %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %4, %10
%16 = tail call i32 @strlen(i8* %0)
%17 = sext i32 %16 to i64
%18 = icmp slt i64 %9, %17
br i1 %18, label %4, label %19
19: ; preds = %15, %10, %1
%20 = phi i64 [ 0, %1 ], [ %5, %10 ], [ %9, %15 ]
%21 = add i64 %20, 1
%22 = and i64 %21, 4294967295
%23 = getelementptr inbounds i8, i8* %0, i64 %22
%24 = tail call i64 @strspn(i8* %23, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%25 = trunc i64 %24 to i32
%26 = tail call i8* @malloc(i32 %25)
%27 = tail call i32 @memcpy(i8* %26, i8* %23, i64 %24)
%28 = tail call i32 @atoi(i8* %26)
ret i32 %28
}