#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 in;
  do {
    scanf("%f", &in);
    if (in == 0)
      break;
    int n = 2;
    float sum = 0.00;
    while (sum <= in) {
      sum += (1.00 / n);
      n++;
    }
    printf("%d card(s)\n", (n - 2));
  } while (in != 0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%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    11db <main+0xbb>
movl   $0x2,-0xc(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm1
movss  -0x8(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jb     11b2 <main+0x92>
cvtsi2sdl -0xc(%rbp),%xmm0
movsd  0xe76(%rip),%xmm1
divsd  %xmm0,%xmm1
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    116a <main+0x4a>
mov    -0xc(%rbp),%esi
sub    $0x2,%esi
lea    0xe4c(%rip),%rdi
call   1030 <printf@plt>
movss  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    112f <main+0xf>
jp     112f <main+0xf>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xed8(%rip),%r14
lea    0xc(%rsp),%rbx
lea    0xecf(%rip),%r15
jmp    115b <main+0x3b>
xchg   %ax,%ax
add    $0xfffffffe,%esi
mov    %r15,%rdi
call   1030 <printf@plt>
movss  0xc(%rsp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    115b <main+0x3b>
jnp    11b5 <main+0x95>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
xorps  %xmm1,%xmm1
movss  0xc(%rsp),%xmm0
ucomiss %xmm1,%xmm0
jne    1176 <main+0x56>
jnp    11b5 <main+0x95>
mov    $0x2,%esi
movsd  0xe7d(%rip),%xmm4
jb     1140 <main+0x20>
mov    $0x2,%esi
xorps  %xmm1,%xmm1
nopl   (%rax)
xorps  %xmm2,%xmm2
cvtsi2sd %esi,%xmm2
movapd %xmm4,%xmm3
divsd  %xmm2,%xmm3
cvtss2sd %xmm1,%xmm1
addsd  %xmm3,%xmm1
cvtsd2ss %xmm1,%xmm1
add    $0x1,%esi
ucomiss %xmm1,%xmm0
jae    1190 <main+0x70>
jmp    1140 <main+0x20>
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 float
store i32 0, i32* %1
br label %5
5: ; preds = %29, %0
%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 %32
10: ; preds = %5
store i32 2, i32* %3
store float 0.000000e+00, float* %4
br label %11
11: ; preds = %15, %10
%12 = load float, float* %4
%13 = load float, float* %2
%14 = fcmp ole float %12, %13
br i1 %14, label %15, label %25
15: ; preds = %11
%16 = load i32, i32* %3
%17 = sitofp i32 %16 to double
%18 = fdiv double 1.000000e+00, %17
%19 = load float, float* %4
%20 = fpext float %19 to double
%21 = fadd double %20, %18
%22 = fptrunc double %21 to float
store float %22, float* %4
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
br label %11
25: ; preds = %11
%26 = load i32, i32* %3
%27 = sub nsw i32 %26, 2
%28 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %25
%30 = load float, float* %2
%31 = fcmp une float %30, 0.000000e+00
br i1 %31, label %5, label %32
32: ; preds = %29, %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*
br label %3
3: ; preds = %19, %0
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %1)
%5 = load float, float* %1
%6 = fcmp oeq float %5, 0.000000e+00
br i1 %6, label %25, label %7
7: ; preds = %3
%8 = fcmp ult float %5, 0.000000e+00
br i1 %8, label %19, label %9
9: ; preds = %7, %9
%10 = phi float [ %16, %9 ], [ 0.000000e+00, %7 ]
%11 = phi i32 [ %17, %9 ], [ 2, %7 ]
%12 = sitofp i32 %11 to double
%13 = fdiv double 1.000000e+00, %12
%14 = fpext float %10 to double
%15 = fadd double %13, %14
%16 = fptrunc double %15 to float
%17 = add nuw nsw i32 %11, 1
%18 = fcmp ult float %5, %16
br i1 %18, label %19, label %9
19: ; preds = %9, %7
%20 = phi i32 [ 2, %7 ], [ %17, %9 ]
%21 = add nsw i32 %20, -2
%22 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %21)
%23 = load float, float* %1
%24 = fcmp une float %23, 0.000000e+00
br i1 %24, label %3, label %25
25: ; preds = %3, %19
ret i32 0
}