#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 er(int);
long long log(long long);
int /*<<< orphan*/ printf(char *, long long);
scalar_t__ scanf(char *, int *);
main() {
  long long k;
  int n;
  long long l = 0;
  int year, m;
  double x = 0, p;
  while (scanf("%d", &year)) {
    l = 0;
    x = 0;
    if (year == 0)
      break;
    year -= 1960;
    m = year / 10;
    k = 4 * er(m);
    while (x < k * log(2)) {
      l++;
      x += log(l);
    }
    printf("%lld\n", l - 1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
lea    0xe9a(%rip),%rdi
lea    -0x24(%rbp),%rsi
call   1050 <scanf@plt>
cmp    $0x0,%rax
je     123f <main+0xff>
movq   $0x0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    1198 <main+0x58>
jmp    123f <main+0xff>
mov    -0x24(%rbp),%eax
sub    $0x7a8,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%edi
call   1040 <er@plt>
shl    $0x2,%eax
cltq
mov    %rax,-0x10(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    $0x2,%edi
call   1060 <log@plt>
movsd  -0x48(%rbp),%xmm1
mov    %rax,%rcx
mov    -0x40(%rbp),%rax
imul   %rcx,%rax
cvtsi2sd %rax,%xmm0
ucomisd %xmm1,%xmm0
jbe    1226 <main+0xe6>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <log@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    11c2 <main+0x82>
mov    -0x20(%rbp),%rsi
sub    $0x1,%rsi
lea    0xdce(%rip),%rdi
call   1030 <printf@plt>
jmp    115f <main+0x1f>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xeac(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
test   %rax,%rax
je     1247 <main+0x107>
lea    0xe95(%rip),%r14
lea    0xe8b(%rip),%r15
lea    0x4(%rsp),%r12
jmp    11a5 <main+0x65>
nopl   0x0(%rax)
xor    %ebx,%ebx
add    $0xffffffffffffffff,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
test   %rax,%rax
je     1247 <main+0x107>
mov    0x4(%rsp),%eax
test   %eax,%eax
je     1247 <main+0x107>
add    $0xfffff858,%eax
mov    %eax,0x4(%rsp)
cltq
imul   $0x66666667,%rax,%rdi
mov    %rdi,%rax
shr    $0x3f,%rax
sar    $0x22,%rdi
add    %eax,%edi
call   1040 <er@plt>
shl    $0x2,%eax
movslq %eax,%r13
mov    $0x2,%edi
call   1060 <log@plt>
imul   %r13,%rax
test   %rax,%rax
jle    1180 <main+0x40>
xorps  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %ebx,%ebx
nopl   0x0(%rax)
add    $0x1,%rbx
mov    %rbx,%rdi
call   1060 <log@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
mov    $0x2,%edi
call   1060 <log@plt>
imul   %r13,%rax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
ucomisd 0x8(%rsp),%xmm0
ja     1200 <main+0xc0>
jmp    1182 <main+0x42>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [6 x i8] c"%lld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i32
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
%8 = alloca double
store i32 0, i32* %1
store i64 0, i64* %4
store double 0.000000e+00, double* %7
br label %9
9: ; preds = %40, %0
%10 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %44
12: ; preds = %9
store i64 0, i64* %4
store double 0.000000e+00, double* %7
%13 = load i32, i32* %5
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %12
br label %44
16: ; preds = %12
%17 = load i32, i32* %5
%18 = sub nsw i32 %17, 1960
store i32 %18, i32* %5
%19 = load i32, i32* %5
%20 = sdiv i32 %19, 10
store i32 %20, i32* %6
%21 = load i32, i32* %6
%22 = call i32 @er(i32 %21)
%23 = mul nsw i32 4, %22
%24 = sext i32 %23 to i64
store i64 %24, i64* %2
br label %25
25: ; preds = %32, %16
%26 = load double, double* %7
%27 = load i64, i64* %2
%28 = call i64 @log(i64 2)
%29 = mul nsw i64 %27, %28
%30 = sitofp i64 %29 to double
%31 = fcmp olt double %26, %30
br i1 %31, label %32, label %40
32: ; preds = %25
%33 = load i64, i64* %4
%34 = add nsw i64 %33, 1
store i64 %34, i64* %4
%35 = load i64, i64* %4
%36 = call i64 @log(i64 %35)
%37 = sitofp i64 %36 to double
%38 = load double, double* %7
%39 = fadd double %38, %37
store double %39, double* %7
br label %25
40: ; preds = %25
%41 = load i64, i64* %4
%42 = sub nsw i64 %41, 1
%43 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 %42)
br label %9
44: ; preds = %15, %9
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [6 x i8] c"%lld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = icmp eq i64 %3, 0
br i1 %4, label %34, label %5
5: ; preds = %0, %28
%6 = load i32, i32* %1
%7 = icmp eq i32 %6, 0
br i1 %7, label %34, label %8
8: ; preds = %5
%9 = add nsw i32 %6, -1960
store i32 %9, i32* %1
%10 = sdiv i32 %9, 10
%11 = call i32 @er(i32 %10)
%12 = shl nsw i32 %11, 2
%13 = sext i32 %12 to i64
%14 = call i64 @log(i64 2)
%15 = mul nsw i64 %14, %13
%16 = icmp sgt i64 %15, 0
br i1 %16, label %17, label %28
17: ; preds = %8, %17
%18 = phi i64 [ %20, %17 ], [ 0, %8 ]
%19 = phi double [ %23, %17 ], [ 0.000000e+00, %8 ]
%20 = add nuw nsw i64 %18, 1
%21 = call i64 @log(i64 %20)
%22 = sitofp i64 %21 to double
%23 = fadd double %19, %22
%24 = call i64 @log(i64 2)
%25 = mul nsw i64 %24, %13
%26 = sitofp i64 %25 to double
%27 = fcmp olt double %23, %26
br i1 %27, label %17, label %28
28: ; preds = %17, %8
%29 = phi i64 [ 0, %8 ], [ %20, %17 ]
%30 = add nsw i64 %29, -1
%31 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 %30)
%32 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %5
34: ; preds = %28, %5, %0
ret i32 0
}