#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 */
int CheckSet(char *);
int /*<<< orphan*/ SetNumerics(float *, float *, float *, float *);
int /*<<< orphan*/ WrMessage(char *);
int errno;
int /*<<< orphan*/ printf(char *, ...);
float sqrt(float);
char *strerror(int);
void WrNumericErrors(void) {
  int check;
  int err_no;
  float large_val;
  float small_val;
  float zero_val;
  float negative_val;
  float result;
  SetNumerics(&large_val, &small_val, &zero_val, &negative_val);
  WrMessage("@NUMERIC-ERRORS");
  check = CheckSet("@OVERFLOW");
  if (check) {
    WrMessage("@NUMERIC-OVERFLOW");
    errno = 0;
    result = large_val / small_val;
    err_no = errno;
    printf("Result: %g\n", result);
    printf("System error: %s\n\n", strerror(err_no));
    WrMessage("@NUMERIC-CONTINUE");
  }
  check = CheckSet("@UNDERFLOW");
  if (check) {
    WrMessage("@NUMERIC-UNDERFLOW");
    errno = 0;
    result = small_val / large_val;
    err_no = errno;
    printf("Result: %g\n", result);
    printf("System error: %s\n\n", strerror(err_no));
    WrMessage("@NUMERIC-CONTINUE");
  }
  check = CheckSet("@DIVISION");
  if (check) {
    WrMessage("@NUMERIC-DIVISION");
    errno = 0;
    result = 1.0 / zero_val;
    err_no = errno;
    printf("Result: %g\n", result);
    printf("System error: %s\n\n", strerror(err_no));
    WrMessage("@NUMERIC-CONTINUE");
  }
  check = CheckSet("@DOMAIN");
  if (check) {
    WrMessage("@NUMERIC-DOMAIN");
    errno = 0;
    result = sqrt(negative_val);
    err_no = errno;
    printf("Result: %g\n", result);
    printf("System error: %s\n\n", strerror(err_no));
    WrMessage("@NUMERIC-CONTINUE");
  }
  return;
}


