#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 getline(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int nn;
  int i = 0, j, k;
  char line[1000];
  char saveline[1000][1000];
  while ((nn = getline(line, 1000)) > 0) {
    if (i < 1000) {
      for (j = 0; j < 1000; j++) {
        saveline[i][j] = line[j];
      }
      i++;
    }
  }
  printf("The new line is:\n");
  for (k = 0; k < i; k++) {
    printf("%s", saveline[k]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf4640,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x400(%rbp),%rdi
mov    $0x3e8,%esi
call   1040 <getline@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    11ba <main+0x9a>
cmpl   $0x3e8,-0xc(%rbp)
jge    11b5 <main+0x95>
movl   $0x0,-0x10(%rbp)
cmpl   $0x3e8,-0x10(%rbp)
jge    11ac <main+0x8c>
movslq -0x10(%rbp),%rax
mov    -0x400(%rbp,%rax,1),%dl
movslq -0xc(%rbp),%rcx
lea    -0xf4640(%rbp),%rax
imul   $0x3e8,%rcx,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    116a <main+0x4a>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1139 <main+0x19>
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    120c <main+0xec>
movslq -0x14(%rbp),%rax
lea    -0xf4640(%rbp),%rsi
imul   $0x3e8,%rax,%rax
add    %rax,%rsi
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11cf <main+0xaf>
xor    %eax,%eax
add    $0xf4640,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0xf4630,%rsp
mov    %rsp,%rdi
mov    $0x3e8,%esi
call   1060 <getline@plt>
test   %eax,%eax
jle    11fc <main+0xbc>
xor    %ebp,%ebp
mov    %rsp,%rbx
jmp    1181 <main+0x41>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x3e8,%esi
call   1060 <getline@plt>
test   %eax,%eax
jle    11b0 <main+0x70>
cmp    $0x3e7,%ebp
jg     1170 <main+0x30>
movslq %ebp,%rax
imul   $0x3e8,%rax,%rax
lea    (%rsp,%rax,1),%rdi
add    $0x3f0,%rdi
mov    $0x3e8,%edx
mov    %rbx,%rsi
call   1050 <memcpy@plt>
add    $0x1,%ebp
jmp    1170 <main+0x30>
lea    0xe4c(%rip),%rdi
call   1030 <puts@plt>
test   %ebp,%ebp
jle    1208 <main+0xc8>
mov    %ebp,%ebp
lea    0x3f0(%rsp),%rbx
lea    0xe2f(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x3e8,%rbx
add    $0xffffffffffffffff,%rbp
jne    11e0 <main+0xa0>
jmp    1208 <main+0xc8>
lea    0xe00(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0xf4630,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"The new line is:\0A\00"
@.str.1 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [1000 x i8]
%7 = alloca [1000 x [1000 x i8]]
store i32 0, i32* %1
store i32 0, i32* %3
br label %8
8: ; preds = %36, %0
%9 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%10 = call i32 @getline(i8* %9, i32 1000)
store i32 %10, i32* %2
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %37
12: ; preds = %8
%13 = load i32, i32* %3
%14 = icmp slt i32 %13, 1000
br i1 %14, label %15, label %36
15: ; preds = %12
store i32 0, i32* %4
br label %16
16: ; preds = %30, %15
%17 = load i32, i32* %4
%18 = icmp slt i32 %17, 1000
br i1 %18, label %19, label %33
19: ; preds = %16
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = load i32, i32* %3
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [1000 x [1000 x i8]], [1000 x [1000 x i8]]* %7, i64 0, i64 %25
%27 = load i32, i32* %4
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [1000 x i8], [1000 x i8]* %26, i64 0, i64 %28
store i8 %23, i8* %29
br label %30
30: ; preds = %19
%31 = load i32, i32* %4
%32 = add nsw i32 %31, 1
store i32 %32, i32* %4
br label %16
33: ; preds = %16
%34 = load i32, i32* %3
%35 = add nsw i32 %34, 1
store i32 %35, i32* %3
br label %36
36: ; preds = %33, %12
br label %8
37: ; preds = %8
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %5
br label %39
39: ; preds = %49, %37
%40 = load i32, i32* %5
%41 = load i32, i32* %3
%42 = icmp slt i32 %40, %41
br i1 %42, label %43, label %52
43: ; preds = %39
%44 = load i32, i32* %5
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [1000 x [1000 x i8]], [1000 x [1000 x i8]]* %7, i64 0, i64 %45
%47 = getelementptr inbounds [1000 x i8], [1000 x i8]* %46, i64 0, i64 0
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %47)
br label %49
49: ; preds = %43
%50 = load i32, i32* %5
%51 = add nsw i32 %50, 1
store i32 %51, i32* %5
br label %39
52: ; preds = %39
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%s\00"
@str = [17 x i8] c"The new line is:\00"
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%3 = alloca [1000 x [1000 x i8]]
%4 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [1000 x [1000 x i8]], [1000 x [1000 x i8]]* %3, i64 0, i64 0, i64 0
%6 = call i32 @getline(i8* %4, i32 1000)
%7 = icmp sgt i32 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %0
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
br label %32
10: ; preds = %0, %17
%11 = phi i32 [ %18, %17 ], [ 0, %0 ]
%12 = icmp slt i32 %11, 1000
br i1 %12, label %13, label %17
13: ; preds = %10
%14 = sext i32 %11 to i64
%15 = getelementptr [1000 x [1000 x i8]], [1000 x [1000 x i8]]* %3, i64 0, i64 %14, i64 0
%16 = add nsw i32 %11, 1
br label %17
17: ; preds = %13, %10
%18 = phi i32 [ %16, %13 ], [ %11, %10 ]
%19 = call i32 @getline(i8* %4, i32 1000)
%20 = icmp sgt i32 %19, 0
br i1 %20, label %10, label %21
21: ; preds = %17
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%23 = icmp sgt i32 %18, 0
br i1 %23, label %24, label %32
24: ; preds = %21
%25 = zext i32 %18 to i64
br label %26
26: ; preds = %24, %26
%27 = phi i64 [ 0, %24 ], [ %30, %26 ]
%28 = getelementptr inbounds [1000 x [1000 x i8]], [1000 x [1000 x i8]]* %3, i64 0, i64 %27, i64 0
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %28)
%30 = add nuw nsw i64 %27, 1
%31 = icmp eq i64 %30, %25
br i1 %31, label %32, label %26
32: ; preds = %26, %8, %21
ret i32 0
}