#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 /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, double *);
int main() {
  double length;
  double sum;
  for (;;) {
    scanf("%lf", &length);
    if ((length - 0.00) < 0.01 && (0.00 - length) < 0.01)
      return 0;
    sum = 0;
    for (int i = 2;; i++) {
      sum += 1 / (double)i;
      if (sum > length) {
        printf("%d card(s)\n", i - 1);
        break;
      }
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeda(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
movsd  -0x10(%rbp),%xmm1
xorps  %xmm0,%xmm0
subsd  %xmm0,%xmm1
movsd  0xead(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    117f <main+0x5f>
xorps  %xmm1,%xmm1
subsd  -0x10(%rbp),%xmm1
movsd  0xe93(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    117f <main+0x5f>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x2,-0x1c(%rbp)
cvtsi2sdl -0x1c(%rbp),%xmm1
movsd  0xe6d(%rip),%xmm0
divsd  %xmm1,%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11d0 <main+0xb0>
mov    -0x1c(%rbp),%esi
sub    $0x1,%esi
lea    0xe4e(%rip),%rdi
call   1030 <printf@plt>
jmp    11e3 <main+0xc3>
jmp    11d5 <main+0xb5>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    118e <main+0x6e>
jmp    112f <main+0xf>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xee0(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1040 <scanf@plt>
movsd  0x8(%rsp),%xmm0
movsd  0xeb8(%rip),%xmm2
ucomisd %xmm0,%xmm2
xorpd  %xmm1,%xmm1
jbe    1160 <main+0x40>
subsd  %xmm0,%xmm1
ucomisd %xmm1,%xmm2
ja     11ec <main+0xcc>
movsd  0xea0(%rip),%xmm4
lea    0xea5(%rip),%r14
lea    0xe9a(%rip),%r15
lea    0x8(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
xorpd  %xmm1,%xmm1
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
lea    0x2(%rsi),%eax
xorps  %xmm2,%xmm2
cvtsi2sd %eax,%xmm2
movapd %xmm4,%xmm3
divsd  %xmm2,%xmm3
addsd  %xmm3,%xmm1
add    $0x1,%esi
ucomisd %xmm0,%xmm1
jbe    1190 <main+0x70>
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
movsd  0xe3e(%rip),%xmm4
movsd  0x8(%rsp),%xmm0
movsd  0xe28(%rip),%xmm2
ucomisd %xmm0,%xmm2
jbe    1180 <main+0x60>
xorpd  %xmm1,%xmm1
subsd  %xmm0,%xmm1
ucomisd %xmm1,%xmm2
jbe    1180 <main+0x60>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%lf\00"
@.str.1 = [12 x i8] c"%d card(s)\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca i32
store i32 0, i32* %1
br label %5
5: ; preds = %33, %0
%6 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %2)
%7 = load double, double* %2
%8 = fsub double %7, 0.000000e+00
%9 = fcmp olt double %8, 1.000000e-02
br i1 %9, label %10, label %15
10: ; preds = %5
%11 = load double, double* %2
%12 = fsub double 0.000000e+00, %11
%13 = fcmp olt double %12, 1.000000e-02
br i1 %13, label %14, label %15
14: ; preds = %10
ret i32 0
15: ; preds = %10, %5
store double 0.000000e+00, double* %3
store i32 2, i32* %4
br label %16
16: ; preds = %30, %15
%17 = load i32, i32* %4
%18 = sitofp i32 %17 to double
%19 = fdiv double 1.000000e+00, %18
%20 = load double, double* %3
%21 = fadd double %20, %19
store double %21, double* %3
%22 = load double, double* %3
%23 = load double, double* %2
%24 = fcmp ogt double %22, %23
br i1 %24, label %25, label %29
25: ; preds = %16
%26 = load i32, i32* %4
%27 = sub nsw i32 %26, 1
%28 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %27)
br label %33
29: ; preds = %16
br label %30
30: ; preds = %29
%31 = load i32, i32* %4
%32 = add nsw i32 %31, 1
store i32 %32, i32* %4
br label %16
33: ; preds = %25
br label %5
}

LLVM IR (-O2):
@.str = [4 x i8] c"%lf\00"
@.str.1 = [12 x i8] c"%d card(s)\0A\00"
define i32 @main() {
%1 = alloca double
%2 = bitcast double* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %1)
%4 = load double, double* %1
%5 = fcmp olt double %4, 1.000000e-02
%6 = fsub double 0.000000e+00, %4
%7 = fcmp olt double %6, 1.000000e-02
%8 = and i1 %5, %7
br i1 %8, label %11, label %9
9: ; preds = %0, %20
%10 = phi double [ %24, %20 ], [ %4, %0 ]
br label %12
11: ; preds = %20, %0
ret i32 0
12: ; preds = %12, %9
%13 = phi double [ %17, %12 ], [ 0.000000e+00, %9 ]
%14 = phi i32 [ %19, %12 ], [ 2, %9 ]
%15 = sitofp i32 %14 to double
%16 = fdiv double 1.000000e+00, %15
%17 = fadd double %13, %16
%18 = fcmp ogt double %17, %10
%19 = add nuw nsw i32 %14, 1
br i1 %18, label %20, label %12
20: ; preds = %12
%21 = add nsw i32 %14, -1
%22 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %21)
%23 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %1)
%24 = load double, double* %1
%25 = fcmp olt double %24, 1.000000e-02
%26 = fsub double 0.000000e+00, %24
%27 = fcmp olt double %26, 1.000000e-02
%28 = and i1 %25, %27
br i1 %28, label %11, label %9
}