#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(unsigned char *);
unsigned char *extractInt(unsigned char *ptr, int *i) {
  *i = 0;
  for (int k = (sizeof(int) * 8) - 1; k >= 0; k--) {
    int toExtract = atoi(ptr);
    int bit = toExtract & 0x01;
    bit = bit << k;
    *i |= bit;
    while (*ptr != ' ' && *ptr != '\n') {
      ptr += sizeof(char);
    }
    ptr += sizeof(char);
    if (*ptr == '\n')
      ptr += sizeof(char);
  }
  return ptr;
}


x86 assembly (clang, -O0):
<extractInt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x1f,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     11e7 <extractInt+0xd7>
mov    -0x8(%rbp),%rdi
call   1030 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
and    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x14(%rbp),%ecx
shl    %cl,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%ecx
mov    -0x10(%rbp),%rax
or     (%rax),%ecx
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
movzbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x20,%ecx
mov    %al,-0x1d(%rbp)
je     118b <extractInt+0x7b>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
cmp    $0xa,%eax
setne  %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    119b <extractInt+0x8b>
jmp    11ac <extractInt+0x9c>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1166 <extractInt+0x56>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
cmp    $0xa,%eax
jne    11d4 <extractInt+0xc4>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    11d9 <extractInt+0xc9>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1131 <extractInt+0x21>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extractInt>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
movl   $0x0,(%rsi)
mov    $0x1f,%ebp
xor    %eax,%eax
jmp    1140 <extractInt+0x30>
nopl   0x0(%rax)
cmpb   $0xa,(%rcx)
lea    0x1(%rcx),%rbx
cmovne %rcx,%rbx
sub    $0x1,%ebp
jb     1174 <extractInt+0x64>
mov    %eax,%r15d
mov    %rbx,%rdi
call   1030 <atoi@plt>
and    $0x1,%eax
mov    %ebp,%ecx
shl    %cl,%eax
or     %r15d,%eax
mov    %eax,(%r14)
add    $0x1,%rbx
mov    %rbx,%rcx
nop
movzbl -0x1(%rcx),%edx
cmp    $0xa,%dl
je     1130 <extractInt+0x20>
cmp    $0x20,%dl
je     1130 <extractInt+0x20>
add    $0x1,%rcx
jmp    1160 <extractInt+0x50>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i8* @extractInt(i8* %0, i32* nocapture %1) {
store i32 0, i32* %1
br label %4
3: ; preds = %17
ret i8* %22
4: ; preds = %2, %17
%5 = phi i32 [ 0, %2 ], [ %11, %17 ]
%6 = phi i8* [ %0, %2 ], [ %22, %17 ]
%7 = phi i32 [ 31, %2 ], [ %23, %17 ]
%8 = tail call i32 @atoi(i8* %6)
%9 = and i32 %8, 1
%10 = shl nuw i32 %9, %7
%11 = or i32 %10, %5
store i32 %11, i32* %1
br label %12
12: ; preds = %15, %4
%13 = phi i8* [ %6, %4 ], [ %16, %15 ]
%14 = load i8, i8* %13
switch i8 %14, label %15 [
i8 32, label %17
i8 10, label %17
]
15: ; preds = %12
%16 = getelementptr inbounds i8, i8* %13, i64 1
br label %12
17: ; preds = %12, %12
%18 = getelementptr inbounds i8, i8* %13, i64 1
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 10
%21 = getelementptr inbounds i8, i8* %13, i64 2
%22 = select i1 %20, i8* %21, i8* %18
%23 = add nsw i32 %7, -1
%24 = icmp eq i32 %7, 0
br i1 %24, label %3, label %4
}