#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 EDOM;
int coords_to_qth(double, double, int, char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
void inCheckCoordsToQth(double Lat, double Lng, size_t *takenTests,
                        size_t *passedTests) {
  ++(*takenTests);
  char qth[13];
  memset(qth, 0, 13);
  int retcode = coords_to_qth(Lat, Lng, 5, qth);
  if (retcode != 0 && retcode != EDOM) {
    printf("Test failed: coords_to_qth( %lf, %lf, %d, &qth):\n", Lat, Lng, 5);
    printf("\tUnexpected error code. All \"out of domain\" errors must be "
           "returned as errno's EDOM.\n");
    return;
  }
  if (Lng < -180.0 || Lng > 180.0 || Lat < -90.0 || Lat > 90.0) {
    if (retcode != EDOM) {
      printf("Test failed: coords_to_qth( %lf, %lf, %d, &qth):\n", Lat, Lng, 5);
      printf("\tFunction doesn't report invalid data properly.\n");
      return;
    }
    ++(*passedTests);
    return;
  }
  if (retcode != 0) {
    printf("Test failed: coords_to_qth( %lf, %lf, %d, &qth):\n", Lat, Lng, 5);
    printf("\tFunction doesn't report valid data properly.\n");
    return;
  }
  ++(*passedTests);
  return;
}


x86 assembly (clang, -O0):
<inCheckCoordsToQth>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
lea    -0x2d(%rbp),%rdi
xor    %esi,%esi
mov    $0xd,%edx
call   1050 <memset@plt>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
lea    -0x2d(%rbp),%rsi
mov    $0x5,%edi
call   1030 <coords_to_qth@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
je     11cf <inCheckCoordsToQth+0x9f>
mov    -0x34(%rbp),%eax
mov    0x2e51(%rip),%rcx
cmp    (%rcx),%eax
je     11cf <inCheckCoordsToQth+0x9f>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
lea    0xe70(%rip),%rdi
mov    $0x5,%esi
mov    $0x2,%al
call   1040 <printf@plt>
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12c0 <inCheckCoordsToQth+0x190>
movsd  0xe29(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
ja     1223 <inCheckCoordsToQth+0xf3>
movsd  -0x10(%rbp),%xmm0
movsd  0xe19(%rip),%xmm1
ucomisd %xmm1,%xmm0
ja     1223 <inCheckCoordsToQth+0xf3>
movsd  0xe0f(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
ja     1223 <inCheckCoordsToQth+0xf3>
movsd  -0x8(%rbp),%xmm0
movsd  0xdff(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1278 <inCheckCoordsToQth+0x148>
mov    -0x34(%rbp),%eax
mov    0x2dbb(%rip),%rcx
cmp    (%rcx),%eax
je     1265 <inCheckCoordsToQth+0x135>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
lea    0xdda(%rip),%rdi
mov    $0x5,%esi
mov    $0x2,%al
call   1040 <printf@plt>
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12c0 <inCheckCoordsToQth+0x190>
mov    -0x20(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
jmp    12c0 <inCheckCoordsToQth+0x190>
cmpl   $0x0,-0x34(%rbp)
je     12b2 <inCheckCoordsToQth+0x182>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
lea    0xd8d(%rip),%rdi
mov    $0x5,%esi
mov    $0x2,%al
call   1040 <printf@plt>
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12c0 <inCheckCoordsToQth+0x190>
mov    -0x20(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inCheckCoordsToQth>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r14
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
addq   $0x1,(%rdi)
lea    0x1b(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xd,%edx
call   1060 <memset@plt>
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
mov    $0x5,%edi
mov    %rbx,%rsi
call   1040 <coords_to_qth@plt>
mov    0x2e5a(%rip),%rcx
mov    (%rcx),%ecx
test   %eax,%eax
je     11c3 <inCheckCoordsToQth+0x83>
cmp    %ecx,%eax
je     11c3 <inCheckCoordsToQth+0x83>
lea    0xe81(%rip),%rdi
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
mov    $0x5,%esi
mov    $0x2,%al
call   1050 <printf@plt>
lea    0xef2(%rip),%rdi
jmp    1243 <inCheckCoordsToQth+0x103>
movsd  0x8(%rsp),%xmm0
ucomisd 0xe2f(%rip),%xmm0
movsd  0x10(%rsp),%xmm1
ja     121f <inCheckCoordsToQth+0xdf>
movsd  0xe27(%rip),%xmm2
ucomisd %xmm0,%xmm2
ja     121f <inCheckCoordsToQth+0xdf>
movsd  0xe21(%rip),%xmm2
ucomisd %xmm1,%xmm2
ja     121f <inCheckCoordsToQth+0xdf>
ucomisd 0xe1b(%rip),%xmm1
ja     121f <inCheckCoordsToQth+0xdf>
test   %eax,%eax
je     1223 <inCheckCoordsToQth+0xe3>
lea    0xe16(%rip),%rdi
mov    $0x5,%esi
mov    $0x2,%al
call   1050 <printf@plt>
lea    0xe35(%rip),%rdi
jmp    1243 <inCheckCoordsToQth+0x103>
cmp    %ecx,%eax
jne    1229 <inCheckCoordsToQth+0xe9>
addq   $0x1,(%r14)
jmp    1248 <inCheckCoordsToQth+0x108>
lea    0xdf0(%rip),%rdi
mov    $0x5,%esi
mov    $0x2,%al
call   1050 <printf@plt>
lea    0xe3d(%rip),%rdi
call   1030 <puts@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@EDOM = global i32 0
@.str = [50 x i8] c"Test failed: coords_to_qth( %lf, %lf, %d, &qth):\0A\00"
@.str.1 = [86 x i8] c"\09Unexpected error code. All \22out of domain\22 errors must be returned as errno's EDOM.\0A\00"
@.str.2 = [49 x i8] c"\09Function doesn't report invalid data properly.\0A\00"
@.str.3 = [47 x i8] c"\09Function doesn't report valid data properly.\0A\00"
define void @inCheckCoordsToQth(double %0, double %1, i64* %2, i64* %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca i64*
%8 = alloca i64*
%9 = alloca [13 x i8]
%10 = alloca i32
store double %0, double* %5
store double %1, double* %6
store i64* %2, i64** %7
store i64* %3, i64** %8
%11 = load i64*, i64** %7
%12 = load i64, i64* %11
%13 = add i64 %12, 1
store i64 %13, i64* %11
%14 = getelementptr inbounds [13 x i8], [13 x i8]* %9, i64 0, i64 0
%15 = call i32 @memset(i8* %14, i32 0, i32 13)
%16 = load double, double* %5
%17 = load double, double* %6
%18 = getelementptr inbounds [13 x i8], [13 x i8]* %9, i64 0, i64 0
%19 = call i32 @coords_to_qth(double %16, double %17, i32 5, i8* %18)
store i32 %19, i32* %10
%20 = load i32, i32* %10
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %31
22: ; preds = %4
%23 = load i32, i32* %10
%24 = load i32, i32* @EDOM
%25 = icmp ne i32 %23, %24
br i1 %25, label %26, label %31
26: ; preds = %22
%27 = load double, double* %5
%28 = load double, double* %6
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), double %27, double %28, i32 5)
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([86 x i8], [86 x i8]* @.str.1, i64 0, i64 0))
br label %68
31: ; preds = %22, %4
%32 = load double, double* %6
%33 = fcmp olt double %32, -1.800000e+02
br i1 %33, label %43, label %34
34: ; preds = %31
%35 = load double, double* %6
%36 = fcmp ogt double %35, 1.800000e+02
br i1 %36, label %43, label %37
37: ; preds = %34
%38 = load double, double* %5
%39 = fcmp olt double %38, -9.000000e+01
br i1 %39, label %43, label %40
40: ; preds = %37
%41 = load double, double* %5
%42 = fcmp ogt double %41, 9.000000e+01
br i1 %42, label %43, label %56
43: ; preds = %40, %37, %34, %31
%44 = load i32, i32* %10
%45 = load i32, i32* @EDOM
%46 = icmp ne i32 %44, %45
br i1 %46, label %47, label %52
47: ; preds = %43
%48 = load double, double* %5
%49 = load double, double* %6
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), double %48, double %49, i32 5)
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0))
br label %68
52: ; preds = %43
%53 = load i64*, i64** %8
%54 = load i64, i64* %53
%55 = add i64 %54, 1
store i64 %55, i64* %53
br label %68
56: ; preds = %40
%57 = load i32, i32* %10
%58 = icmp ne i32 %57, 0
br i1 %58, label %59, label %64
59: ; preds = %56
%60 = load double, double* %5
%61 = load double, double* %6
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), double %60, double %61, i32 5)
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0))
br label %68
64: ; preds = %56
%65 = load i64*, i64** %8
%66 = load i64, i64* %65
%67 = add i64 %66, 1
store i64 %67, i64* %65
br label %68
68: ; preds = %64, %59, %52, %47, %26
ret void
}

