#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;
      }
      printf("(%d, %d)\n", left, right);
    } 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     12fc <main+0x1dc>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11ee <main+0xce>
jp     11ee <main+0xce>
jmp    12fc <main+0x1dc>
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    12e3 <main+0x1c3>
jmp    12af <main+0x18f>
jmp    12b4 <main+0x194>
mov    -0x97c(%rbp),%esi
mov    -0x980(%rbp),%edx
lea    0xd45(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x980(%rbp),%eax
sub    -0x97c(%rbp),%eax
cmp    $0x1,%eax
jne    1202 <main+0xe2>
mov    -0x980(%rbp),%esi
lea    0xd26(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b1 <main+0x91>
xor    %eax,%eax
add    $0x980,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x978,%rsp
movq   $0x0,0x10(%rsp)
xorpd  %xmm1,%xmm1
mov    $0x3,%eax
mov    $0x2,%ecx
movsd  0xeb0(%rip),%xmm0
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),%rcx
cmp    (%rcx),%rax
je     129b <main+0x17b>
movsd  0x8(%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11cb <main+0xab>
jnp    129b <main+0x17b>
mov    $0x12b,%ebp
lea    0xe3d(%rip),%r13
lea    0xe40(%rip),%r14
lea    0xe2b(%rip),%r15
lea    0x8(%rsp),%r12
xor    %ebx,%ebx
jmp    11f6 <main+0xd6>
xchg   %ax,%ax
movsd  0x8(%rsp),%xmm0
lea    (%rbx,%rbp,1),%eax
mov    %eax,%esi
shr    $0x1f,%esi
add    %eax,%esi
sar    %esi
movslq %esi,%rax
movsd  0x10(%rsp,%rax,8),%xmm1
ucomisd %xmm0,%xmm1
jbe    1220 <main+0x100>
mov    %esi,%ebp
jmp    1240 <main+0x120>
cs nopw 0x0(%rax,%rax,1)
nop
ucomisd %xmm1,%xmm0
jbe    1230 <main+0x110>
mov    %esi,%ebx
jmp    1240 <main+0x120>
nopw   0x0(%rax,%rax,1)
ucomisd %xmm0,%xmm1
jne    1240 <main+0x120>
jnp    1259 <main+0x139>
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebp,%eax
sub    %ebx,%eax
cmp    $0x1,%eax
jne    11f0 <main+0xd0>
mov    %ebp,%esi
xor    %ebx,%ebx
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <scanf@plt>
mov    0x2d71(%rip),%rcx
cmp    (%rcx),%rax
je     129b <main+0x17b>
movsd  0x8(%rsp),%xmm0
ucomisd 0xd7e(%rip),%xmm0
mov    $0x12b,%ebp
jne    11f6 <main+0xd6>
jp     11f6 <main+0xd6>
xor    %eax,%eax
add    $0x978,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%lf\00"
@EOF = global i64 0
@.str.1 = [10 x i8] c"(%d, %d)\0A\00"
@.str.2 = [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 = %81, %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 %84
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 %84
38: ; preds = %34
store i32 0, i32* %6
store i32 299, i32* %7
br label %39
39: ; preds = %76, %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 %81
70: ; preds = %61
br label %71
71: ; preds = %70, %59
br label %72
72: ; preds = %71, %50
%73 = load i32, i32* %6
%74 = load i32, i32* %7
%75 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %73, i32 %74)
br label %76
76: ; preds = %72
%77 = load i32, i32* %7
%78 = load i32, i32* %6
%79 = sub nsw i32 %77, %78
%80 = icmp ne i32 %79, 1
br i1 %80, label %39, label %81
81: ; preds = %76, %68
%82 = load i32, i32* %7
%83 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %82)
br label %30
84: ; preds = %37, %30
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%lf\00"
@EOF = global i64 0
@.str.1 = [10 x i8] c"(%d, %d)\0A\00"
@.str.2 = [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 %65, 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, %52
%31 = phi double [ %53, %52 ], [ %10, %6 ]
%32 = phi i32 [ %54, %52 ], [ 0, %6 ]
%33 = phi i32 [ %55, %52 ], [ 299, %6 ]
%34 = add nsw i32 %33, %32
%35 = sdiv i32 %34, 2
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [300 x double], [300 x double]* %2, i64 0, i64 %36
%38 = load double, double* %37
%39 = fcmp ogt double %38, %31
br i1 %39, label %44, label %40
40: ; preds = %30
%41 = fcmp olt double %38, %31
br i1 %41, label %44, label %42
42: ; preds = %40
%43 = fcmp oeq double %38, %31
br i1 %43, label %56, label %44
44: ; preds = %40, %30, %42
%45 = phi i32 [ %32, %42 ], [ %32, %30 ], [ %35, %40 ]
%46 = phi i32 [ %33, %42 ], [ %35, %30 ], [ %33, %40 ]
%47 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %45, i32 %46)
%48 = sub nsw i32 %46, %45
%49 = icmp eq i32 %48, 1
br i1 %49, label %56, label %50
50: ; preds = %44
%51 = load double, double* %1
br label %52
52: ; preds = %50, %56
%53 = phi double [ %51, %50 ], [ %62, %56 ]
%54 = phi i32 [ %45, %50 ], [ 0, %56 ]
%55 = phi i32 [ %46, %50 ], [ 299, %56 ]
br label %30
56: ; preds = %42, %44
%57 = phi i32 [ %46, %44 ], [ %35, %42 ]
%58 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %57)
%59 = call i64 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %1)
%60 = load i64, i64* @EOF
%61 = icmp eq i64 %59, %60
%62 = load double, double* %1
%63 = fcmp oeq double %62, 0.000000e+00
%64 = select i1 %61, i1 true, i1 %63
br i1 %64, label %65, label %52
65: ; preds = %56, %6
ret i32 0
}