#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 */
char getchar();
int /*<<< orphan*/ printf(char *);
int i_input(char *p_input) {
  char c = '\0';
  int i;
  for (i = 0; i < 150; i++) {
    p_input[i] = getchar();
    if (p_input[i] == '\n') {
      return (0);
    }
  }
  printf("you have input long enough!\n");
  return (0);
}


x86 assembly (clang, -O0):
<i_input>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movb   $0x0,-0x11(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x96,-0x18(%rbp)
jge    118c <i_input+0x6c>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    1179 <i_input+0x59>
movl   $0x0,-0x4(%rbp)
jmp    119f <i_input+0x7f>
jmp    117e <i_input+0x5e>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1137 <i_input+0x17>
lea    0xe6d(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<i_input>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %ebx,%ebx
nopl   0x0(%rax)
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %al,(%r14,%rbx,1)
cmp    $0xa,%al
je     1158 <i_input+0x38>
add    $0x1,%rbx
cmp    $0x96,%rbx
jne    1130 <i_input+0x10>
lea    0xead(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [29 x i8] c"you have input long enough!\0A\00"
define i32 @i_input(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8
%5 = alloca i32
store i8* %0, i8** %3
store i8 0, i8* %4
store i32 0, i32* %5
br label %6
6: ; preds = %24, %1
%7 = load i32, i32* %5
%8 = icmp slt i32 %7, 150
br i1 %8, label %9, label %27
9: ; preds = %6
%10 = call signext i8 (...) @getchar()
%11 = load i8*, i8** %3
%12 = load i32, i32* %5
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %11, i64 %13
store i8 %10, i8* %14
%15 = load i8*, i8** %3
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 10
br i1 %21, label %22, label %23
22: ; preds = %9
store i32 0, i32* %2
br label %29
23: ; preds = %9
br label %24
24: ; preds = %23
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 1
store i32 %26, i32* %5
br label %6
27: ; preds = %6
%28 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
br label %29
29: ; preds = %27, %22
%30 = load i32, i32* %2
ret i32 %30
}

LLVM IR (-O2):
@str = [28 x i8] c"you have input long enough!\00"
define i32 @i_input(i8* nocapture writeonly %0) {
br label %5
2: ; preds = %5
%3 = add nuw nsw i64 %6, 1
%4 = icmp eq i64 %3, 150
br i1 %4, label %10, label %5
5: ; preds = %1, %2
%6 = phi i64 [ 0, %1 ], [ %3, %2 ]
%7 = tail call signext i8 (...) @getchar()
%8 = getelementptr inbounds i8, i8* %0, i64 %6
store i8 %7, i8* %8
%9 = icmp eq i8 %7, 10
br i1 %9, label %12, label %2
10: ; preds = %2
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
br label %12
12: ; preds = %5, %10
ret i32 0
}