#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*/ printf(char *, long);
long seq(long);
int problem014() {
  long start = 0;
  long num = 0;
  long i = 1000000;
  while (i-- != 13) {
    long temp = seq(i);
    if (temp > start) {
      start = temp;
      num = i;
    }
  }
  printf("%ld\n", num);
  return 0;
}


x86 assembly (clang, -O0):
<problem014>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movq   $0x0,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0xf4240,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x18(%rbp)
cmp    $0xd,%rax
je     1189 <problem014+0x69>
mov    -0x18(%rbp),%rdi
call   1040 <seq@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x8(%rbp),%rax
jle    1184 <problem014+0x64>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x10(%rbp)
jmp    1140 <problem014+0x20>
mov    -0x10(%rbp),%rsi
lea    0xe6c(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<problem014>:
push   %r15
push   %r14
push   %rbx
mov    $0xf423f,%ebx
xor    %r15d,%r15d
xor    %r14d,%r14d
mov    %rbx,%rdi
call   1040 <seq@plt>
cmp    %r15,%rax
cmovg  %rbx,%r14
cmovg  %rax,%r15
add    $0xffffffffffffffff,%rbx
cmp    $0xc,%rbx
jne    1130 <problem014+0x10>
lea    0xeac(%rip),%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%ld\0A\00"
define i32 @problem014() {
%1 = alloca i64
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
store i64 0, i64* %1
store i64 0, i64* %2
store i64 1000000, i64* %3
br label %5
5: ; preds = %18, %0
%6 = load i64, i64* %3
%7 = add nsw i64 %6, -1
store i64 %7, i64* %3
%8 = icmp ne i64 %6, 13
br i1 %8, label %9, label %19
9: ; preds = %5
%10 = load i64, i64* %3
%11 = call i64 @seq(i64 %10)
store i64 %11, i64* %4
%12 = load i64, i64* %4
%13 = load i64, i64* %1
%14 = icmp sgt i64 %12, %13
br i1 %14, label %15, label %18
15: ; preds = %9
%16 = load i64, i64* %4
store i64 %16, i64* %1
%17 = load i64, i64* %3
store i64 %17, i64* %2
br label %18
18: ; preds = %15, %9
br label %5
19: ; preds = %5
%20 = load i64, i64* %2
%21 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 %20)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%ld\0A\00"
define i32 @problem014() {
br label %1
1: ; preds = %0, %1
%2 = phi i64 [ 999999, %0 ], [ %9, %1 ]
%3 = phi i64 [ 0, %0 ], [ %8, %1 ]
%4 = phi i64 [ 0, %0 ], [ %7, %1 ]
%5 = tail call i64 @seq(i64 %2)
%6 = icmp sgt i64 %5, %3
%7 = select i1 %6, i64 %2, i64 %4
%8 = select i1 %6, i64 %5, i64 %3
%9 = add nsw i64 %2, -1
%10 = icmp eq i64 %2, 13
br i1 %10, label %11, label %1
11: ; preds = %1
%12 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 %7)
ret i32 0
}