#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 getchar();
int /*<<< orphan*/ printf(char *, ...);
char putchar(int);
int main(void) {
  int input[30], output[30];
  int i = 0;
  printf("Input %d chars please:\n", 30);
  while (i != 30) {
    input[i] = getchar();
    if (input[i] == '\n') {
      break;
    }
    i++;
  }
  if (i == 30) {
    input[30 - 1] = '\n';
    printf("Your input is full\n");
  }
  i = 0;
  while (i != 30 && putchar(input[i]) != '\n')
    i++;
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x104(%rbp)
lea    0xead(%rip),%rdi
mov    $0x1e,%esi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x1e,-0x104(%rbp)
je     11ab <main+0x7b>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,%ecx
movslq -0x104(%rbp),%rax
mov    %ecx,-0x80(%rbp,%rax,4)
movslq -0x104(%rbp),%rax
cmpl   $0xa,-0x80(%rbp,%rax,4)
jne    1197 <main+0x67>
jmp    11ab <main+0x7b>
mov    -0x104(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x104(%rbp)
jmp    115f <main+0x2f>
cmpl   $0x1e,-0x104(%rbp)
jne    11cd <main+0x9d>
movl   $0xa,-0xc(%rbp)
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x104(%rbp)
xor    %eax,%eax
cmpl   $0x1e,-0x104(%rbp)
mov    %al,-0x105(%rbp)
je     120b <main+0xdb>
movslq -0x104(%rbp),%rax
mov    -0x80(%rbp,%rax,4),%edi
call   1030 <putchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
setne  %al
mov    %al,-0x105(%rbp)
mov    -0x105(%rbp),%al
test   $0x1,%al
jne    121e <main+0xee>
jmp    1232 <main+0x102>
mov    -0x104(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x104(%rbp)
jmp    11d7 <main+0xa7>
xor    %eax,%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x80,%rsp
lea    0xeb1(%rip),%rdi
mov    $0x1e,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %ebx,%ebx
nopl   (%rax)
xor    %eax,%eax
call   1060 <getchar@plt>
mov    %eax,(%rsp,%rbx,4)
cmp    $0xa,%eax
je     118d <main+0x4d>
add    $0x1,%rbx
cmp    $0x1e,%rbx
jne    1160 <main+0x20>
movl   $0xa,0x74(%rsp)
lea    0xe90(%rip),%rdi
call   1040 <puts@plt>
xor    %ebx,%ebx
nop
mov    (%rsp,%rbx,4),%edi
call   1030 <putchar@plt>
cmp    $0xa,%al
je     11a9 <main+0x69>
lea    0x1(%rbx),%rax
cmp    $0x1d,%rbx
mov    %rax,%rbx
jne    1190 <main+0x50>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [24 x i8] c"Input %d chars please:\0A\00"
@.str.1 = [20 x i8] c"Your input is full\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [30 x i32]
%3 = alloca [30 x i32]
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 30)
br label %6
6: ; preds = %20, %0
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 30
br i1 %8, label %9, label %23
9: ; preds = %6
%10 = call i32 (...) @getchar()
%11 = load i32, i32* %4
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [30 x i32], [30 x i32]* %2, i64 0, i64 %12
store i32 %10, i32* %13
%14 = load i32, i32* %4
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [30 x i32], [30 x i32]* %2, i64 0, i64 %15
%17 = load i32, i32* %16
%18 = icmp eq i32 %17, 10
br i1 %18, label %19, label %20
19: ; preds = %9
br label %23
20: ; preds = %9
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %6
23: ; preds = %19, %6
%24 = load i32, i32* %4
%25 = icmp eq i32 %24, 30
br i1 %25, label %26, label %29
26: ; preds = %23
%27 = getelementptr inbounds [30 x i32], [30 x i32]* %2, i64 0, i64 29
store i32 10, i32* %27
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %29
29: ; preds = %26, %23
store i32 0, i32* %4
br label %30
30: ; preds = %43, %29
%31 = load i32, i32* %4
%32 = icmp ne i32 %31, 30
br i1 %32, label %33, label %41
33: ; preds = %30
%34 = load i32, i32* %4
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [30 x i32], [30 x i32]* %2, i64 0, i64 %35
%37 = load i32, i32* %36
%38 = call signext i8 @putchar(i32 %37)
%39 = sext i8 %38 to i32
%40 = icmp ne i32 %39, 10
br label %41
41: ; preds = %33, %30
%42 = phi i1 [ false, %30 ], [ %40, %33 ]
br i1 %42, label %43, label %46
43: ; preds = %41
%44 = load i32, i32* %4
%45 = add nsw i32 %44, 1
store i32 %45, i32* %4
br label %30
46: ; preds = %41
ret i32 0
}

LLVM IR (-O2):
@.str = [24 x i8] c"Input %d chars please:\0A\00"
@str = [19 x i8] c"Your input is full\00"
define i32 @main() {
%1 = alloca [30 x i32]
%2 = bitcast [30 x i32]* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 30)
br label %6
4: ; preds = %6
%5 = icmp eq i64 %11, 30
br i1 %5, label %12, label %6
6: ; preds = %0, %4
%7 = phi i64 [ 0, %0 ], [ %11, %4 ]
%8 = tail call i32 (...) @getchar()
%9 = getelementptr inbounds [30 x i32], [30 x i32]* %1, i64 0, i64 %7
store i32 %8, i32* %9
%10 = icmp eq i32 %8, 10
%11 = add nuw nsw i64 %7, 1
br i1 %10, label %15, label %4
12: ; preds = %4
%13 = getelementptr inbounds [30 x i32], [30 x i32]* %1, i64 0, i64 29
store i32 10, i32* %13
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
br label %15
15: ; preds = %6, %12
br label %16
16: ; preds = %15, %16
%17 = phi i64 [ %22, %16 ], [ 0, %15 ]
%18 = getelementptr inbounds [30 x i32], [30 x i32]* %1, i64 0, i64 %17
%19 = load i32, i32* %18
%20 = tail call signext i8 @putchar(i32 %19)
%21 = icmp eq i8 %20, 10
%22 = add nuw nsw i64 %17, 1
%23 = icmp eq i64 %22, 30
%24 = select i1 %21, i1 true, i1 %23
br i1 %24, label %25, label %16
25: ; preds = %16
ret i32 0
}