#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 */
size_t EOF;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ free(char *);
size_t getline(char **, size_t *, int /*<<< orphan*/);
char *malloc(int);
int /*<<< orphan*/ perror(char *);
char *realloc(char *, size_t);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strcpy(char *, char *);
size_t strlen(char *);
int /*<<< orphan*/ toNatoPhonetic(char *);
void takeInputLine() {
  size_t read = 0, length = 0;
  char *inputLine = NULL, *manipulantLine = NULL;
  manipulantLine = malloc(128);
  if (manipulantLine == NULL) {
    perror("Memory Allocation Error");
    exit(1);
  }
  manipulantLine[0] = '\0';
  while ((read = getline(&inputLine, &length, stdin)) != EOF) {
    if (strlen(manipulantLine) < length) {
      manipulantLine = realloc(manipulantLine, length);
      if (manipulantLine == NULL) {
        perror("Memory Allocation Error");
        exit(1);
      }
    }
    strcpy(manipulantLine, inputLine);
    toNatoPhonetic(manipulantLine);
  }
  free(manipulantLine);
  free(inputLine);
}


x86 assembly (clang, -O0):
<takeInputLine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movq   $0x0,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    $0x80,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11e7 <takeInputLine+0x57>
lea    0xe28(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    0x2df3(%rip),%rax
mov    (%rax),%edx
lea    -0x18(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1090 <getline@plt>
mov    %rax,-0x8(%rbp)
mov    0x2dd1(%rip),%rcx
cmp    (%rcx),%rax
je     127d <takeInputLine+0xed>
mov    -0x20(%rbp),%rdi
call   1050 <strlen@plt>
cmp    -0x10(%rbp),%rax
jae    1262 <takeInputLine+0xd2>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1070 <realloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    125d <takeInputLine+0xcd>
lea    0xdb2(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
jmp    1262 <takeInputLine+0xd2>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x20(%rbp),%rdi
call   10b0 <toNatoPhonetic@plt>
jmp    11ee <takeInputLine+0x5e>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<takeInputLine>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
movq   $0x0,0x8(%rsp)
movq   $0x0,(%rsp)
mov    $0x80,%edi
call   1060 <malloc@plt>
test   %rax,%rax
je     126b <takeInputLine+0xdb>
mov    %rax,%rbx
movb   $0x0,(%rax)
mov    0x2e1a(%rip),%r12
mov    (%r12),%edx
mov    %rsp,%rdi
lea    0x8(%rsp),%rsi
call   1090 <getline@plt>
mov    0x2dfa(%rip),%r13
cmp    0x0(%r13),%rax
jne    120b <takeInputLine+0x7b>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
mov    %rsp,%r14
lea    0x8(%rsp),%r15
jmp    1249 <takeInputLine+0xb9>
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%rsp),%rsi
mov    %rbx,%rdi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
call   10b0 <toNatoPhonetic@plt>
mov    (%r12),%edx
mov    %r14,%rdi
mov    %r15,%rsi
call   1090 <getline@plt>
cmp    0x0(%r13),%rax
je     11ec <takeInputLine+0x5c>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    0x8(%rsp),%rsi
cmp    %rsi,%rax
jae    1220 <takeInputLine+0x90>
mov    %rbx,%rdi
call   1070 <realloc@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1220 <takeInputLine+0x90>
lea    0xd8e(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [24 x i8] c"Memory Allocation Error\00"
@stdin = global i32 0
@EOF = global i64 0
define void @takeInputLine() {
%1 = alloca i64
%2 = alloca i64
%3 = alloca i8*
%4 = alloca i8*
store i64 0, i64* %1
store i64 0, i64* %2
store i8* null, i8** %3
store i8* null, i8** %4
%5 = call i8* @malloc(i32 128)
store i8* %5, i8** %4
%6 = load i8*, i8** %4
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @exit(i32 1)
unreachable
11: ; preds = %0
%12 = load i8*, i8** %4
%13 = getelementptr inbounds i8, i8* %12, i64 0
store i8 0, i8* %13
br label %14
14: ; preds = %34, %11
%15 = load i32, i32* @stdin
%16 = call i64 @getline(i8** %3, i64* %2, i32 %15)
store i64 %16, i64* %1
%17 = load i64, i64* @EOF
%18 = icmp ne i64 %16, %17
br i1 %18, label %19, label %40
19: ; preds = %14
%20 = load i8*, i8** %4
%21 = call i64 @strlen(i8* %20)
%22 = load i64, i64* %2
%23 = icmp ult i64 %21, %22
br i1 %23, label %24, label %34
24: ; preds = %19
%25 = load i8*, i8** %4
%26 = load i64, i64* %2
%27 = call i8* @realloc(i8* %25, i64 %26)
store i8* %27, i8** %4
%28 = load i8*, i8** %4
%29 = icmp eq i8* %28, null
br i1 %29, label %30, label %33
30: ; preds = %24
%31 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%32 = call i32 @exit(i32 1)
unreachable
33: ; preds = %24
br label %34
34: ; preds = %33, %19
%35 = load i8*, i8** %4
%36 = load i8*, i8** %3
%37 = call i32 @strcpy(i8* %35, i8* %36)
%38 = load i8*, i8** %4
%39 = call i32 @toNatoPhonetic(i8* %38)
br label %14
40: ; preds = %14
%41 = load i8*, i8** %4
%42 = call i32 @free(i8* %41)
%43 = load i8*, i8** %3
%44 = call i32 @free(i8* %43)
ret void
}

LLVM IR (-O2):
@.str = [24 x i8] c"Memory Allocation Error\00"
@stdin = global i32 0
@EOF = global i64 0
define void @takeInputLine() {
%1 = alloca i64
%2 = alloca i8*
%3 = bitcast i64* %1 to i8*
store i64 0, i64* %1
%4 = bitcast i8** %2 to i8*
store i8* null, i8** %2
%5 = tail call dereferenceable_or_null(128) i8* @malloc(i32 128)
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %10
7: ; preds = %0
%8 = tail call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %0
store i8 0, i8* %5
%11 = load i32, i32* @stdin
%12 = call i64 @getline(i8** %2, i64* %1, i32 %11)
%13 = load i64, i64* @EOF
%14 = icmp eq i64 %12, %13
br i1 %14, label %35, label %15
15: ; preds = %10, %26
%16 = phi i8* [ %27, %26 ], [ %5, %10 ]
%17 = call i64 @strlen(i8* dereferenceable(1) %16)
%18 = load i64, i64* %1
%19 = icmp ult i64 %17, %18
br i1 %19, label %20, label %26
20: ; preds = %15
%21 = call i8* @realloc(i8* %16, i64 %18)
%22 = icmp eq i8* %21, null
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %20, %15
%27 = phi i8* [ %21, %20 ], [ %16, %15 ]
%28 = load i8*, i8** %2
%29 = call i32 @strcpy(i8* %27, i8* %28)
%30 = call i32 @toNatoPhonetic(i8* %27)
%31 = load i32, i32* @stdin
%32 = call i64 @getline(i8** %2, i64* %1, i32 %31)
%33 = load i64, i64* @EOF
%34 = icmp eq i64 %32, %33
br i1 %34, label %35, label %15
35: ; preds = %26, %10
%36 = phi i8* [ %5, %10 ], [ %27, %26 ]
%37 = call i32 @free(i8* %36)
%38 = load i8*, i8** %2
%39 = call i32 @free(i8* %38)
ret void
}