#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 */
double atof(char *);
int /*<<< orphan*/ printf(char *, long);
int /*<<< orphan*/ scanf(char *, char *);
scalar_t__ strcmp(char *, char *);
int main(void) {
  char s[5];
  int flag = 0;
  long i;
  double t = 0;
  double sum;
  while (1) {
    scanf("%s", s);
    if (strcmp(s, "0.00") == 0) {
      break;
    }
    t = atof(s);
    sum = 0;
    i = 0;
    while (sum <= t) {
      sum += (double)1 / (double)(1 + (++i));
    }
    printf("%ld card(s)\n", i);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
lea    -0x9(%rbp),%rsi
lea    0xe9f(%rip),%rdi
call   1060 <scanf@plt>
lea    -0x9(%rbp),%rdi
lea    0xe92(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    118d <main+0x4d>
jmp    1204 <main+0xc4>
lea    -0x9(%rbp),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movq   $0x0,-0x18(%rbp)
movsd  -0x28(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     11ef <main+0xaf>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
add    $0x1,%rax
cvtsi2sd %rax,%xmm1
movsd  0xe24(%rip),%xmm0
divsd  %xmm1,%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11ab <main+0x6b>
mov    -0x18(%rbp),%rsi
lea    0xe16(%rip),%rdi
call   1040 <printf@plt>
jmp    115e <main+0x1e>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xec1(%rip),%rdi
lea    0x3(%rsp),%rbx
mov    %rbx,%rsi
call   1060 <scanf@plt>
lea    0xeb0(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1207 <main+0xc7>
lea    0x3(%rsp),%rbx
lea    0xe98(%rip),%r14
lea    0xe89(%rip),%r15
lea    0xe85(%rip),%r12
jmp    11b5 <main+0x75>
xor    %esi,%esi
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1207 <main+0xc7>
mov    %rbx,%rdi
call   1030 <atof@plt>
ucomisd 0xe43(%rip),%xmm0
jb     1190 <main+0x50>
xorpd  %xmm1,%xmm1
xor    %eax,%eax
movsd  0xe2b(%rip),%xmm4
cs nopw 0x0(%rax,%rax,1)
nop
lea    0x1(%rax),%rsi
add    $0x2,%rax
xorps  %xmm2,%xmm2
cvtsi2sd %rax,%xmm2
movapd %xmm4,%xmm3
divsd  %xmm2,%xmm3
addsd  %xmm3,%xmm1
ucomisd %xmm1,%xmm0
mov    %rsi,%rax
jae    11e0 <main+0xa0>
jmp    1192 <main+0x52>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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