#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 *, float *);
int main() {
  float num;
  while (1) {
    scanf("%f", &num);
    if (num == 0.00f) {
      break;
    } else {
      int cards = 1;
      double sum = 0;
      for (;; ++cards) {
        sum += 1.0 / (1 + cards);
        if (sum > num) {
          break;
        }
      }
      printf("%d card(s)\n", cards);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xed2(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movss  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    115b <main+0x3b>
jp     115b <main+0x3b>
jmp    11ce <main+0xae>
movl   $0x1,-0xc(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd  0xe84(%rip),%xmm0
divsd  %xmm1,%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11a7 <main+0x87>
jmp    11ba <main+0x9a>
jmp    11ac <main+0x8c>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    116a <main+0x4a>
mov    -0xc(%rbp),%esi
lea    0xe47(%rip),%rdi
call   1030 <printf@plt>
jmp    112f <main+0xf>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xedc(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
movss  0xc(%rsp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    114e <main+0x2e>
jnp    11cb <main+0xab>
movsd  0xeaa(%rip),%xmm4
lea    0xeb2(%rip),%r14
lea    0xea8(%rip),%r15
lea    0xc(%rsp),%rbx
nopl   0x0(%rax)
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
xor    %esi,%esi
nopl   0x0(%rax)
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    1180 <main+0x60>
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
movsd  0xe46(%rip),%xmm4
movss  0xc(%rsp),%xmm0
ucomiss 0xe41(%rip),%xmm0
jne    1170 <main+0x50>
jp     1170 <main+0x50>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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