#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ EXIT_SUCCESS;
long atol(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(long *);
long *malloc(long);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, long);
int main() {
  FILE *input = fopen("input2.txt", "r");
  long lines = 0;
  long *ptr;
  int ii = 0;
  int jump = sizeof(long);
  char holder[256 + 1];
  memset(holder, 0, 256 + 1);
  fgets(holder, 256 + 1, input);
  lines = atol(holder);
  ptr = malloc(lines * jump);
  memset(holder, 0, 256 + 1);
  while (fgets(holder, 256 + 1, input) != NULL) {
    ptr[ii] = atol(holder);
    ii += jump;
    memset(holder, 0, 256 + 1);
  }
  for (ii -= jump * 2; ii >= 0; ii -= jump) {
    printf("%ld\n", ptr[ii]);
  }
  free(ptr);
  fclose(input);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe57(%rip),%rdi
lea    0xe5b(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x8,-0x28(%rbp)
lea    -0x130(%rbp),%rdi
xor    %esi,%esi
mov    $0x101,%edx
call   1060 <memset@plt>
lea    -0x130(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x101,%esi
call   1070 <fgets@plt>
lea    -0x130(%rbp),%rdi
call   1090 <atol@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
movslq -0x28(%rbp),%rax
imul   %rax,%rdi
call   1080 <malloc@plt>
mov    %rax,-0x20(%rbp)
lea    -0x130(%rbp),%rdi
xor    %esi,%esi
mov    $0x101,%edx
call   1060 <memset@plt>
lea    -0x130(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x101,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     128a <main+0xfa>
lea    -0x130(%rbp),%rdi
call   1090 <atol@plt>
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x28(%rbp),%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
lea    -0x130(%rbp),%rdi
xor    %esi,%esi
mov    $0x101,%edx
call   1060 <memset@plt>
jmp    122f <main+0x9f>
mov    -0x28(%rbp),%ecx
shl    $0x1,%ecx
mov    -0x24(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jl     12ca <main+0x13a>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xd58(%rip),%rdi
call   1050 <printf@plt>
mov    -0x28(%rbp),%ecx
mov    -0x24(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x24(%rbp)
jmp    1298 <main+0x108>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
mov    0x2cfd(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x108,%rsp
lea    0xe5b(%rip),%rdi
lea    0xe5f(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%r14
mov    %rsp,%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x101,%edx
call   1060 <memset@plt>
mov    %r15,%rdi
mov    $0x101,%esi
mov    %r14,%rdx
call   1070 <fgets@plt>
mov    %r15,%rdi
call   1090 <atol@plt>
lea    0x0(,%rax,8),%rdi
call   1080 <malloc@plt>
mov    %rax,%r12
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x101,%edx
call   1060 <memset@plt>
mov    %r15,%rdi
mov    $0x101,%esi
mov    %r14,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     1286 <main+0xf6>
xor    %ebx,%ebx
mov    %rsp,%r15
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1090 <atol@plt>
mov    %rax,(%r12,%rbx,8)
add    $0x8,%rbx
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x101,%edx
call   1060 <memset@plt>
mov    %r15,%rdi
mov    $0x101,%esi
mov    %r14,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
jne    1220 <main+0x90>
cmp    $0x10,%ebx
jl     1286 <main+0xf6>
add    $0xfffffff0,%ebx
lea    0xdaa(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebx,%eax
mov    (%r12,%rax,8),%rsi
mov    %r15,%rdi
call   1050 <printf@plt>
add    $0xfffffff8,%ebx
cmp    $0xfffffff8,%ebx
jne    1270 <main+0xe0>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    0x2d43(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"input2.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [5 x i8] c"%ld\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i64
%4 = alloca i64*
%5 = alloca i32
%6 = alloca i32
%7 = alloca [257 x i8]
store i32 0, i32* %1
%8 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %8, i32** %2
store i64 0, i64* %3
store i32 0, i32* %5
store i32 8, i32* %6
%9 = getelementptr inbounds [257 x i8], [257 x i8]* %7, i64 0, i64 0
%10 = call i32 @memset(i8* %9, i32 0, i32 257)
%11 = getelementptr inbounds [257 x i8], [257 x i8]* %7, i64 0, i64 0
%12 = load i32*, i32** %2
%13 = call i32* @fgets(i8* %11, i32 257, i32* %12)
%14 = getelementptr inbounds [257 x i8], [257 x i8]* %7, i64 0, i64 0
%15 = call i64 @atol(i8* %14)
store i64 %15, i64* %3
%16 = load i64, i64* %3
%17 = load i32, i32* %6
%18 = sext i32 %17 to i64
%19 = mul nsw i64 %16, %18
%20 = call i64* @malloc(i64 %19)
store i64* %20, i64** %4
%21 = getelementptr inbounds [257 x i8], [257 x i8]* %7, i64 0, i64 0
%22 = call i32 @memset(i8* %21, i32 0, i32 257)
br label %23
23: ; preds = %28, %0
%24 = getelementptr inbounds [257 x i8], [257 x i8]* %7, i64 0, i64 0
%25 = load i32*, i32** %2
%26 = call i32* @fgets(i8* %24, i32 257, i32* %25)
%27 = icmp ne i32* %26, null
br i1 %27, label %28, label %40
28: ; preds = %23
%29 = getelementptr inbounds [257 x i8], [257 x i8]* %7, i64 0, i64 0
%30 = call i64 @atol(i8* %29)
%31 = load i64*, i64** %4
%32 = load i32, i32* %5
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i64, i64* %31, i64 %33
store i64 %30, i64* %34
%35 = load i32, i32* %6
%36 = load i32, i32* %5
%37 = add nsw i32 %36, %35
store i32 %37, i32* %5
%38 = getelementptr inbounds [257 x i8], [257 x i8]* %7, i64 0, i64 0
%39 = call i32 @memset(i8* %38, i32 0, i32 257)
br label %23
40: ; preds = %23
%41 = load i32, i32* %6
%42 = mul nsw i32 %41, 2
%43 = load i32, i32* %5
%44 = sub nsw i32 %43, %42
store i32 %44, i32* %5
br label %45
45: ; preds = %55, %40
%46 = load i32, i32* %5
%47 = icmp sge i32 %46, 0
br i1 %47, label %48, label %59
48: ; preds = %45
%49 = load i64*, i64** %4
%50 = load i32, i32* %5
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i64, i64* %49, i64 %51
%53 = load i64, i64* %52
%54 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %53)
br label %55
55: ; preds = %48
%56 = load i32, i32* %6
%57 = load i32, i32* %5
%58 = sub nsw i32 %57, %56
store i32 %58, i32* %5
br label %45
59: ; preds = %45
%60 = load i64*, i64** %4
%61 = call i32 @free(i64* %60)
%62 = load i32*, i32** %2
%63 = call i32 @fclose(i32* %62)
%64 = load i32, i32* @EXIT_SUCCESS
%65 = call i32 @exit(i32 %64)
unreachable
}

LLVM IR (-O2):
@.str = [11 x i8] c"input2.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [5 x i8] c"%ld\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca [257 x i8]
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = getelementptr inbounds [257 x i8], [257 x i8]* %1, i64 0, i64 0
%4 = call i32 @memset(i8* %3, i32 0, i32 257)
%5 = call i32* @fgets(i8* %3, i32 257, i32* %2)
%6 = call i64 @atol(i8* %3)
%7 = shl nsw i64 %6, 3
%8 = call i64* @malloc(i64 %7)
%9 = call i32 @memset(i8* %3, i32 0, i32 257)
%10 = call i32* @fgets(i8* %3, i32 257, i32* %2)
%11 = icmp eq i32* %10, null
br i1 %11, label %33, label %12
12: ; preds = %0, %12
%13 = phi i64 [ %16, %12 ], [ 0, %0 ]
%14 = call i64 @atol(i8* %3)
%15 = getelementptr inbounds i64, i64* %8, i64 %13
store i64 %14, i64* %15
%16 = add nuw i64 %13, 8
%17 = call i32 @memset(i8* %3, i32 0, i32 257)
%18 = call i32* @fgets(i8* %3, i32 257, i32* %2)
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %12
20: ; preds = %12
%21 = trunc i64 %16 to i32
%22 = icmp sgt i32 %21, 15
br i1 %22, label %23, label %33
23: ; preds = %20
%24 = add nsw i32 %21, -16
br label %25
25: ; preds = %23, %25
%26 = phi i32 [ %31, %25 ], [ %24, %23 ]
%27 = zext i32 %26 to i64
%28 = getelementptr inbounds i64, i64* %8, i64 %27
%29 = load i64, i64* %28
%30 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %29)
%31 = add nsw i32 %26, -8
%32 = icmp eq i32 %26, 0
br i1 %32, label %33, label %25
33: ; preds = %25, %0, %20
%34 = call i32 @free(i64* %8)
%35 = call i32 @fclose(i32* %2)
%36 = load i32, i32* @EXIT_SUCCESS
%37 = call i32 @exit(i32 %36)
unreachable
}