#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__ EDOM;
scalar_t__ ERANGE;
scalar_t__ errno;
int /*<<< orphan*/ execerror(char *, char *);
double errcheck(double d, char *s) {
  if (errno == EDOM) {
    errno = 0;
    execerror(s, "argument out of domain");
  } else if (errno == ERANGE) {
    errno == 0;
    execerror(s, "result out of range");
  }
  return d;
}


x86 assembly (clang, -O0):
<errcheck>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    0x2ea8(%rip),%rax
mov    (%rax),%rax
mov    0x2eb6(%rip),%rcx
cmp    (%rcx),%rax
jne    115e <errcheck+0x4e>
mov    0x2e8e(%rip),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
lea    0xeac(%rip),%rsi
call   1030 <execerror@plt>
jmp    118d <errcheck+0x7d>
mov    0x2e6b(%rip),%rax
mov    (%rax),%rax
mov    0x2e71(%rip),%rcx
cmp    (%rcx),%rax
jne    1188 <errcheck+0x78>
mov    -0x10(%rbp),%rdi
lea    0xe94(%rip),%rsi
call   1030 <execerror@plt>
jmp    118d <errcheck+0x7d>
movsd  -0x8(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<errcheck>:
push   %rax
mov    0x2eb8(%rip),%rcx
mov    (%rcx),%rax
mov    0x2ec6(%rip),%rdx
cmp    (%rdx),%rax
jne    113c <errcheck+0x2c>
movsd  %xmm0,(%rsp)
movq   $0x0,(%rcx)
lea    0xec6(%rip),%rsi
jmp    1154 <errcheck+0x44>
mov    0x2e9d(%rip),%rcx
cmp    (%rcx),%rax
jne    115e <errcheck+0x4e>
movsd  %xmm0,(%rsp)
lea    0xec3(%rip),%rsi
call   1030 <execerror@plt>
movsd  (%rsp),%xmm0
pop    %rax
ret

LLVM IR (-O0):
@errno = global i64 0
@EDOM = global i64 0
@.str = [23 x i8] c"argument out of domain\00"
@ERANGE = global i64 0
@.str.1 = [20 x i8] c"result out of range\00"
define double @errcheck(double %0, i8* %1) {
%3 = alloca double
%4 = alloca i8*
store double %0, double* %3
store i8* %1, i8** %4
%5 = load i64, i64* @errno
%6 = load i64, i64* @EDOM
%7 = icmp eq i64 %5, %6
br i1 %7, label %8, label %11
8: ; preds = %2
store i64 0, i64* @errno
%9 = load i8*, i8** %4
%10 = call i32 @execerror(i8* %9, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %22
11: ; preds = %2
%12 = load i64, i64* @errno
%13 = load i64, i64* @ERANGE
%14 = icmp eq i64 %12, %13
br i1 %14, label %15, label %21
15: ; preds = %11
%16 = load i64, i64* @errno
%17 = icmp eq i64 %16, 0
%18 = zext i1 %17 to i32
%19 = load i8*, i8** %4
%20 = call i32 @execerror(i8* %19, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %21
21: ; preds = %15, %11
br label %22
22: ; preds = %21, %8
%23 = load double, double* %3
ret double %23
}

LLVM IR (-O2):
@errno = global i64 0
@EDOM = global i64 0
@.str = [23 x i8] c"argument out of domain\00"
@ERANGE = global i64 0
@.str.1 = [20 x i8] c"result out of range\00"
define double @errcheck(double returned %0, i8* %1) {
%3 = load i64, i64* @errno
%4 = load i64, i64* @EDOM
%5 = icmp eq i64 %3, %4
br i1 %5, label %6, label %7
6: ; preds = %2
store i64 0, i64* @errno
br label %10
7: ; preds = %2
%8 = load i64, i64* @ERANGE
%9 = icmp eq i64 %3, %8
br i1 %9, label %10, label %13
10: ; preds = %7, %6
%11 = phi i8* [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), %6 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), %7 ]
%12 = tail call i32 @execerror(i8* %1, i8* %11)
br label %13
13: ; preds = %10, %7
ret double %0
}