x86 assembly (clang, -O0):
<WrNumericErrors>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    -0xc(%rbp),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
lea    -0x18(%rbp),%rcx
call   1050 <SetNumerics@plt>
lea    0xe84(%rip),%rdi
call   1070 <WrMessage@plt>
lea    0xe88(%rip),%rdi
call   1030 <CheckSet@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     1212 <WrNumericErrors+0xb2>
lea    0xe79(%rip),%rdi
call   1070 <WrMessage@plt>
mov    0x2e2b(%rip),%rax
movl   $0x0,(%rax)
movss  -0xc(%rbp),%xmm0
divss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
mov    0x2e0f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe4e(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
call   1080 <strerror@plt>
mov    %rax,%rsi
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe46(%rip),%rdi
call   1070 <WrMessage@plt>
lea    0xe4c(%rip),%rdi
call   1030 <CheckSet@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     129b <WrNumericErrors+0x13b>
lea    0xe3e(%rip),%rdi
call   1070 <WrMessage@plt>
mov    0x2da2(%rip),%rax
movl   $0x0,(%rax)
movss  -0x10(%rbp),%xmm0
divss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
mov    0x2d86(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdc5(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
call   1080 <strerror@plt>
mov    %rax,%rsi
lea    0xdb8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdbd(%rip),%rdi
call   1070 <WrMessage@plt>
lea    0xde1(%rip),%rdi
call   1030 <CheckSet@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     1333 <WrNumericErrors+0x1d3>
lea    0xdd2(%rip),%rdi
call   1070 <WrMessage@plt>
mov    0x2d19(%rip),%rax
movl   $0x0,(%rax)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xd22(%rip),%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
mov    0x2cee(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd2d(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
call   1080 <strerror@plt>
mov    %rax,%rsi
lea    0xd20(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd25(%rip),%rdi
call   1070 <WrMessage@plt>
lea    0xd65(%rip),%rdi
call   1030 <CheckSet@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     13bc <WrNumericErrors+0x25c>
lea    0xd54(%rip),%rdi
call   1070 <WrMessage@plt>
mov    0x2c81(%rip),%rax
movl   $0x0,(%rax)
movss  -0x18(%rbp),%xmm0
call   1060 <sqrt@plt>
movss  %xmm0,-0x1c(%rbp)
mov    0x2c65(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xca4(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
call   1080 <strerror@plt>
mov    %rax,%rsi
lea    0xc97(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xc9c(%rip),%rdi
call   1070 <WrMessage@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<WrNumericErrors>:
push   %rbx
sub    $0x10,%rsp
lea    0x4(%rsp),%rdi
mov    %rsp,%rsi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
call   1050 <SetNumerics@plt>
lea    0xe81(%rip),%rdi
call   1070 <WrMessage@plt>
lea    0xe85(%rip),%rdi
call   1030 <CheckSet@plt>
test   %eax,%eax
je     11f2 <WrNumericErrors+0x92>
lea    0xe7f(%rip),%rdi
call   1070 <WrMessage@plt>
mov    0x2e35(%rip),%rax
movl   $0x0,(%rax)
movss  0x4(%rsp),%xmm0
divss  (%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe69(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1080 <strerror@plt>
lea    0xe60(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe62(%rip),%rdi
call   1070 <WrMessage@plt>
lea    0xe68(%rip),%rdi
call   1030 <CheckSet@plt>
test   %eax,%eax
je     125c <WrNumericErrors+0xfc>
lea    0xe63(%rip),%rdi
call   1070 <WrMessage@plt>
mov    0x2dcb(%rip),%rax
movl   $0x0,(%rax)
movss  (%rsp),%xmm0
divss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdff(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1080 <strerror@plt>
lea    0xdf6(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdf8(%rip),%rdi
call   1070 <WrMessage@plt>
lea    0xe1c(%rip),%rdi
call   1030 <CheckSet@plt>
test   %eax,%eax
je     12c9 <WrNumericErrors+0x169>
lea    0xe16(%rip),%rdi
call   1070 <WrMessage@plt>
mov    0x2d61(%rip),%rax
movl   $0x0,(%rax)
movss  0xd73(%rip),%xmm0
divss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd92(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1080 <strerror@plt>
lea    0xd89(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd8b(%rip),%rdi
call   1070 <WrMessage@plt>
lea    0xdcb(%rip),%rdi
call   1030 <CheckSet@plt>
test   %eax,%eax
je     1343 <WrNumericErrors+0x1e3>
lea    0xdc3(%rip),%rdi
call   1070 <WrMessage@plt>
mov    0x2cf4(%rip),%rbx
movl   $0x0,(%rbx)
movss  0x8(%rsp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jb     1306 <WrNumericErrors+0x1a6>
sqrtss %xmm0,%xmm0
jmp    130b <WrNumericErrors+0x1ab>
call   1060 <sqrt@plt>
mov    (%rbx),%ebx
cvtss2sd %xmm0,%xmm0
lea    0xd18(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    %ebx,%edi
call   1080 <strerror@plt>
lea    0xd0f(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd11(%rip),%rdi
call   1070 <WrMessage@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [16 x i8] c"@NUMERIC-ERRORS\00"
@.str.1 = [10 x i8] c"@OVERFLOW\00"
@.str.2 = [18 x i8] c"@NUMERIC-OVERFLOW\00"
@errno = global i32 0
@.str.3 = [12 x i8] c"Result: %g\0A\00"
@.str.4 = [19 x i8] c"System error: %s\0A\0A\00"
@.str.5 = [18 x i8] c"@NUMERIC-CONTINUE\00"
@.str.6 = [11 x i8] c"@UNDERFLOW\00"
@.str.7 = [19 x i8] c"@NUMERIC-UNDERFLOW\00"
@.str.8 = [10 x i8] c"@DIVISION\00"
@.str.9 = [18 x i8] c"@NUMERIC-DIVISION\00"
@.str.10 = [8 x i8] c"@DOMAIN\00"
@.str.11 = [16 x i8] c"@NUMERIC-DOMAIN\00"
define void @WrNumericErrors() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = call i32 @SetNumerics(float* %3, float* %4, float* %5, float* %6)
%9 = call i32 @WrMessage(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @CheckSet(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
store i32 %10, i32* %1
%11 = load i32, i32* %1
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %26
13: ; preds = %0
%14 = call i32 @WrMessage(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* @errno
%15 = load float, float* %3
%16 = load float, float* %4
%17 = fdiv float %15, %16
store float %17, float* %7
%18 = load i32, i32* @errno
store i32 %18, i32* %2
%19 = load float, float* %7
%20 = fpext float %19 to double
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), double %20)
%22 = load i32, i32* %2
%23 = call i8* @strerror(i32 %22)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %23)
%25 = call i32 @WrMessage(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
br label %26
26: ; preds = %13, %0
%27 = call i32 @CheckSet(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
store i32 %27, i32* %1
%28 = load i32, i32* %1
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %43
30: ; preds = %26
%31 = call i32 @WrMessage(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
store i32 0, i32* @errno
%32 = load float, float* %4
%33 = load float, float* %3
%34 = fdiv float %32, %33
store float %34, float* %7
%35 = load i32, i32* @errno
store i32 %35, i32* %2
%36 = load float, float* %7
%37 = fpext float %36 to double
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), double %37)
%39 = load i32, i32* %2
%40 = call i8* @strerror(i32 %39)
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %40)
%42 = call i32 @WrMessage(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
br label %43
43: ; preds = %30, %26
%44 = call i32 @CheckSet(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0))
store i32 %44, i32* %1
%45 = load i32, i32* %1
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %61
47: ; preds = %43
%48 = call i32 @WrMessage(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0))
store i32 0, i32* @errno
%49 = load float, float* %5
%50 = fpext float %49 to double
%51 = fdiv double 1.000000e+00, %50
%52 = fptrunc double %51 to float
store float %52, float* %7
%53 = load i32, i32* @errno
store i32 %53, i32* %2
%54 = load float, float* %7
%55 = fpext float %54 to double
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), double %55)
%57 = load i32, i32* %2
%58 = call i8* @strerror(i32 %57)
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %58)
%60 = call i32 @WrMessage(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
br label %61
61: ; preds = %47, %43
%62 = call i32 @CheckSet(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0))
store i32 %62, i32* %1
%63 = load i32, i32* %1
%64 = icmp ne i32 %63, 0
br i1 %64, label %65, label %77
65: ; preds = %61
%66 = call i32 @WrMessage(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0))
store i32 0, i32* @errno
%67 = load float, float* %6
%68 = call float @sqrt(float %67)
store float %68, float* %7
%69 = load i32, i32* @errno
store i32 %69, i32* %2
%70 = load float, float* %7
%71 = fpext float %70 to double
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), double %71)
%73 = load i32, i32* %2
%74 = call i8* @strerror(i32 %73)
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %74)
%76 = call i32 @WrMessage(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
br label %77
77: ; preds = %65, %61
ret void
}

LLVM IR (-O2):
@.str = [16 x i8] c"@NUMERIC-ERRORS\00"
@.str.1 = [10 x i8] c"@OVERFLOW\00"
@.str.2 = [18 x i8] c"@NUMERIC-OVERFLOW\00"
@errno = global i32 0
@.str.3 = [12 x i8] c"Result: %g\0A\00"
@.str.4 = [19 x i8] c"System error: %s\0A\0A\00"
@.str.5 = [18 x i8] c"@NUMERIC-CONTINUE\00"
@.str.6 = [11 x i8] c"@UNDERFLOW\00"
@.str.7 = [19 x i8] c"@NUMERIC-UNDERFLOW\00"
@.str.8 = [10 x i8] c"@DIVISION\00"
@.str.9 = [18 x i8] c"@NUMERIC-DIVISION\00"
@.str.10 = [8 x i8] c"@DOMAIN\00"
@.str.11 = [16 x i8] c"@NUMERIC-DOMAIN\00"
define void @WrNumericErrors() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = bitcast float* %1 to i8*
%6 = bitcast float* %2 to i8*
%7 = bitcast float* %3 to i8*
%8 = bitcast float* %4 to i8*
%9 = call i32 @SetNumerics(float* %1, float* %2, float* %3, float* %4)
%10 = call i32 @WrMessage(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @CheckSet(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i32 %11, 0
br i1 %12, label %23, label %13
13: ; preds = %0
%14 = call i32 @WrMessage(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* @errno
%15 = load float, float* %1
%16 = load float, float* %2
%17 = fdiv float %15, %16
%18 = fpext float %17 to double
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), double %18)
%20 = call i8* @strerror(i32 0)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %20)
%22 = call i32 @WrMessage(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
br label %23
23: ; preds = %13, %0
%24 = call i32 @CheckSet(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
%25 = icmp eq i32 %24, 0
br i1 %25, label %36, label %26
26: ; preds = %23
%27 = call i32 @WrMessage(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
store i32 0, i32* @errno
%28 = load float, float* %2
%29 = load float, float* %1
%30 = fdiv float %28, %29
%31 = fpext float %30 to double
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), double %31)
%33 = call i8* @strerror(i32 0)
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %33)
%35 = call i32 @WrMessage(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
br label %36
36: ; preds = %26, %23
%37 = call i32 @CheckSet(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0))
%38 = icmp eq i32 %37, 0
br i1 %38, label %48, label %39
39: ; preds = %36
%40 = call i32 @WrMessage(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0))
store i32 0, i32* @errno
%41 = load float, float* %3
%42 = fdiv float 1.000000e+00, %41
%43 = fpext float %42 to double
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), double %43)
%45 = call i8* @strerror(i32 0)
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %45)
%47 = call i32 @WrMessage(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
br label %48
48: ; preds = %39, %36
%49 = call i32 @CheckSet(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0))
%50 = icmp eq i32 %49, 0
br i1 %50, label %61, label %51
51: ; preds = %48
%52 = call i32 @WrMessage(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0))
store i32 0, i32* @errno
%53 = load float, float* %4
%54 = call float @sqrt(float %53)
%55 = load i32, i32* @errno
%56 = fpext float %54 to double
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), double %56)
%58 = call i8* @strerror(i32 %55)
%59 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %58)
%60 = call i32 @WrMessage(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
br label %61
61: ; preds = %51, %48
ret void
}