#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 EOF;
int fgetc(int /*<<< orphan*/);
char *malloc(int);
char *realloc(char *, size_t);
int /*<<< orphan*/ stdin;
const char *getInput() {
  char *buffer = malloc(24 * sizeof(char));
  int input;
  size_t inputLength = 0;
  size_t bufferSize = 24;
  if (buffer == NULL) {
    return buffer;
  }
  input = fgetc(stdin);
  while (input != EOF && (char)input != '\n') {
    if (inputLength >= bufferSize) {
      bufferSize = bufferSize * 1.5f;
      buffer = realloc(buffer, bufferSize * sizeof(*buffer));
    }
    buffer[inputLength] = (char)input;
    inputLength++;
    input = fgetc(stdin);
  }
  buffer[inputLength] = '\0';
  return buffer;
}


x86 assembly (clang, -O0):
<getInput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    $0x18,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x18,-0x28(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    116e <getInput+0x3e>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1296 <getInput+0x166>
mov    0x2e73(%rip),%rax
mov    (%rax),%edi
call   1030 <fgetc@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%ecx
xor    %eax,%eax
mov    0x2e55(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0x29(%rbp)
je     11a5 <getInput+0x75>
mov    -0x14(%rbp),%eax
movsbl %al,%eax
cmp    $0xa,%eax
setne  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    11b5 <getInput+0x85>
jmp    1282 <getInput+0x152>
mov    -0x20(%rbp),%rax
cmp    -0x28(%rbp),%rax
jb     1250 <getInput+0x120>
mov    -0x28(%rbp),%rax
mov    %rax,%rdx
shr    %rdx
mov    %eax,%ecx
and    $0x1,%ecx
or     %rdx,%rcx
cvtsi2ss %rcx,%xmm0
addss  %xmm0,%xmm0
cvtsi2ss %rax,%xmm1
movss  %xmm1,-0x34(%rbp)
test   %rax,%rax
movss  %xmm0,-0x30(%rbp)
js     1200 <getInput+0xd0>
movss  -0x34(%rbp),%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0x30(%rbp),%xmm0
movss  0xdf3(%rip),%xmm1
mulss  %xmm1,%xmm0
movaps %xmm0,%xmm1
cvttss2si %xmm1,%rax
mov    %rax,%rdx
sar    $0x3f,%rdx
movss  0xddc(%rip),%xmm1
subss  %xmm1,%xmm0
cvttss2si %xmm0,%rcx
and    %rdx,%rcx
or     %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
shl    $0x0,%rsi
call   1050 <realloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    0x2d75(%rip),%rax
mov    (%rax),%edi
call   1030 <fgetc@plt>
mov    %eax,-0x14(%rbp)
jmp    117f <getInput+0x4f>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getInput>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x18,%edi
call   1040 <malloc@plt>
test   %rax,%rax
je     1228 <getInput+0xf8>
mov    %rax,%r14
mov    0x2e90(%rip),%r12
mov    (%r12),%edi
call   1030 <fgetc@plt>
mov    %eax,%r15d
xor    %ebp,%ebp
cmp    $0xa,%r15b
je     1221 <getInput+0xf1>
mov    0x2e69(%rip),%r13
cmp    0x0(%r13),%r15d
je     1221 <getInput+0xf1>
mov    $0x18,%ebx
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
cmp    %rbx,%rbp
jb     11fd <getInput+0xcd>
test   %rbx,%rbx
js     11b0 <getInput+0x80>
xorps  %xmm0,%xmm0
cvtsi2ss %rbx,%xmm0
jmp    11c8 <getInput+0x98>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rax
shr    %rax
and    $0x1,%ebx
or     %rax,%rbx
xorps  %xmm0,%xmm0
cvtsi2ss %rbx,%xmm0
addss  %xmm0,%xmm0
mulss  0xe30(%rip),%xmm0
cvttss2si %xmm0,%rax
mov    %rax,%rcx
sar    $0x3f,%rcx
subss  0xe20(%rip),%xmm0
cvttss2si %xmm0,%rbx
and    %rcx,%rbx
or     %rax,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <realloc@plt>
mov    %rax,%r14
mov    %r15b,(%r14,%rbp,1)
add    $0x1,%rbp
mov    (%r12),%edi
call   1030 <fgetc@plt>
mov    %eax,%r15d
cmp    $0xa,%r15b
je     1221 <getInput+0xf1>
cmp    0x0(%r13),%r15d
jne    1190 <getInput+0x60>
movb   $0x0,(%r14,%rbp,1)
jmp    122b <getInput+0xfb>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32 0
@EOF = global i32 0
define i8* @getInput() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i64
%5 = alloca i64
%6 = call i8* @malloc(i32 24)
store i8* %6, i8** %2
store i64 0, i64* %4
store i64 24, i64* %5
%7 = load i8*, i8** %2
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = load i8*, i8** %2
store i8* %10, i8** %1
br label %53
11: ; preds = %0
%12 = load i32, i32* @stdin
%13 = call i32 @fgetc(i32 %12)
store i32 %13, i32* %3
br label %14
14: ; preds = %38, %11
%15 = load i32, i32* %3
%16 = load i32, i32* @EOF
%17 = icmp ne i32 %15, %16
br i1 %17, label %18, label %23
18: ; preds = %14
%19 = load i32, i32* %3
%20 = trunc i32 %19 to i8
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %21, 10
br label %23
23: ; preds = %18, %14
%24 = phi i1 [ false, %14 ], [ %22, %18 ]
br i1 %24, label %25, label %48
25: ; preds = %23
%26 = load i64, i64* %4
%27 = load i64, i64* %5
%28 = icmp uge i64 %26, %27
br i1 %28, label %29, label %38
29: ; preds = %25
%30 = load i64, i64* %5
%31 = uitofp i64 %30 to float
%32 = fmul float %31, 1.500000e+00
%33 = fptoui float %32 to i64
store i64 %33, i64* %5
%34 = load i8*, i8** %2
%35 = load i64, i64* %5
%36 = mul i64 %35, 1
%37 = call i8* @realloc(i8* %34, i64 %36)
store i8* %37, i8** %2
br label %38
38: ; preds = %29, %25
%39 = load i32, i32* %3
%40 = trunc i32 %39 to i8
%41 = load i8*, i8** %2
%42 = load i64, i64* %4
%43 = getelementptr inbounds i8, i8* %41, i64 %42
store i8 %40, i8* %43
%44 = load i64, i64* %4
%45 = add i64 %44, 1
store i64 %45, i64* %4
%46 = load i32, i32* @stdin
%47 = call i32 @fgetc(i32 %46)
store i32 %47, i32* %3
br label %14
48: ; preds = %23
%49 = load i8*, i8** %2
%50 = load i64, i64* %4
%51 = getelementptr inbounds i8, i8* %49, i64 %50
store i8 0, i8* %51
%52 = load i8*, i8** %2
store i8* %52, i8** %1
br label %53
53: ; preds = %48, %9
%54 = load i8*, i8** %1
ret i8* %54
}

LLVM IR (-O2):
@stdin = global i32 0
@EOF = global i32 0
define noalias i8* @getInput() {
%1 = tail call dereferenceable_or_null(24) i8* @malloc(i32 24)
%2 = icmp eq i8* %1, null
br i1 %2, label %39, label %3
3: ; preds = %0
%4 = load i32, i32* @stdin
%5 = tail call i32 @fgetc(i32 %4)
%6 = load i32, i32* @EOF
%7 = icmp ne i32 %5, %6
%8 = and i32 %5, 255
%9 = icmp ne i32 %8, 10
%10 = and i1 %9, %7
br i1 %10, label %11, label %35
11: ; preds = %3, %23
%12 = phi i32 [ %29, %23 ], [ %5, %3 ]
%13 = phi i64 [ %25, %23 ], [ 24, %3 ]
%14 = phi i64 [ %27, %23 ], [ 0, %3 ]
%15 = phi i8* [ %24, %23 ], [ %1, %3 ]
%16 = trunc i32 %12 to i8
%17 = icmp ult i64 %14, %13
br i1 %17, label %23, label %18
18: ; preds = %11
%19 = uitofp i64 %13 to float
%20 = fmul float %19, 1.500000e+00
%21 = fptoui float %20 to i64
%22 = tail call i8* @realloc(i8* %15, i64 %21)
br label %23
23: ; preds = %18, %11
%24 = phi i8* [ %22, %18 ], [ %15, %11 ]
%25 = phi i64 [ %21, %18 ], [ %13, %11 ]
%26 = getelementptr inbounds i8, i8* %24, i64 %14
store i8 %16, i8* %26
%27 = add i64 %14, 1
%28 = load i32, i32* @stdin
%29 = tail call i32 @fgetc(i32 %28)
%30 = load i32, i32* @EOF
%31 = icmp ne i32 %29, %30
%32 = and i32 %29, 255
%33 = icmp ne i32 %32, 10
%34 = and i1 %33, %31
br i1 %34, label %11, label %35
35: ; preds = %23, %3
%36 = phi i8* [ %1, %3 ], [ %24, %23 ]
%37 = phi i64 [ 0, %3 ], [ %27, %23 ]
%38 = getelementptr inbounds i8, i8* %36, i64 %37
store i8 0, i8* %38
br label %39
39: ; preds = %0, %35
%40 = phi i8* [ %36, %35 ], [ null, %0 ]
ret i8* %40
}