#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 uint32_t;

/* Variables and functions */
char EOF;
int EXIT_SUCCESS;
char getchar();
int htoi(char *);
int /*<<< orphan*/ isspace(char);
int /*<<< orphan*/ printf(char *, int);
char *realloc(char *, int);
int main(void) {
  char *buffer = NULL;
  uint32_t buffer_length = 0;
  char character = 0;
  while ((character = getchar()) != EOF) {
    if (!(isspace(character))) {
      buffer = realloc(buffer, ++buffer_length * sizeof(char));
      buffer[buffer_length - 1] = character;
    }
  }
  buffer = realloc(buffer, ++buffer_length * sizeof(char));
  buffer[buffer_length - 1] = '\0';
  printf("%d\n", htoi(buffer));
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movb   $0x0,-0x15(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x15(%rbp)
movsbl %al,%eax
mov    0x2e62(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11d9 <main+0x89>
movsbl -0x15(%rbp),%edi
call   1040 <isspace@plt>
cmp    $0x0,%eax
jne    11d4 <main+0x84>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
cltq
shl    $0x0,%rax
mov    %eax,%esi
call   1070 <realloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x15(%rbp),%dl
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
jmp    1172 <main+0x22>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
cltq
shl    $0x0,%rax
mov    %eax,%esi
call   1070 <realloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rdi
call   1060 <htoi@plt>
mov    %eax,%esi
lea    0xde6(%rip),%rdi
call   1030 <printf@plt>
mov    0x2db2(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %r15d,%r15d
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e7f(%rip),%r12
cmp    (%r12),%al
jne    11ad <main+0x5d>
xor    %r14d,%r14d
lea    0x1(%r15),%esi
mov    %r14,%rdi
call   1070 <realloc@plt>
movslq %r15d,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    %rax,%rdi
call   1060 <htoi@plt>
lea    0xe6c(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    0x2e36(%rip),%rax
mov    (%rax),%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebx
xor    %r15d,%r15d
xor    %r14d,%r14d
jmp    11cf <main+0x7f>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebx
cmp    (%r12),%al
je     1172 <main+0x22>
movsbl %bl,%edi
call   1040 <isspace@plt>
test   %eax,%eax
jne    11c0 <main+0x70>
lea    0x1(%r15),%ebp
mov    %r14,%rdi
mov    %ebp,%esi
call   1070 <realloc@plt>
mov    %rax,%r14
movslq %r15d,%rax
mov    %bl,(%r14,%rax,1)
mov    %ebp,%r15d
jmp    11c0 <main+0x70>

LLVM IR (-O0):
@EOF = global i8 0
@.str = [4 x i8] c"%d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8
store i32 0, i32* %1
store i8* null, i8** %2
store i32 0, i32* %3
store i8 0, i8* %4
br label %5
5: ; preds = %29, %0
%6 = call signext i8 (...) @getchar()
store i8 %6, i8* %4
%7 = sext i8 %6 to i32
%8 = load i8, i8* @EOF
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %7, %9
br i1 %10, label %11, label %30
11: ; preds = %5
%12 = load i8, i8* %4
%13 = call i32 @isspace(i8 signext %12)
%14 = icmp ne i32 %13, 0
br i1 %14, label %29, label %15
15: ; preds = %11
%16 = load i8*, i8** %2
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 1
store i32 %18, i32* %3
%19 = sext i32 %18 to i64
%20 = mul i64 %19, 1
%21 = trunc i64 %20 to i32
%22 = call i8* @realloc(i8* %16, i32 %21)
store i8* %22, i8** %2
%23 = load i8, i8* %4
%24 = load i8*, i8** %2
%25 = load i32, i32* %3
%26 = sub nsw i32 %25, 1
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %24, i64 %27
store i8 %23, i8* %28
br label %29
29: ; preds = %15, %11
br label %5
30: ; preds = %5
%31 = load i8*, i8** %2
%32 = load i32, i32* %3
%33 = add nsw i32 %32, 1
store i32 %33, i32* %3
%34 = sext i32 %33 to i64
%35 = mul i64 %34, 1
%36 = trunc i64 %35 to i32
%37 = call i8* @realloc(i8* %31, i32 %36)
store i8* %37, i8** %2
%38 = load i8*, i8** %2
%39 = load i32, i32* %3
%40 = sub nsw i32 %39, 1
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %38, i64 %41
store i8 0, i8* %42
%43 = load i8*, i8** %2
%44 = call i32 @htoi(i8* %43)
%45 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %44)
%46 = load i32, i32* @EXIT_SUCCESS
ret i32 %46
}

LLVM IR (-O2):
@EOF = global i8 0
@.str = [4 x i8] c"%d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = tail call signext i8 (...) @getchar()
%2 = load i8, i8* @EOF
%3 = icmp eq i8 %1, %2
br i1 %3, label %21, label %4
4: ; preds = %0, %15
%5 = phi i8 [ %18, %15 ], [ %1, %0 ]
%6 = phi i32 [ %17, %15 ], [ 0, %0 ]
%7 = phi i8* [ %16, %15 ], [ null, %0 ]
%8 = tail call i32 @isspace(i8 signext %5)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %4
%11 = add nsw i32 %6, 1
%12 = tail call i8* @realloc(i8* %7, i32 %11)
%13 = sext i32 %6 to i64
%14 = getelementptr inbounds i8, i8* %12, i64 %13
store i8 %5, i8* %14
br label %15
15: ; preds = %10, %4
%16 = phi i8* [ %7, %4 ], [ %12, %10 ]
%17 = phi i32 [ %6, %4 ], [ %11, %10 ]
%18 = tail call signext i8 (...) @getchar()
%19 = load i8, i8* @EOF
%20 = icmp eq i8 %18, %19
br i1 %20, label %21, label %4
21: ; preds = %15, %0
%22 = phi i8* [ null, %0 ], [ %16, %15 ]
%23 = phi i32 [ 0, %0 ], [ %17, %15 ]
%24 = add nsw i32 %23, 1
%25 = tail call i8* @realloc(i8* %22, i32 %24)
%26 = sext i32 %23 to i64
%27 = getelementptr inbounds i8, i8* %25, i64 %26
store i8 0, i8* %27
%28 = tail call i32 @htoi(i8* %25)
%29 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %28)
%30 = load i32, i32* @EXIT_SUCCESS
ret i32 %30
}