#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*/ free(char *);
int getline(char **, int *, int /*<<< orphan*/);
int /*<<< orphan*/ htoi(char *);
int /*<<< orphan*/ printf(char *, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int main() {
  char *str = NULL;
  int len;
  while (getline(&str, &len, stdin) != -1) {
    printf("%ld\n", htoi(str));
  }
  free(str);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
mov    0x2e8a(%rip),%rax
mov    (%rax),%edx
lea    -0x10(%rbp),%rdi
lea    -0x14(%rbp),%rsi
call   1060 <getline@plt>
cmp    $0xffffffff,%eax
je     1192 <main+0x52>
mov    -0x10(%rbp),%rdi
call   1050 <htoi@plt>
mov    %eax,%esi
lea    0xe78(%rip),%rdi
call   1040 <printf@plt>
jmp    1157 <main+0x17>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
movq   $0x0,0x8(%rsp)
mov    0x2e8d(%rip),%r12
mov    (%r12),%edx
lea    0x8(%rsp),%rdi
lea    0x14(%rsp),%rsi
call   1060 <getline@plt>
cmp    $0xffffffff,%eax
je     11b8 <main+0x78>
lea    0xe86(%rip),%r14
lea    0x8(%rsp),%r15
lea    0x14(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x8(%rsp),%rdi
call   1050 <htoi@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    (%r12),%edx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <getline@plt>
cmp    $0xffffffff,%eax
jne    1190 <main+0x50>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [5 x i8] c"%ld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
store i32 0, i32* %1
store i8* null, i8** %2
br label %4
4: ; preds = %8, %0
%5 = load i32, i32* @stdin
%6 = call i32 @getline(i8** %2, i32* %3, i32 %5)
%7 = icmp ne i32 %6, -1
br i1 %7, label %8, label %12
8: ; preds = %4
%9 = load i8*, i8** %2
%10 = call i32 @htoi(i8* %9)
%11 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %10)
br label %4
12: ; preds = %4
%13 = load i8*, i8** %2
%14 = call i32 @free(i8* %13)
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [5 x i8] c"%ld\0A\00"
define i32 @main() {
%1 = alloca i8*
%2 = alloca i32
%3 = bitcast i8** %1 to i8*
store i8* null, i8** %1
%4 = bitcast i32* %2 to i8*
%5 = load i32, i32* @stdin
%6 = call i32 @getline(i8** %1, i32* %2, i32 %5)
%7 = icmp eq i32 %6, -1
br i1 %7, label %15, label %8
8: ; preds = %0, %8
%9 = load i8*, i8** %1
%10 = call i32 @htoi(i8* %9)
%11 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = load i32, i32* @stdin
%13 = call i32 @getline(i8** %1, i32* %2, i32 %12)
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %8
15: ; preds = %8, %0
%16 = load i8*, i8** %1
%17 = call i32 @free(i8* %16)
ret i32 0
}