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


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    116b <errcheck+0x5b>
mov    0x2e8e(%rip),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rsi
lea    0xeb4(%rip),%rdi
call   1030 <WARNING@plt>
movsd  0xe9f(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11b5 <errcheck+0xa5>
mov    0x2e5e(%rip),%rax
mov    (%rax),%rax
mov    0x2e64(%rip),%rcx
cmp    (%rcx),%rax
jne    11b0 <errcheck+0xa0>
mov    0x2e44(%rip),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rsi
lea    0xe84(%rip),%rdi
call   1030 <WARNING@plt>
movsd  0xe55(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11b5 <errcheck+0xa5>
movsd  -0x8(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<errcheck>:
push   %rax
mov    %rdi,%rsi
mov    0x2eb5(%rip),%rax
mov    (%rax),%rcx
mov    0x2ec3(%rip),%rdx
cmp    (%rdx),%rcx
jne    1133 <errcheck+0x23>
lea    0xed7(%rip),%rdi
jmp    1146 <errcheck+0x36>
mov    0x2ea6(%rip),%rdx
cmp    (%rdx),%rcx
jne    115a <errcheck+0x4a>
lea    0xedc(%rip),%rdi
movq   $0x0,(%rax)
call   1030 <WARNING@plt>
movsd  0xea6(%rip),%xmm0
pop    %rax
ret

LLVM IR (-O0):
@errno = global i64 0
@EDOM = global i64 0
@.str = [26 x i8] c"%s argument out of domain\00"
@ERANGE = global i64 0
@.str.1 = [23 x i8] c"%s 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 @WARNING(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %9)
store double 1.000000e+00, double* %3
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 @WARNING(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %16)
store double 1.000000e+00, double* %3
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 = [26 x i8] c"%s argument out of domain\00"
@ERANGE = global i64 0
@.str.1 = [23 x i8] c"%s result out of range\00"
define double @errcheck(double %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 ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), %2 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), %6 ]
store i64 0, i64* @errno
%11 = tail call i32 @WARNING(i8* %10, i8* %1)
br label %12
12: ; preds = %9, %6
%13 = phi double [ %0, %6 ], [ 1.000000e+00, %9 ]
ret double %13
}