LLVM IR (-O2):
@EDOM = global i32 0
@.str = [50 x i8] c"Test failed: coords_to_qth( %lf, %lf, %d, &qth):\0A\00"
@str = [46 x i8] c"\09Function doesn't report valid data properly.\00"
@str.4 = [48 x i8] c"\09Function doesn't report invalid data properly.\00"
@str.5 = [85 x i8] c"\09Unexpected error code. All \22out of domain\22 errors must be returned as errno's EDOM.\00"
define void @inCheckCoordsToQth(double %0, double %1, i64* nocapture %2, i64* nocapture %3) {
%5 = alloca [13 x i8]
%6 = load i64, i64* %2
%7 = add i64 %6, 1
store i64 %7, i64* %2
%8 = getelementptr inbounds [13 x i8], [13 x i8]* %5, i64 0, i64 0
%9 = call i32 @memset(i8* %8, i32 0, i32 13)
%10 = call i32 @coords_to_qth(double %0, double %1, i32 5, i8* %8)
%11 = icmp eq i32 %10, 0
%12 = load i32, i32* @EDOM
%13 = icmp eq i32 %10, %12
%14 = select i1 %11, i1 true, i1 %13
br i1 %14, label %18, label %15
15: ; preds = %4
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), double %0, double %1, i32 5)
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([85 x i8], [85 x i8]* @str.5, i64 0, i64 0))
br label %40
18: ; preds = %4
%19 = fcmp olt double %1, -1.800000e+02
%20 = fcmp ogt double %1, 1.800000e+02
%21 = or i1 %19, %20
%22 = fcmp olt double %0, -9.000000e+01
%23 = or i1 %22, %21
%24 = fcmp ogt double %0, 9.000000e+01
%25 = or i1 %24, %23
br i1 %25, label %26, label %33
26: ; preds = %18
br i1 %13, label %30, label %27
27: ; preds = %26
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), double %0, double %1, i32 5)
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str.4, i64 0, i64 0))
br label %40
30: ; preds = %26
%31 = load i64, i64* %3
%32 = add i64 %31, 1
store i64 %32, i64* %3
br label %40
33: ; preds = %18
br i1 %11, label %37, label %34
34: ; preds = %33
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), double %0, double %1, i32 5)
%36 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str, i64 0, i64 0))
br label %40
37: ; preds = %33
%38 = load i64, i64* %3
%39 = add i64 %38, 1
store i64 %39, i64* %3
br label %40
40: ; preds = %37, %34, %30, %27, %15
ret void
}