#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, "arugument 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    119b <errcheck+0x8b>
mov    0x2e6b(%rip),%rax
mov    (%rax),%rax
mov    0x2e71(%rip),%rcx
cmp    (%rcx),%rax
jne    1196 <errcheck+0x86>
mov    0x2e51(%rip),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
lea    0xe87(%rip),%rsi
call   1030 <execerror@plt>
jmp    119b <errcheck+0x8b>
movsd  -0x8(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<errcheck>:
push   %rax
mov    0x2eb8(%rip),%rax
mov    (%rax),%rcx
mov    0x2ec6(%rip),%rdx
cmp    (%rdx),%rcx
jne    1135 <errcheck+0x25>
movsd  %xmm0,(%rsp)
lea    0xecd(%rip),%rsi
jmp    114d <errcheck+0x3d>
mov    0x2ea4(%rip),%rdx
cmp    (%rdx),%rcx
jne    115e <errcheck+0x4e>
movsd  %xmm0,(%rsp)
lea    0xecb(%rip),%rsi
movq   $0x0,(%rax)
call   1030 <execerror@plt>
movsd  (%rsp),%xmm0
pop    %rax
ret

LLVM IR (-O0):
@errno = global i64 0
@EDOM = global i64 0
@.str = [24 x i8] c"arugument 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 ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
br label %19
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 %18
15: ; preds = %11
store i64 0, i64* @errno
%16 = load i8*, i8** %4
%17 = call i32 @execerror(i8* %16, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %15, %11
br label %19
19: ; preds = %18, %8
%20 = load double, double* %3
ret double %20
}

LLVM IR (-O2):
@errno = global i64 0
@EDOM = global i64 0
@.str = [24 x i8] c"arugument 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 %9, label %6
6: ; preds = %2
%7 = load i64, i64* @ERANGE
%8 = icmp eq i64 %3, %7
br i1 %8, label %9, label %12
9: ; preds = %6, %2
%10 = phi i8* [ getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), %2 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), %6 ]
store i64 0, i64* @errno
%11 = tail call i32 @execerror(i8* %1, i8* %10)
br label %12
12: ; preds = %9, %6
ret double %0
}