#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;
int /*<<< orphan*/ printf(char *, int);
scalar_t__ scanf(char *, double *);
int main() {
  double c, cardlength[300];
  int i, mid, left, right;
  cardlength[0] = 0.0;
  for (i = 1; i < 300; i++) {
    cardlength[i] = cardlength[i - 1] + ((double)1 / (double)(i + 1));
  }
  while (scanf("%lf", &c) != EOF) {
    if (c == 0.0)
      break;
    left = 0;
    right = 300 - 1;
    do {
      mid = (left + right) / 2;
      if (cardlength[mid] > c)
        right = mid;
      else if (cardlength[mid] < c)
        left = mid;
      else if (cardlength[mid] == c) {
        right = mid;
        break;
      }
    } while (right - left != 1);
    printf("%d card(s)\n", right);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x980,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x970(%rbp)
ff
movl   $0x1,-0x974(%rbp)
cmpl   $0x12c,-0x974(%rbp)
jge    11ac <main+0x8c>
mov    -0x974(%rbp),%eax
sub    $0x1,%eax
cltq
movsd  -0x970(%rbp,%rax,8),%xmm0
ff ff
mov    -0x974(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm2
movsd  0xe80(%rip),%xmm1
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movslq -0x974(%rbp),%rax
movsd  %xmm0,-0x970(%rbp,%rax,8)
ff ff
mov    -0x974(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x974(%rbp)
jmp    1147 <main+0x27>
jmp    11b1 <main+0x91>
lea    0xe50(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    0x2e20(%rip),%rcx
cmp    (%rcx),%rax
je     12e5 <main+0x1c5>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11ee <main+0xce>
jp     11ee <main+0xce>
jmp    12e5 <main+0x1c5>
movl   $0x0,-0x97c(%rbp)
movl   $0x12b,-0x980(%rbp)
mov    -0x97c(%rbp),%eax
add    -0x980(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x978(%rbp)
movslq -0x978(%rbp),%rax
movsd  -0x970(%rbp,%rax,8),%xmm0
ff ff
ucomisd -0x10(%rbp),%xmm0
jbe    1248 <main+0x128>
mov    -0x978(%rbp),%eax
mov    %eax,-0x980(%rbp)
jmp    12b4 <main+0x194>
movslq -0x978(%rbp),%rax
movsd  -0x970(%rbp,%rax,8),%xmm1
ff ff
movsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1278 <main+0x158>
mov    -0x978(%rbp),%eax
mov    %eax,-0x97c(%rbp)
jmp    12af <main+0x18f>
movslq -0x978(%rbp),%rax
movsd  -0x970(%rbp,%rax,8),%xmm0
ff ff
ucomisd -0x10(%rbp),%xmm0
jne    12aa <main+0x18a>
jp     12aa <main+0x18a>
mov    -0x978(%rbp),%eax
mov    %eax,-0x980(%rbp)
jmp    12ce <main+0x1ae>
jmp    12af <main+0x18f>
jmp    12b4 <main+0x194>
jmp    12b9 <main+0x199>
mov    -0x980(%rbp),%eax
sub    -0x97c(%rbp),%eax
cmp    $0x1,%eax
jne    1202 <main+0xe2>
mov    -0x980(%rbp),%esi
lea    0xd31(%rip),%rdi
call   1030 <printf@plt>
jmp    11b1 <main+0x91>
xor    %eax,%eax
add    $0x980,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x978,%rsp
movq   $0x0,0x10(%rsp)
xorpd  %xmm1,%xmm1
mov    $0x3,%eax
mov    $0x2,%ecx
movsd  0xeb3(%rip),%xmm0
nopl   (%rax)
xorps  %xmm3,%xmm3
cvtsi2sd %ecx,%xmm3
movapd %xmm0,%xmm2
divsd  %xmm3,%xmm2
addsd  %xmm1,%xmm2
movsd  %xmm2,0x8(%rsp,%rcx,8)
cmp    $0x12c,%rcx
je     1194 <main+0x74>
xorps  %xmm3,%xmm3
cvtsi2sd %eax,%xmm3
movapd %xmm0,%xmm1
divsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
movsd  %xmm1,0x10(%rsp,%rcx,8)
add    $0x2,%eax
add    $0x2,%rcx
jmp    1150 <main+0x30>
lea    0xe75(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x2e3c(%rip),%r12
cmp    (%r12),%rax
je     1273 <main+0x153>
movsd  0x8(%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11cc <main+0xac>
jnp    1273 <main+0x153>
lea    0xe41(%rip),%r14
lea    0xe36(%rip),%r15
lea    0x8(%rsp),%rbx
nop
mov    $0x12b,%ecx
xor    %eax,%eax
jmp    11fd <main+0xdd>
nopl   0x0(%rax)
mov    %esi,%ecx
mov    %ecx,%edx
sub    %eax,%edx
mov    %ecx,%esi
cmp    $0x1,%edx
je     1240 <main+0x120>
lea    (%rcx,%rax,1),%edx
mov    %edx,%esi
shr    $0x1f,%esi
add    %edx,%esi
sar    %esi
movslq %esi,%rdx
movsd  0x10(%rsp,%rdx,8),%xmm1
ucomisd %xmm0,%xmm1
ja     11f0 <main+0xd0>
ucomisd %xmm1,%xmm0
jbe    1230 <main+0x110>
mov    %esi,%eax
jmp    11f2 <main+0xd2>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
ucomisd %xmm0,%xmm1
jne    11f2 <main+0xd2>
jp     11f2 <main+0xd2>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
cmp    (%r12),%rax
je     1273 <main+0x153>
movsd  0x8(%rsp),%xmm0
ucomisd 0xda1(%rip),%xmm0
jne    11e0 <main+0xc0>
jp     11e0 <main+0xc0>
xor    %eax,%eax
add    $0x978,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%lf\00"
@EOF = global i64 0
@.str.1 = [12 x i8] c"%d card(s)\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca [300 x double]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = getelementptr inbounds [300 x double], [300 x double]* %3, i64 0, i64 0
store double 0.000000e+00, double* %8
store i32 1, i32* %4
br label %9
9: ; preds = %26, %0
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 300
br i1 %11, label %12, label %29
12: ; preds = %9
%13 = load i32, i32* %4
%14 = sub nsw i32 %13, 1
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [300 x double], [300 x double]* %3, i64 0, i64 %15
%17 = load double, double* %16
%18 = load i32, i32* %4
%19 = add nsw i32 %18, 1
%20 = sitofp i32 %19 to double
%21 = fdiv double 1.000000e+00, %20
%22 = fadd double %17, %21
%23 = load i32, i32* %4
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [300 x double], [300 x double]* %3, i64 0, i64 %24
store double %22, double* %25
br label %26
26: ; preds = %12
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 1
store i32 %28, i32* %4
br label %9
29: ; preds = %9
br label %30
30: ; preds = %78, %29
%31 = call i64 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %2)
%32 = load i64, i64* @EOF
%33 = icmp ne i64 %31, %32
br i1 %33, label %34, label %81
34: ; preds = %30
%35 = load double, double* %2
%36 = fcmp oeq double %35, 0.000000e+00
br i1 %36, label %37, label %38
37: ; preds = %34
br label %81
38: ; preds = %34
store i32 0, i32* %6
store i32 299, i32* %7
br label %39
39: ; preds = %73, %38
%40 = load i32, i32* %6
%41 = load i32, i32* %7
%42 = add nsw i32 %40, %41
%43 = sdiv i32 %42, 2
store i32 %43, i32* %5
%44 = load i32, i32* %5
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [300 x double], [300 x double]* %3, i64 0, i64 %45
%47 = load double, double* %46
%48 = load double, double* %2
%49 = fcmp ogt double %47, %48
br i1 %49, label %50, label %52
50: ; preds = %39
%51 = load i32, i32* %5
store i32 %51, i32* %7
br label %72
52: ; preds = %39
%53 = load i32, i32* %5
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [300 x double], [300 x double]* %3, i64 0, i64 %54
%56 = load double, double* %55
%57 = load double, double* %2
%58 = fcmp olt double %56, %57
br i1 %58, label %59, label %61
59: ; preds = %52
%60 = load i32, i32* %5
store i32 %60, i32* %6
br label %71
61: ; preds = %52
%62 = load i32, i32* %5
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [300 x double], [300 x double]* %3, i64 0, i64 %63
%65 = load double, double* %64
%66 = load double, double* %2
%67 = fcmp oeq double %65, %66
br i1 %67, label %68, label %70
68: ; preds = %61
%69 = load i32, i32* %5
store i32 %69, i32* %7
br label %78
70: ; preds = %61
br label %71
71: ; preds = %70, %59
br label %72
72: ; preds = %71, %50
br label %73
73: ; preds = %72
%74 = load i32, i32* %7
%75 = load i32, i32* %6
%76 = sub nsw i32 %74, %75
%77 = icmp ne i32 %76, 1
br i1 %77, label %39, label %78
78: ; preds = %73, %68
%79 = load i32, i32* %7
%80 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %79)
br label %30
81: ; preds = %37, %30
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%lf\00"
@EOF = global i64 0
@.str.1 = [12 x i8] c"%d card(s)\0A\00"
define i32 @main() {
%1 = alloca double
%2 = alloca [300 x double]
%3 = bitcast double* %1 to i8*
%4 = bitcast [300 x double]* %2 to i8*
%5 = getelementptr inbounds [300 x double], [300 x double]* %2, i64 0, i64 0
store double 0.000000e+00, double* %5
br label %13
6: ; preds = %13
%7 = call i64 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %1)
%8 = load i64, i64* @EOF
%9 = icmp eq i64 %7, %8
%10 = load double, double* %1
%11 = fcmp oeq double %10, 0.000000e+00
%12 = select i1 %9, i1 true, i1 %11
br i1 %12, label %59, label %30
13: ; preds = %23, %0
%14 = phi double [ 0.000000e+00, %0 ], [ %28, %23 ]
%15 = phi i64 [ 1, %0 ], [ %24, %23 ]
%16 = add nuw nsw i64 %15, 1
%17 = trunc i64 %16 to i32
%18 = sitofp i32 %17 to double
%19 = fdiv double 1.000000e+00, %18
%20 = fadd double %19, %14
%21 = getelementptr inbounds [300 x double], [300 x double]* %2, i64 0, i64 %15
store double %20, double* %21
%22 = icmp eq i64 %16, 300
br i1 %22, label %6, label %23
23: ; preds = %13
%24 = add nuw nsw i64 %15, 2
%25 = trunc i64 %24 to i32
%26 = sitofp i32 %25 to double
%27 = fdiv double 1.000000e+00, %26
%28 = fadd double %27, %20
%29 = getelementptr inbounds [300 x double], [300 x double]* %2, i64 0, i64 %16
store double %28, double* %29
br label %13
30: ; preds = %6, %50
%31 = phi double [ %56, %50 ], [ %10, %6 ]
br label %32
32: ; preds = %30, %45
%33 = phi i32 [ %46, %45 ], [ 0, %30 ]
%34 = phi i32 [ %47, %45 ], [ 299, %30 ]
%35 = add nsw i32 %34, %33
%36 = sdiv i32 %35, 2
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [300 x double], [300 x double]* %2, i64 0, i64 %37
%39 = load double, double* %38
%40 = fcmp ogt double %39, %31
br i1 %40, label %45, label %41
41: ; preds = %32
%42 = fcmp olt double %39, %31
br i1 %42, label %45, label %43
43: ; preds = %41
%44 = fcmp oeq double %39, %31
br i1 %44, label %50, label %45
45: ; preds = %41, %32, %43
%46 = phi i32 [ %33, %43 ], [ %33, %32 ], [ %36, %41 ]
%47 = phi i32 [ %34, %43 ], [ %36, %32 ], [ %34, %41 ]
%48 = sub nsw i32 %47, %46
%49 = icmp eq i32 %48, 1
br i1 %49, label %50, label %32
50: ; preds = %43, %45
%51 = phi i32 [ %47, %45 ], [ %36, %43 ]
%52 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %51)
%53 = call i64 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %1)
%54 = load i64, i64* @EOF
%55 = icmp eq i64 %53, %54
%56 = load double, double* %1
%57 = fcmp oeq double %56, 0.000000e+00
%58 = select i1 %55, i1 true, i1 %57
br i1 %58, label %59, label %30
59: ; preds = %50, %6
ret i32 0
}