#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 */
unsigned long atol(char *);
int /*<<< orphan*/ printf(char *, int);
int siracusa(unsigned long);
int main(int argc, char *argv[]) {
  long unsigned int n = atol(argv[1]);
  int max = siracusa(1), pos = 0;
  for (long unsigned int i = 1; i <= n; i++) {
    if (siracusa(i) > max) {
      max = siracusa(i);
      pos = i;
    }
  }
  printf("%d\n", pos);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <atol@plt>
mov    %rax,-0x18(%rbp)
mov    $0x1,%edi
call   1050 <siracusa@plt>
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movq   $0x1,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
ja     11bc <main+0x8c>
mov    -0x28(%rbp),%rdi
call   1050 <siracusa@plt>
cmp    -0x1c(%rbp),%eax
jle    11a6 <main+0x76>
mov    -0x28(%rbp),%rdi
call   1050 <siracusa@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x28(%rbp),%rax
mov    %eax,-0x20(%rbp)
jmp    11ab <main+0x7b>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1173 <main+0x43>
mov    -0x20(%rbp),%esi
lea    0xe3a(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    0x8(%rsi),%rdi
call   1040 <atol@plt>
mov    %rax,%r14
mov    $0x1,%ebx
mov    $0x1,%edi
call   1050 <siracusa@plt>
test   %r14,%r14
je     1184 <main+0x54>
mov    %eax,%ebp
xor    %r15d,%r15d
jmp    1169 <main+0x39>
xchg   %ax,%ax
add    $0x1,%rbx
cmp    %r14,%rbx
ja     1187 <main+0x57>
mov    %rbx,%rdi
call   1050 <siracusa@plt>
cmp    %ebp,%eax
jle    1160 <main+0x30>
mov    %rbx,%rdi
call   1050 <siracusa@plt>
mov    %eax,%ebp
mov    %ebx,%r15d
jmp    1160 <main+0x30>
xor    %r15d,%r15d
lea    0xe72(%rip),%rdi
mov    %r15d,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
%9 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i64 @atol(i8* %12)
store i64 %13, i64* %6
%14 = call i32 @siracusa(i64 1)
store i32 %14, i32* %7
store i32 0, i32* %8
store i64 1, i64* %9
br label %15
15: ; preds = %30, %2
%16 = load i64, i64* %9
%17 = load i64, i64* %6
%18 = icmp ule i64 %16, %17
br i1 %18, label %19, label %33
19: ; preds = %15
%20 = load i64, i64* %9
%21 = call i32 @siracusa(i64 %20)
%22 = load i32, i32* %7
%23 = icmp sgt i32 %21, %22
br i1 %23, label %24, label %29
24: ; preds = %19
%25 = load i64, i64* %9
%26 = call i32 @siracusa(i64 %25)
store i32 %26, i32* %7
%27 = load i64, i64* %9
%28 = trunc i64 %27 to i32
store i32 %28, i32* %8
br label %29
29: ; preds = %24, %19
br label %30
30: ; preds = %29
%31 = load i64, i64* %9
%32 = add i64 %31, 1
store i64 %32, i64* %9
br label %15
33: ; preds = %15
%34 = load i32, i32* %8
%35 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %34)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i64 @atol(i8* %4)
%6 = tail call i32 @siracusa(i64 1)
%7 = icmp eq i64 %5, 0
br i1 %7, label %8, label %11
8: ; preds = %20, %2
%9 = phi i32 [ 0, %2 ], [ %22, %20 ]
%10 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %9)
ret i32 0
11: ; preds = %2, %20
%12 = phi i64 [ %23, %20 ], [ 1, %2 ]
%13 = phi i32 [ %22, %20 ], [ 0, %2 ]
%14 = phi i32 [ %21, %20 ], [ %6, %2 ]
%15 = tail call i32 @siracusa(i64 %12)
%16 = icmp sgt i32 %15, %14
br i1 %16, label %17, label %20
17: ; preds = %11
%18 = tail call i32 @siracusa(i64 %12)
%19 = trunc i64 %12 to i32
br label %20
20: ; preds = %11, %17
%21 = phi i32 [ %18, %17 ], [ %14, %11 ]
%22 = phi i32 [ %19, %17 ], [ %13, %11 ]
%23 = add i64 %12, 1
%24 = icmp ugt i64 %23, %5
br i1 %24, label %8, label %11
}