#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 /*<<< orphan*/ scanf(char *, double *);
void main() {
  double real;
  printf("Problem 11: Egyptian fraction sum with least operands of real number "
         "\n");
  scanf("%lf", &real);
  int i = 2;
  double remover;
  while (real > 0 && real > 0.0001f) {
    remover = 1 / (float)i;
    if (remover <= real) {
      real -= remover;
      printf("1/%d", i);
      if (real > 0.0001f && real > 0)
        printf(", ");
    }
    i++;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xedd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf16(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x2,-0xc(%rbp)
movsd  -0x8(%rbp),%xmm0
xor    %eax,%eax
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x19(%rbp)
jbe    117b <main+0x5b>
movsd  -0x8(%rbp),%xmm0
movsd  0xe8f(%rip),%xmm1
ucomisd %xmm1,%xmm0
seta   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    118b <main+0x6b>
jmp    1227 <main+0x107>
cvtsi2ssl -0xc(%rbp),%xmm1
movss  0xe70(%rip),%xmm0
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     1219 <main+0xf9>
movsd  -0x18(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  -0x8(%rbp),%xmm0
movsd  0xe16(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1214 <main+0xf4>
movsd  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1214 <main+0xf4>
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1219 <main+0xf9>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114d <main+0x2d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xee0(%rip),%rdi
call   1030 <puts@plt>
lea    0xec8(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
movsd  0x8(%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    121f <main+0xef>
ucomisd 0xe8e(%rip),%xmm0
jbe    121f <main+0xef>
mov    $0x2,%ebx
movsd  0xe7b(%rip),%xmm3
lea    0xe8c(%rip),%r14
lea    0xe8a(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xorps  %xmm1,%xmm1
cvtsi2ss %ebx,%xmm1
movss  0xe61(%rip),%xmm2
divss  %xmm1,%xmm2
xorps  %xmm1,%xmm1
cvtss2sd %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jb     120c <main+0xdc>
subsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movsd  0xe22(%rip),%xmm3
movsd  0x8(%rsp),%xmm0
ucomisd %xmm3,%xmm0
jbe    120c <main+0xdc>
ucomisd 0xe16(%rip),%xmm0
jbe    120c <main+0xdc>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsd  0xdfa(%rip),%xmm3
movsd  0x8(%rsp),%xmm0
ucomisd 0xdf4(%rip),%xmm0
jbe    121f <main+0xef>
add    $0x1,%ebx
ucomisd %xmm3,%xmm0
ja     11a0 <main+0x70>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [71 x i8] c"Problem 11: Egyptian fraction sum with least operands of real number \0A\00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [5 x i8] c"1/%d\00"
@.str.3 = [3 x i8] c", \00"
define void @main() {
%1 = alloca double
%2 = alloca i32
%3 = alloca double
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %1)
store i32 2, i32* %2
br label %6
6: ; preds = %36, %0
%7 = load double, double* %1
%8 = fcmp ogt double %7, 0.000000e+00
br i1 %8, label %9, label %12
9: ; preds = %6
%10 = load double, double* %1
%11 = fcmp ogt double %10, 0x3F1A36E2E0000000
br label %12
12: ; preds = %9, %6
%13 = phi i1 [ false, %6 ], [ %11, %9 ]
br i1 %13, label %14, label %39
14: ; preds = %12
%15 = load i32, i32* %2
%16 = sitofp i32 %15 to float
%17 = fdiv float 1.000000e+00, %16
%18 = fpext float %17 to double
store double %18, double* %3
%19 = load double, double* %3
%20 = load double, double* %1
%21 = fcmp ole double %19, %20
br i1 %21, label %22, label %36
22: ; preds = %14
%23 = load double, double* %3
%24 = load double, double* %1
%25 = fsub double %24, %23
store double %25, double* %1
%26 = load i32, i32* %2
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %26)
%28 = load double, double* %1
%29 = fcmp ogt double %28, 0x3F1A36E2E0000000
br i1 %29, label %30, label %35
30: ; preds = %22
%31 = load double, double* %1
%32 = fcmp ogt double %31, 0.000000e+00
br i1 %32, label %33, label %35
33: ; preds = %30
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %35
35: ; preds = %33, %30, %22
br label %36
36: ; preds = %35, %14
%37 = load i32, i32* %2
%38 = add nsw i32 %37, 1
store i32 %38, i32* %2
br label %6
39: ; preds = %12
ret void
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [5 x i8] c"1/%d\00"
@.str.3 = [3 x i8] c", \00"
@str = [70 x i8] c"Problem 11: Egyptian fraction sum with least operands of real number \00"
define void @main() {
%1 = alloca double
%2 = bitcast double* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([70 x i8], [70 x i8]* @str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %1)
%5 = load double, double* %1
%6 = fcmp ogt double %5, 0.000000e+00
%7 = fcmp ogt double %5, 0x3F1A36E2E0000000
%8 = and i1 %6, %7
br i1 %8, label %9, label %32
9: ; preds = %0, %26
%10 = phi double [ %27, %26 ], [ %5, %0 ]
%11 = phi i32 [ %28, %26 ], [ 2, %0 ]
%12 = sitofp i32 %11 to float
%13 = fdiv float 1.000000e+00, %12
%14 = fpext float %13 to double
%15 = fcmp ult double %10, %14
br i1 %15, label %26, label %16
16: ; preds = %9
%17 = fsub double %10, %14
store double %17, double* %1
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%19 = load double, double* %1
%20 = fcmp ogt double %19, 0x3F1A36E2E0000000
%21 = fcmp ogt double %19, 0.000000e+00
%22 = and i1 %20, %21
br i1 %22, label %23, label %26
23: ; preds = %16
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%25 = load double, double* %1
br label %26
26: ; preds = %16, %23, %9
%27 = phi double [ %19, %16 ], [ %25, %23 ], [ %10, %9 ]
%28 = add nuw nsw i32 %11, 1
%29 = fcmp ogt double %27, 0.000000e+00
%30 = fcmp ogt double %27, 0x3F1A36E2E0000000
%31 = and i1 %29, %30
br i1 %31, label %9, label %32
32: ; preds = %26, %0
ret void
}