#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 */
scalar_t__ EOF;
double log(int);
double pow(int, int);
int /*<<< orphan*/ printf(char *, int);
scalar_t__ scanf(char *, int *);
int main() {
  int y;
  int m, n;
  int i;
  double sum, bound;
  while (scanf("%d", &y) != EOF) {
    if (y == 0)
      break;
    m = (y - 1960) / 10 + 2;
    bound = pow(2, m) * log(2);
    n = 1;
    sum = 0;
    while (sum < bound)
      sum += log(n++);
    printf("%d\n", n - 2);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    0x2e82(%rip),%rcx
cmp    (%rcx),%rax
je     121a <main+0xda>
cmpl   $0x0,-0x8(%rbp)
jne    117e <main+0x3e>
jmp    121a <main+0xda>
mov    -0x8(%rbp),%eax
sub    $0x7a8,%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x2,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
mov    $0x2,%edi
call   1060 <pow@plt>
movsd  %xmm0,-0x30(%rbp)
mov    $0x2,%edi
call   1050 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x1,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1203 <main+0xc3>
mov    -0x10(%rbp),%edi
mov    %edi,%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
call   1050 <log@plt>
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11d0 <main+0x90>
mov    -0x10(%rbp),%esi
sub    $0x2,%esi
lea    0xdf3(%rip),%rdi
call   1030 <printf@plt>
jmp    114f <main+0xf>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
lea    0xeb5(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x2e84(%rip),%r12
cmp    (%r12),%rax
je     1240 <main+0x100>
mov    0xc(%rsp),%eax
test   %eax,%eax
je     1240 <main+0x100>
lea    0xe8a(%rip),%r14
lea    0xe80(%rip),%r15
lea    0xc(%rsp),%rbx
nopl   (%rax)
add    $0xfffff858,%eax
cltq
imul   $0x66666667,%rax,%rax
mov    %rax,%rcx
sar    $0x22,%rcx
shr    $0x3f,%rax
lea    (%rcx,%rax,1),%esi
add    $0x2,%esi
mov    $0x2,%edi
call   1060 <pow@plt>
movsd  %xmm0,0x10(%rsp)
mov    $0x2,%edi
call   1050 <log@plt>
mulsd  0x10(%rsp),%xmm0
mov    $0x1,%ebp
ucomisd 0xe24(%rip),%xmm0
jbe    1216 <main+0xd6>
xorps  %xmm1,%xmm1
mov    $0x1,%edi
movsd  %xmm0,0x18(%rsp)
nopl   0x0(%rax)
movsd  %xmm1,0x10(%rsp)
lea    0x1(%rdi),%ebp
call   1050 <log@plt>
movsd  0x10(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  0x18(%rsp),%xmm0
ucomisd %xmm1,%xmm0
mov    %ebp,%edi
ja     11f0 <main+0xb0>
add    $0xfffffffe,%ebp
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
cmp    (%r12),%rax
je     1240 <main+0x100>
mov    0xc(%rsp),%eax
test   %eax,%eax
jne    1190 <main+0x50>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@EOF = global i64 0
@.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 double
%7 = alloca double
store i32 0, i32* %1
br label %8
8: ; preds = %35, %0
%9 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%10 = load i64, i64* @EOF
%11 = icmp ne i64 %9, %10
br i1 %11, label %12, label %39
12: ; preds = %8
%13 = load i32, i32* %2
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %12
br label %39
16: ; preds = %12
%17 = load i32, i32* %2
%18 = sub nsw i32 %17, 1960
%19 = sdiv i32 %18, 10
%20 = add nsw i32 %19, 2
store i32 %20, i32* %3
%21 = load i32, i32* %3
%22 = call double @pow(i32 2, i32 %21)
%23 = call double @log(i32 2)
%24 = fmul double %22, %23
store double %24, double* %7
store i32 1, i32* %4
store double 0.000000e+00, double* %6
br label %25
25: ; preds = %29, %16
%26 = load double, double* %6
%27 = load double, double* %7
%28 = fcmp olt double %26, %27
br i1 %28, label %29, label %35
29: ; preds = %25
%30 = load i32, i32* %4
%31 = add nsw i32 %30, 1
store i32 %31, i32* %4
%32 = call double @log(i32 %30)
%33 = load double, double* %6
%34 = fadd double %33, %32
store double %34, double* %6
br label %25
35: ; preds = %25
%36 = load i32, i32* %4
%37 = sub nsw i32 %36, 2
%38 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %37)
br label %8
39: ; preds = %15, %8
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@EOF = global i64 0
@.str.1 = [4 x i8] c"%d\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 = load i64, i64* @EOF
%5 = icmp eq i64 %3, %4
%6 = load i32, i32* %1
%7 = icmp eq i32 %6, 0
%8 = select i1 %5, i1 true, i1 %7
br i1 %8, label %35, label %9
9: ; preds = %0, %25
%10 = phi i32 [ %32, %25 ], [ %6, %0 ]
%11 = add nsw i32 %10, -1960
%12 = sdiv i32 %11, 10
%13 = add nsw i32 %12, 2
%14 = call double @pow(i32 2, i32 %13)
%15 = call double @log(i32 2)
%16 = fmul double %14, %15
%17 = fcmp ogt double %16, 0.000000e+00
br i1 %17, label %18, label %25
18: ; preds = %9, %18
%19 = phi i32 [ %21, %18 ], [ 1, %9 ]
%20 = phi double [ %23, %18 ], [ 0.000000e+00, %9 ]
%21 = add nuw nsw i32 %19, 1
%22 = call double @log(i32 %19)
%23 = fadd double %20, %22
%24 = fcmp olt double %23, %16
br i1 %24, label %18, label %25
25: ; preds = %18, %9
%26 = phi i32 [ 1, %9 ], [ %21, %18 ]
%27 = add nsw i32 %26, -2
%28 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %27)
%29 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%30 = load i64, i64* @EOF
%31 = icmp eq i64 %29, %30
%32 = load i32, i32* %1
%33 = icmp eq i32 %32, 0
%34 = select i1 %31, i1 true, i1 %33
br i1 %34, label %35, label %9
35: ; preds = %25, %0
ret i32 0
}