#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 INFINITY;
int /*<<< orphan*/ getchar();
double double_max() {
  double d, d_p, step;
  int i;
  d = 1;
  while (d != INFINITY) {
    d_p = d;
    d = d * 10;
    i++;
  };
  d = d_p;
  step = d;
  while (step > 1) {
    step = step / 10;
    i = 0;
    while ((d < INFINITY) && (d + step != d)) {
      d_p = d;
      d = d + step;
      i++;
      if (i == 30)
        getchar();
    };
    d = d_p;
  };
  return d;
}


x86 assembly (clang, -O0):
<double_max>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  0xee0(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    0x2eb7(%rip),%rax
ucomisd (%rax),%xmm0
jne    1146 <double_max+0x36>
jp     1146 <double_max+0x36>
jmp    1170 <double_max+0x60>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xeb0(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1125 <double_max+0x15>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe6f(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1248 <double_max+0x138>
movsd  -0x18(%rbp),%xmm0
movsd  0xe60(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movsd  -0x8(%rbp),%xmm1
mov    0x2e24(%rip),%rax
movsd  (%rax),%xmm0
xor    %eax,%eax
ucomisd %xmm1,%xmm0
mov    %al,-0x1d(%rbp)
jbe    11f1 <double_max+0xe1>
movsd  -0x8(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
ucomisd -0x8(%rbp),%xmm0
setne  %al
setp   %cl
or     %cl,%al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    1201 <double_max+0xf1>
jmp    1239 <double_max+0x129>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x1e,-0x1c(%rbp)
jne    1234 <double_max+0x124>
mov    $0x0,%al
call   1030 <getchar@plt>
jmp    11b8 <double_max+0xa8>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1184 <double_max+0x74>
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<double_max>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    0x2ecb(%rip),%rbx
movsd  (%rbx),%xmm4
ucomisd 0xed7(%rip),%xmm4
jne    1131 <double_max+0x21>
jnp    1200 <double_max+0xf0>
movsd  0xec7(%rip),%xmm1
nopl   0x0(%rax)
movapd %xmm1,%xmm2
mulsd  0xebc(%rip),%xmm1
ucomisd %xmm4,%xmm1
jne    1140 <double_max+0x30>
jp     1140 <double_max+0x30>
ucomisd 0xea4(%rip),%xmm2
jbe    1202 <double_max+0xf2>
movapd %xmm2,%xmm3
jmp    1186 <double_max+0x76>
nopl   0x0(%rax,%rax,1)
movapd %xmm3,%xmm0
ucomisd 0xe84(%rip),%xmm2
movapd %xmm0,%xmm3
jbe    1206 <double_max+0xf6>
divsd  0xe7a(%rip),%xmm2
ucomisd %xmm3,%xmm4
jbe    1170 <double_max+0x60>
movapd %xmm2,%xmm1
addsd  %xmm3,%xmm1
ucomisd %xmm3,%xmm1
jne    11a4 <double_max+0x94>
jnp    1170 <double_max+0x60>
mov    $0x1d,%ebp
movsd  %xmm2,(%rsp)
xchg   %ax,%ax
movapd %xmm3,%xmm0
movapd %xmm1,%xmm3
sub    $0x1,%ebp
jae    11e5 <double_max+0xd5>
xor    %eax,%eax
movsd  %xmm3,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
call   1030 <getchar@plt>
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm3
movsd  (%rsp),%xmm2
movsd  (%rbx),%xmm4
ucomisd %xmm3,%xmm4
jbe    1174 <double_max+0x64>
movapd %xmm2,%xmm1
addsd  %xmm3,%xmm1
ucomisd %xmm3,%xmm1
jne    11b0 <double_max+0xa0>
jp     11b0 <double_max+0xa0>
jmp    1174 <double_max+0x64>
jmp    1206 <double_max+0xf6>
movapd %xmm2,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@INFINITY = global double 0.000000e+00
define double @double_max() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca i32
store double 1.000000e+00, double* %1
br label %5
5: ; preds = %9, %0
%6 = load double, double* %1
%7 = load double, double* @INFINITY
%8 = fcmp une double %6, %7
br i1 %8, label %9, label %15
9: ; preds = %5
%10 = load double, double* %1
store double %10, double* %2
%11 = load double, double* %1
%12 = fmul double %11, 1.000000e+01
store double %12, double* %1
%13 = load i32, i32* %4
%14 = add nsw i32 %13, 1
store i32 %14, i32* %4
br label %5
15: ; preds = %5
%16 = load double, double* %2
store double %16, double* %1
%17 = load double, double* %1
store double %17, double* %3
br label %18
18: ; preds = %48, %15
%19 = load double, double* %3
%20 = fcmp ogt double %19, 1.000000e+00
br i1 %20, label %21, label %50
21: ; preds = %18
%22 = load double, double* %3
%23 = fdiv double %22, 1.000000e+01
store double %23, double* %3
store i32 0, i32* %4
br label %24
24: ; preds = %47, %21
%25 = load double, double* %1
%26 = load double, double* @INFINITY
%27 = fcmp olt double %25, %26
br i1 %27, label %28, label %34
28: ; preds = %24
%29 = load double, double* %1
%30 = load double, double* %3
%31 = fadd double %29, %30
%32 = load double, double* %1
%33 = fcmp une double %31, %32
br label %34
34: ; preds = %28, %24
%35 = phi i1 [ false, %24 ], [ %33, %28 ]
br i1 %35, label %36, label %48
36: ; preds = %34
%37 = load double, double* %1
store double %37, double* %2
%38 = load double, double* %1
%39 = load double, double* %3
%40 = fadd double %38, %39
store double %40, double* %1
%41 = load i32, i32* %4
%42 = add nsw i32 %41, 1
store i32 %42, i32* %4
%43 = load i32, i32* %4
%44 = icmp eq i32 %43, 30
br i1 %44, label %45, label %47
45: ; preds = %36
%46 = call i32 (...) @getchar()
br label %47
47: ; preds = %45, %36
br label %24
48: ; preds = %34
%49 = load double, double* %2
store double %49, double* %1
br label %18
50: ; preds = %18
%51 = load double, double* %1
ret double %51
}

LLVM IR (-O2):
@INFINITY = global double 0.000000e+00
define double @double_max() {
%1 = load double, double* @INFINITY
%2 = fcmp une double %1, 1.000000e+00
br i1 %2, label %5, label %40
3: ; preds = %5
%4 = fcmp ogt double %6, 1.000000e+00
br i1 %4, label %9, label %40
5: ; preds = %0, %5
%6 = phi double [ %7, %5 ], [ 1.000000e+00, %0 ]
%7 = fmul double %6, 1.000000e+01
%8 = fcmp une double %7, %1
br i1 %8, label %5, label %3
9: ; preds = %3, %35
%10 = phi double [ %36, %35 ], [ %1, %3 ]
%11 = phi double [ %37, %35 ], [ %1, %3 ]
%12 = phi double [ %14, %35 ], [ %6, %3 ]
%13 = phi double [ %38, %35 ], [ %6, %3 ]
%14 = fdiv double %12, 1.000000e+01
%15 = fcmp olt double %13, %11
%16 = fadd double %14, %13
%17 = fcmp une double %16, %13
%18 = select i1 %15, i1 %17, i1 false
br i1 %18, label %19, label %35
19: ; preds = %9, %29
%20 = phi double [ %32, %29 ], [ %16, %9 ]
%21 = phi double [ %20, %29 ], [ %13, %9 ]
%22 = phi i32 [ %24, %29 ], [ 0, %9 ]
%23 = phi double [ %30, %29 ], [ %10, %9 ]
%24 = add nuw nsw i32 %22, 1
%25 = icmp eq i32 %24, 30
br i1 %25, label %26, label %29
26: ; preds = %19
%27 = tail call i32 (...) @getchar()
%28 = load double, double* @INFINITY
br label %29
29: ; preds = %26, %19
%30 = phi double [ %28, %26 ], [ %23, %19 ]
%31 = fcmp olt double %20, %30
%32 = fadd double %14, %20
%33 = fcmp une double %32, %20
%34 = select i1 %31, i1 %33, i1 false
br i1 %34, label %19, label %35
35: ; preds = %29, %9
%36 = phi double [ %10, %9 ], [ %30, %29 ]
%37 = phi double [ %11, %9 ], [ %30, %29 ]
%38 = phi double [ %13, %9 ], [ %21, %29 ]
%39 = fcmp ogt double %14, 1.000000e+00
br i1 %39, label %9, label %40
40: ; preds = %35, %0, %3
%41 = phi double [ %6, %3 ], [ undef, %0 ], [ %38, %35 ]
ret double %41
}