#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__ ERANGE;
scalar_t__ errno;
double exp(double);
int /*<<< orphan*/ printf(char *, double);
int main(void) {
  double param, result;
  errno = 0;
  for (param = 1;; param = param + 1) {
    result = exp(param);
    if (errno == ERANGE) {
      printf("exp(%f) overflows\n", param);
      break;
    }
  }
  errno = 0;
  for (param = -1;; param = param - 1) {
    result = exp(param);
    if (errno == ERANGE) {
      printf("exp(%f) overflows\n", param);
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2ea2(%rip),%rax
movq   $0x0,(%rax)
movsd  0xebb(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <exp@plt>
movsd  %xmm0,-0x18(%rbp)
mov    0x2e78(%rip),%rax
mov    (%rax),%rax
mov    0x2e7e(%rip),%rcx
cmp    (%rcx),%rax
jne    1189 <main+0x69>
movsd  -0x10(%rbp),%xmm0
lea    0xe91(%rip),%rdi
call   1030 <printf@plt>
jmp    11a5 <main+0x85>
jmp    118e <main+0x6e>
movsd  0xe6a(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    114a <main+0x2a>
mov    0x2e2c(%rip),%rax
movq   $0x0,(%rax)
movsd  0xe4d(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <exp@plt>
movsd  %xmm0,-0x18(%rbp)
mov    0x2e02(%rip),%rax
mov    (%rax),%rax
mov    0x2e08(%rip),%rcx
cmp    (%rcx),%rax
jne    11ff <main+0xdf>
movsd  -0x10(%rbp),%xmm0
lea    0xe1b(%rip),%rdi
call   1030 <printf@plt>
jmp    121f <main+0xff>
jmp    1204 <main+0xe4>
movsd  -0x10(%rbp),%xmm0
movsd  0xdef(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    11c0 <main+0xa0>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    0x2ead(%rip),%r14
movq   $0x0,(%r14)
movsd  0xec6(%rip),%xmm2
xor    %eax,%eax
movsd  0xec4(%rip),%xmm0
mov    0x2e9d(%rip),%rbx
movsd  0xebd(%rip),%xmm1
movapd %xmm2,%xmm3
ucomisd %xmm0,%xmm3
ja     1175 <main+0x55>
nopl   (%rax)
ucomisd %xmm3,%xmm1
ja     1175 <main+0x55>
cmp    (%rbx),%rax
je     11a8 <main+0x88>
addsd  %xmm2,%xmm3
ucomisd %xmm0,%xmm3
jbe    1160 <main+0x40>
movapd %xmm3,%xmm0
movsd  %xmm3,(%rsp)
call   1040 <exp@plt>
movsd  (%rsp),%xmm3
movsd  0xe70(%rip),%xmm2
movsd  0xe78(%rip),%xmm1
movsd  0xe68(%rip),%xmm0
mov    (%r14),%rax
cmp    (%rbx),%rax
jne    116b <main+0x4b>
lea    0xe71(%rip),%rdi
movapd %xmm3,%xmm0
call   1030 <printf@plt>
movsd  0xe50(%rip),%xmm1
movsd  0xe40(%rip),%xmm0
movq   $0x0,(%r14)
movsd  0xe41(%rip),%xmm3
xor    %eax,%eax
movapd %xmm3,%xmm2
ucomisd %xmm0,%xmm2
ja     1205 <main+0xe5>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
ucomisd %xmm2,%xmm1
ja     1205 <main+0xe5>
cmp    (%rbx),%rax
je     1238 <main+0x118>
addsd  %xmm3,%xmm2
ucomisd %xmm0,%xmm2
jbe    11f0 <main+0xd0>
movapd %xmm2,%xmm0
movsd  %xmm2,(%rsp)
call   1040 <exp@plt>
movsd  0xdfd(%rip),%xmm3
movsd  (%rsp),%xmm2
movsd  0xde8(%rip),%xmm1
movsd  0xdd8(%rip),%xmm0
mov    (%r14),%rax
cmp    (%rbx),%rax
jne    11fb <main+0xdb>
lea    0xde1(%rip),%rdi
movapd %xmm2,%xmm0
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@errno = global i64 0
@ERANGE = global i64 0
@.str = [19 x i8] c"exp(%f) overflows\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
store i32 0, i32* %1
store i64 0, i64* @errno
store double 1.000000e+00, double* %2
br label %4
4: ; preds = %14, %0
%5 = load double, double* %2
%6 = call double @exp(double %5)
store double %6, double* %3
%7 = load i64, i64* @errno
%8 = load i64, i64* @ERANGE
%9 = icmp eq i64 %7, %8
br i1 %9, label %10, label %13
10: ; preds = %4
%11 = load double, double* %2
%12 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), double %11)
br label %17
13: ; preds = %4
br label %14
14: ; preds = %13
%15 = load double, double* %2
%16 = fadd double %15, 1.000000e+00
store double %16, double* %2
br label %4
17: ; preds = %10
store i64 0, i64* @errno
store double -1.000000e+00, double* %2
br label %18
18: ; preds = %28, %17
%19 = load double, double* %2
%20 = call double @exp(double %19)
store double %20, double* %3
%21 = load i64, i64* @errno
%22 = load i64, i64* @ERANGE
%23 = icmp eq i64 %21, %22
br i1 %23, label %24, label %27
24: ; preds = %18
%25 = load double, double* %2
%26 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), double %25)
br label %31
27: ; preds = %18
br label %28
28: ; preds = %27
%29 = load double, double* %2
%30 = fsub double %29, 1.000000e+00
store double %30, double* %2
br label %18
31: ; preds = %24
ret i32 0
}

LLVM IR (-O2):
@errno = global i64 0
@ERANGE = global i64 0
@.str = [19 x i8] c"exp(%f) overflows\0A\00"
define i32 @main() {
store i64 0, i64* @errno
br label %1
1: ; preds = %16, %0
%2 = phi i64 [ 0, %0 ], [ %11, %16 ]
%3 = phi double [ 1.000000e+00, %0 ], [ %17, %16 ]
%4 = fcmp olt double %3, -7.450000e+02
%5 = fcmp ogt double %3, 7.090000e+02
%6 = or i1 %5, %4
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = tail call double @exp(double %3)
%9 = load i64, i64* @errno
br label %10
10: ; preds = %1, %7
%11 = phi i64 [ %2, %1 ], [ %9, %7 ]
%12 = load i64, i64* @ERANGE
%13 = icmp eq i64 %11, %12
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), double %3)
store i64 0, i64* @errno
br label %18
16: ; preds = %10
%17 = fadd double %3, 1.000000e+00
br label %1
18: ; preds = %33, %14
%19 = phi i64 [ 0, %14 ], [ %28, %33 ]
%20 = phi double [ -1.000000e+00, %14 ], [ %34, %33 ]
%21 = fcmp olt double %20, -7.450000e+02
%22 = fcmp ogt double %20, 7.090000e+02
%23 = or i1 %22, %21
br i1 %23, label %24, label %27
24: ; preds = %18
%25 = tail call double @exp(double %20)
%26 = load i64, i64* @errno
br label %27
27: ; preds = %18, %24
%28 = phi i64 [ %19, %18 ], [ %26, %24 ]
%29 = load i64, i64* @ERANGE
%30 = icmp eq i64 %28, %29
br i1 %30, label %31, label %33
31: ; preds = %27
%32 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), double %20)
ret i32 0
33: ; preds = %27
%34 = fadd double %20, -1.000000e+00
br label %18
}