#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*/ putc(char);
void getInput(char input[10000]) {
  int ph = 0;
  char temp = *(char *)0xfffffffe;
  if (temp != '\n' && temp != '\r') {
    input[ph] = temp;
    putc(input[ph]);
  } else {
    input[ph] = *(char *)0xfffffffe;
    putc(input[ph]);
  }
  while (input[ph] != 13) {
    ph++;
    input[ph] = *(char *)0xfffffffe;
    putc(input[ph]);
  }
  input[ph] = 0;
  return;
}


x86 assembly (clang, -O0):
<getInput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0xfffffffe,%eax
mov    (%rax),%al
mov    %al,-0xd(%rbp)
movsbl -0xd(%rbp),%eax
cmp    $0xa,%eax
je     116b <getInput+0x5b>
movsbl -0xd(%rbp),%eax
cmp    $0xd,%eax
je     116b <getInput+0x5b>
mov    -0xd(%rbp),%dl
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <putc@plt>
jmp    118e <getInput+0x7e>
mov    $0xfffffffe,%eax
mov    (%rax),%dl
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <putc@plt>
jmp    1193 <getInput+0x83>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xd,%eax
je     11d9 <getInput+0xc9>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    $0xfffffffe,%eax
mov    (%rax),%dl
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <putc@plt>
jmp    1193 <getInput+0x83>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getInput>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r15
mov    $0xfffffffe,%r14d
movsbl (%r14),%edi
mov    %dil,(%r15)
call   1030 <putc@plt>
cmpb   $0xd,(%r15)
jne    1137 <getInput+0x27>
xor    %eax,%eax
jmp    1160 <getInput+0x50>
xor    %r12d,%r12d
nopw   0x0(%rax,%rax,1)
mov    %r12,%rbx
add    $0x1,%r12
movsbl (%r14),%edi
mov    %dil,0x1(%r15,%rbx,1)
call   1030 <putc@plt>
cmpb   $0xd,0x1(%r15,%rbx,1)
jne    1140 <getInput+0x30>
mov    %r12d,%eax
movb   $0x0,(%r15,%rax,1)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @getInput(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8
store i8* %0, i8** %2
store i32 0, i32* %3
%5 = load i8, i8* inttoptr (i64 4294967294 to i8*)
store i8 %5, i8* %4
%6 = load i8, i8* %4
%7 = sext i8 %6 to i32
%8 = icmp ne i32 %7, 10
br i1 %8, label %9, label %25
9: ; preds = %1
%10 = load i8, i8* %4
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 13
br i1 %12, label %13, label %25
13: ; preds = %9
%14 = load i8, i8* %4
%15 = load i8*, i8** %2
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
store i8 %14, i8* %18
%19 = load i8*, i8** %2
%20 = load i32, i32* %3
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = load i8, i8* %22
%24 = call i32 @putc(i8 signext %23)
br label %37
25: ; preds = %9, %1
%26 = load i8, i8* inttoptr (i64 4294967294 to i8*)
%27 = load i8*, i8** %2
%28 = load i32, i32* %3
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
store i8 %26, i8* %30
%31 = load i8*, i8** %2
%32 = load i32, i32* %3
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
%35 = load i8, i8* %34
%36 = call i32 @putc(i8 signext %35)
br label %37
37: ; preds = %25, %13
br label %38
38: ; preds = %46, %37
%39 = load i8*, i8** %2
%40 = load i32, i32* %3
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %39, i64 %41
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp ne i32 %44, 13
br i1 %45, label %46, label %60
46: ; preds = %38
%47 = load i32, i32* %3
%48 = add nsw i32 %47, 1
store i32 %48, i32* %3
%49 = load i8, i8* inttoptr (i64 4294967294 to i8*)
%50 = load i8*, i8** %2
%51 = load i32, i32* %3
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %50, i64 %52
store i8 %49, i8* %53
%54 = load i8*, i8** %2
%55 = load i32, i32* %3
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8, i8* %54, i64 %56
%58 = load i8, i8* %57
%59 = call i32 @putc(i8 signext %58)
br label %38
60: ; preds = %38
%61 = load i8*, i8** %2
%62 = load i32, i32* %3
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i8, i8* %61, i64 %63
store i8 0, i8* %64
ret void
}

LLVM IR (-O2):
define void @getInput(i8* nocapture %0) {
%2 = load i8, i8* inttoptr (i64 4294967294 to i8*)
store i8 %2, i8* %0
%3 = tail call i32 @putc(i8 signext %2)
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 13
br i1 %5, label %16, label %6
6: ; preds = %1, %6
%7 = phi i64 [ %8, %6 ], [ 0, %1 ]
%8 = add nuw nsw i64 %7, 1
%9 = load i8, i8* inttoptr (i64 4294967294 to i8*)
%10 = getelementptr inbounds i8, i8* %0, i64 %8
store i8 %9, i8* %10
%11 = tail call i32 @putc(i8 signext %9)
%12 = load i8, i8* %10
%13 = icmp eq i8 %12, 13
br i1 %13, label %14, label %6
14: ; preds = %6
%15 = and i64 %8, 4294967295
br label %16
16: ; preds = %14, %1
%17 = phi i64 [ 0, %1 ], [ %15, %14 ]
%18 = getelementptr inbounds i8, i8* %0, i64 %17
store i8 0, i8* %18
ret void
}