#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__ calloc(int, size_t);
int /*<<< orphan*/ free(char *);
int getline(char **, size_t *, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
char *getInput(void) {
  size_t len = 100;
  char *buf;
  int bcount = 0;
  buf = (char *)calloc(1, len + 1);
  bcount = getline(&buf, &len, stdin);
  if (bcount < 0) {
    free(buf);
    return NULL;
  } else {
  }
  return buf;
}


x86 assembly (clang, -O0):
<getInput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movq   $0x64,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rsi
add    $0x1,%rsi
mov    $0x1,%edi
call   1040 <calloc@plt>
mov    %rax,-0x18(%rbp)
mov    0x2e84(%rip),%rax
mov    (%rax),%edx
lea    -0x18(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <getline@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    1196 <getInput+0x66>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    11a3 <getInput+0x73>
jmp    119b <getInput+0x6b>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getInput>:
sub    $0x18,%rsp
movq   $0x64,0x10(%rsp)
mov    $0x65,%esi
mov    $0x1,%edi
call   1040 <calloc@plt>
mov    %rax,0x8(%rsp)
mov    0x2e90(%rip),%rax
mov    (%rax),%edx
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1050 <getline@plt>
mov    %eax,%ecx
mov    0x8(%rsp),%rax
test   %ecx,%ecx
js     1179 <getInput+0x49>
add    $0x18,%rsp
ret
mov    %rax,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@stdin = global i32 0
define i8* @getInput() {
%1 = alloca i8*
%2 = alloca i64
%3 = alloca i8*
%4 = alloca i32
store i64 100, i64* %2
store i32 0, i32* %4
%5 = load i64, i64* %2
%6 = add i64 %5, 1
%7 = call i64 @calloc(i32 1, i64 %6)
%8 = inttoptr i64 %7 to i8*
store i8* %8, i8** %3
%9 = load i32, i32* @stdin
%10 = call i32 @getline(i8** %3, i64* %2, i32 %9)
store i32 %10, i32* %4
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %0
%14 = load i8*, i8** %3
%15 = call i32 @free(i8* %14)
store i8* null, i8** %1
br label %19
16: ; preds = %0
br label %17
17: ; preds = %16
%18 = load i8*, i8** %3
store i8* %18, i8** %1
br label %19
19: ; preds = %17, %13
%20 = load i8*, i8** %1
ret i8* %20
}

LLVM IR (-O2):
@stdin = global i32 0
define i8* @getInput() {
%1 = alloca i64
%2 = alloca i8*
%3 = bitcast i64* %1 to i8*
store i64 100, i64* %1
%4 = bitcast i8** %2 to i8*
%5 = tail call i64 @calloc(i32 1, i64 101)
%6 = inttoptr i64 %5 to i8*
store i8* %6, i8** %2
%7 = load i32, i32* @stdin
%8 = call i32 @getline(i8** %2, i64* %1, i32 %7)
%9 = icmp slt i32 %8, 0
%10 = load i8*, i8** %2
br i1 %9, label %11, label %13
11: ; preds = %0
%12 = call i32 @free(i8* %10)
br label %13
13: ; preds = %0, %11
%14 = phi i8* [ null, %11 ], [ %10, %0 ]
ret i8* %14
}