#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 cal_loop(int);
int /*<<< orphan*/ clear_cache();
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n;
  int max_loop = 0;
  int max_num = 0;
  scanf("%d", &n);
  int i = 1;
  while (i <= n) {
    clear_cache();
    int loop = cal_loop(i);
    if (loop > max_loop) {
      max_loop = loop;
      max_num = i;
    }
    i++;
  }
  printf("%d\n", max_num);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xe9c(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11b8 <main+0x78>
mov    $0x0,%al
call   1050 <clear_cache@plt>
mov    -0x14(%rbp),%edi
call   1030 <cal_loop@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    11aa <main+0x6a>
mov    -0x18(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1174 <main+0x34>
mov    -0x10(%rbp),%esi
lea    0xe41(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    1192 <main+0x52>
xor    %ebp,%ebp
xor    %ebx,%ebx
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebp
xor    %eax,%eax
call   1050 <clear_cache@plt>
mov    %ebp,%edi
call   1030 <cal_loop@plt>
cmp    %ebx,%eax
cmovg  %ebp,%r14d
cmovg  %eax,%ebx
cmp    0xc(%rsp),%ebp
jl     1170 <main+0x30>
jmp    1195 <main+0x55>
xor    %r14d,%r14d
lea    0xe67(%rip),%rdi
mov    %r14d,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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