#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*/ computeSequenceTerm(long *);
int /*<<< orphan*/ printf(char *, long);
int /*<<< orphan*/ scanf(char *, long *);
int main(void) {
  long int sequence[1000000L + 1], termSerial;
  computeSequenceTerm(sequence);
  while (1) {
    scanf("%ld", &termSerial);
    if (termSerial < 0)
      break;
    printf("%ld\n", sequence[termSerial]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7a1220,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x7a1210(%rbp),%rdi
call   1050 <computeSequenceTerm@plt>
lea    0xeab(%rip),%rdi
lea    -0x7a1218(%rbp),%rsi
call   1040 <scanf@plt>
cmpq   $0x0,-0x7a1218(%rbp)
jge    1174 <main+0x44>
jmp    1194 <main+0x64>
mov    -0x7a1218(%rbp),%rax
mov    -0x7a1210(%rbp,%rax,8),%rsi
ff
lea    0xe7a(%rip),%rdi
call   1030 <printf@plt>
jmp    114e <main+0x1e>
xor    %eax,%eax
add    $0x7a1220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x7a1220,%rsp
lea    0x10(%rsp),%rdi
call   1050 <computeSequenceTerm@plt>
lea    0xeb3(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x8(%rsp),%rax
test   %rax,%rax
js     11a2 <main+0x72>
lea    0xe9c(%rip),%r14
lea    0xe91(%rip),%r15
lea    0x8(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x10(%rsp,%rax,8),%rsi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
mov    0x8(%rsp),%rax
test   %rax,%rax
jns    1180 <main+0x50>
xor    %eax,%eax
add    $0x7a1220,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%ld\00"
@.str.1 = [5 x i8] c"%ld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1000001 x i64]
%3 = alloca i64
store i32 0, i32* %1
%4 = getelementptr inbounds [1000001 x i64], [1000001 x i64]* %2, i64 0, i64 0
%5 = call i32 @computeSequenceTerm(i64* %4)
br label %6
6: ; preds = %0, %11
%7 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %3)
%8 = load i64, i64* %3
%9 = icmp slt i64 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %6
br label %16
11: ; preds = %6
%12 = load i64, i64* %3
%13 = getelementptr inbounds [1000001 x i64], [1000001 x i64]* %2, i64 0, i64 %12
%14 = load i64, i64* %13
%15 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %14)
br label %6
16: ; preds = %10
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%ld\00"
@.str.1 = [5 x i8] c"%ld\0A\00"
define i32 @main() {
%1 = alloca [1000001 x i64]
%2 = alloca i64
%3 = bitcast [1000001 x i64]* %1 to i8*
%4 = bitcast i64* %2 to i8*
%5 = getelementptr inbounds [1000001 x i64], [1000001 x i64]* %1, i64 0, i64 0
%6 = call i32 @computeSequenceTerm(i64* %5)
%7 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %2)
%8 = load i64, i64* %2
%9 = icmp slt i64 %8, 0
br i1 %9, label %18, label %10
10: ; preds = %0, %10
%11 = phi i64 [ %16, %10 ], [ %8, %0 ]
%12 = getelementptr inbounds [1000001 x i64], [1000001 x i64]* %1, i64 0, i64 %11
%13 = load i64, i64* %12
%14 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %13)
%15 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %2)
%16 = load i64, i64* %2
%17 = icmp slt i64 %16, 0
br i1 %17, label %18, label %10
18: ; preds = %10, %0
ret i32 0
}