#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*/ assert(int);
scalar_t__ errno;
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ sqrt(double);
int main(void) {
  assert(errno == 0);
  perror("No error reported as");
  errno = ERANGE;
  assert(errno == ERANGE);
  perror("Range error reported as");
  errno = 0;
  assert(errno == 0);
  sqrt(-1.0);
  assert(errno == EDOM);
  perror("Domain error reported as");
  puts("SUCCESS testing <error.h>");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e7a(%rip),%rax
cmpq   $0x0,(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    0xe9a(%rip),%rdi
call   1050 <perror@plt>
mov    0x2e66(%rip),%rax
mov    (%rax),%rcx
mov    0x2e4c(%rip),%rax
mov    %rcx,(%rax)
mov    0x2e42(%rip),%rax
mov    (%rax),%rax
mov    0x2e48(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    0xe6e(%rip),%rdi
call   1050 <perror@plt>
mov    0x2e15(%rip),%rax
movq   $0x0,(%rax)
mov    0x2e07(%rip),%rax
cmpq   $0x0,(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movsd  0xe1e(%rip),%xmm0
call   1060 <sqrt@plt>
mov    0x2de2(%rip),%rax
mov    (%rax),%rax
mov    0x2df0(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    0xe26(%rip),%rdi
call   1050 <perror@plt>
lea    0xe33(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    0x2e88(%rip),%rbx
xor    %edi,%edi
cmpq   $0x0,(%rbx)
sete   %dil
call   1040 <assert@plt>
lea    0xeaa(%rip),%rdi
call   1050 <perror@plt>
mov    0x2e76(%rip),%rax
mov    (%rax),%rax
mov    %rax,(%rbx)
mov    $0x1,%edi
call   1040 <assert@plt>
lea    0xe9c(%rip),%rdi
call   1050 <perror@plt>
movq   $0x0,(%rbx)
mov    $0x1,%edi
call   1040 <assert@plt>
movsd  0xe61(%rip),%xmm0
call   1060 <sqrt@plt>
mov    (%rbx),%rax
mov    0x2e3a(%rip),%rcx
xor    %edi,%edi
cmp    (%rcx),%rax
sete   %dil
call   1040 <assert@plt>
lea    0xe72(%rip),%rdi
call   1050 <perror@plt>
lea    0xe7f(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@errno = global i64 0
@.str = [21 x i8] c"No error reported as\00"
@ERANGE = global i64 0
@.str.1 = [24 x i8] c"Range error reported as\00"
@EDOM = global i64 0
@.str.2 = [25 x i8] c"Domain error reported as\00"
@.str.3 = [26 x i8] c"SUCCESS testing <error.h>\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = load i64, i64* @errno
%3 = icmp eq i64 %2, 0
%4 = zext i1 %3 to i32
%5 = call i32 @assert(i32 %4)
%6 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%7 = load i64, i64* @ERANGE
store i64 %7, i64* @errno
%8 = load i64, i64* @errno
%9 = load i64, i64* @ERANGE
%10 = icmp eq i64 %8, %9
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
store i64 0, i64* @errno
%14 = load i64, i64* @errno
%15 = icmp eq i64 %14, 0
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = call i32 @sqrt(double -1.000000e+00)
%19 = load i64, i64* @errno
%20 = load i64, i64* @EDOM
%21 = icmp eq i64 %19, %20
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
%24 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%25 = call i32 @puts(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@errno = global i64 0
@.str = [21 x i8] c"No error reported as\00"
@ERANGE = global i64 0
@.str.1 = [24 x i8] c"Range error reported as\00"
@EDOM = global i64 0
@.str.2 = [25 x i8] c"Domain error reported as\00"
@.str.3 = [26 x i8] c"SUCCESS testing <error.h>\00"
define i32 @main() {
%1 = load i64, i64* @errno
%2 = icmp eq i64 %1, 0
%3 = zext i1 %2 to i32
%4 = tail call i32 @assert(i32 %3)
%5 = tail call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%6 = load i64, i64* @ERANGE
store i64 %6, i64* @errno
%7 = tail call i32 @assert(i32 1)
%8 = tail call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
store i64 0, i64* @errno
%9 = tail call i32 @assert(i32 1)
%10 = tail call i32 @sqrt(double -1.000000e+00)
%11 = load i64, i64* @errno
%12 = load i64, i64* @EDOM
%13 = icmp eq i64 %11, %12
%14 = zext i1 %13 to i32
%15 = tail call i32 @assert(i32 %14)
%16 = tail call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}