#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 /*<<< orphan*/ printf(char *, ...);
scalar_t__ qth_to_coords(char const *, size_t, double *, double *, size_t *);
void checkQthToCoords(const char *qth, size_t qthStringSize,
                      size_t expectedPrecisionLvl, double expectedLat,
                      double expectedLng, double acceptedBias,
                      size_t *takenTests, size_t *passedTests) {
  ++(*takenTests);
  size_t precision = 0;
  double lat = -300;
  double lng = -300;
  if (qth_to_coords(qth, qthStringSize, &lat, &lng, &precision) != 0) {
    printf(
        "Test failed: qth_to_coords( \"%s\", %lu, &lat, &lng, &precision):\n",
        qth, qthStringSize);
    printf("\tInvalid test sample.\n");
    return;
  }
  if (precision != expectedPrecisionLvl) {
    printf(
        "Test failed: qth_to_coords( \"%s\", %lu, &lat, &lng, &precision):\n",
        qth, qthStringSize);
    printf("\tBad precision, got %lu, expected %lu. \n", precision,
           expectedPrecisionLvl);
    return;
  }
  if (lat > (expectedLat + (acceptedBias / 2) + 0.000001) ||
      lat < (expectedLat - (acceptedBias / 2) - 0.000001)) {
    printf(
        "Test failed: qth_to_coords( \"%s\", %lu, &lat, &lng, &precision):\n",
        qth, qthStringSize);
    printf("\tLatitude out of acceptable range: got %f, expected %f +/- %f.\n",
           lat, expectedLat, (acceptedBias / 2) + 0.000001);
    return;
  }
  if (lng > (expectedLng + acceptedBias + 0.000001) ||
      lng < (expectedLng - acceptedBias - 0.000001)) {
    printf(
        "Test failed: qth_to_coords( \"%s\", %lu, &lat, &lng, &precision):\n",
        qth, qthStringSize);
    printf("\tLongitude out of acceptable range: got %f, expected %f +/- %f.\n",
           lng, expectedLng, acceptedBias + 0.000001);
    return;
  }
  ++(*passedTests);
  return;
}


x86 assembly (clang, -O0):
<checkQthToCoords>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
movsd  %xmm1,-0x28(%rbp)
movsd  %xmm2,-0x30(%rbp)
mov    %rcx,-0x38(%rbp)
mov    %r8,-0x40(%rbp)
mov    -0x38(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
movq   $0x0,-0x48(%rbp)
movsd  0xe97(%rip),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xe8a(%rip),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x50(%rbp),%rdx
lea    -0x58(%rbp),%rcx
lea    -0x48(%rbp),%r8
call   1040 <qth_to_coords@plt>
cmp    $0x0,%rax
je     11c7 <checkQthToCoords+0xa7>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1358 <checkQthToCoords+0x238>
mov    -0x48(%rbp),%rax
cmp    -0x18(%rbp),%rax
je     1206 <checkQthToCoords+0xe6>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x48(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1358 <checkQthToCoords+0x238>
movsd  -0x50(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
movsd  0xdf3(%rip),%xmm3
divsd  %xmm3,%xmm2
addsd  %xmm2,%xmm1
movsd  0xddb(%rip),%xmm2
addsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
ja     1270 <checkQthToCoords+0x150>
movsd  -0x50(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
movsd  0xdbe(%rip),%xmm3
divsd  %xmm3,%xmm2
subsd  %xmm2,%xmm0
movsd  0xda6(%rip),%xmm2
subsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jbe    12c0 <checkQthToCoords+0x1a0>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xd99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  -0x50(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
movsd  0xd73(%rip),%xmm3
divsd  %xmm3,%xmm2
movsd  0xd5f(%rip),%xmm3
addsd  %xmm3,%xmm2
lea    0xde5(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
jmp    1358 <checkQthToCoords+0x238>
movsd  -0x58(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
addsd  -0x30(%rbp),%xmm1
movsd  0xd31(%rip),%xmm2
addsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
ja     130a <checkQthToCoords+0x1ea>
movsd  -0x58(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
movsd  0xd0c(%rip),%xmm2
subsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jbe    134a <checkQthToCoords+0x22a>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xcff(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  -0x58(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  0xcd6(%rip),%xmm2
addsd  -0x30(%rbp),%xmm2
lea    0xd9b(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
jmp    1358 <checkQthToCoords+0x238>
mov    -0x40(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkQthToCoords>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r8,%r15
movsd  %xmm2,0x8(%rsp)
movsd  %xmm1,0x28(%rsp)
movsd  %xmm0,0x30(%rsp)
mov    %rdx,%r12
mov    %rsi,%r14
mov    %rdi,%rbx
addq   $0x1,(%rcx)
movq   $0x0,0x20(%rsp)
movabs $0xc072c00000000000,%rax
c0 72 c0
mov    %rax,0x18(%rsp)
mov    %rax,0x10(%rsp)
lea    0x18(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0x20(%rsp),%r8
call   1050 <qth_to_coords@plt>
test   %rax,%rax
je     11b8 <checkQthToCoords+0x88>
lea    0xe7e(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf55(%rip),%rdi
call   1030 <puts@plt>
jmp    1281 <checkQthToCoords+0x151>
movsd  0x30(%rsp),%xmm4
movsd  0x28(%rsp),%xmm3
movsd  0x8(%rsp),%xmm2
cmp    %r12,0x20(%rsp)
jne    1257 <checkQthToCoords+0x127>
movsd  0x18(%rsp),%xmm0
movsd  0xe1d(%rip),%xmm5
mulsd  %xmm2,%xmm5
movapd %xmm5,%xmm1
addsd  %xmm4,%xmm1
addsd  0xe11(%rip),%xmm1
ucomisd %xmm1,%xmm0
ja     1213 <checkQthToCoords+0xe3>
movapd %xmm4,%xmm1
subsd  %xmm5,%xmm1
addsd  0xe03(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    128d <checkQthToCoords+0x15d>
lea    0xdfe(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
xor    %eax,%eax
movsd  %xmm5,0x8(%rsp)
call   1040 <printf@plt>
movsd  0x18(%rsp),%xmm0
movsd  0x8(%rsp),%xmm2
addsd  0xdc7(%rip),%xmm2
lea    0xe3a(%rip),%rdi
movsd  0x30(%rsp),%xmm1
mov    $0x3,%al
call   1040 <printf@plt>
jmp    1281 <checkQthToCoords+0x151>
lea    0xdba(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x20(%rsp),%rsi
lea    0xde2(%rip),%rdi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
movsd  0x10(%rsp),%xmm0
movapd %xmm3,%xmm1
addsd  %xmm2,%xmm1
addsd  0xd65(%rip),%xmm1
ucomisd %xmm1,%xmm0
ja     12bf <checkQthToCoords+0x18f>
movapd %xmm3,%xmm1
subsd  %xmm2,%xmm1
addsd  0xd57(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    12f9 <checkQthToCoords+0x1c9>
lea    0xd52(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm2
addsd  0xd21(%rip),%xmm2
lea    0xdd4(%rip),%rdi
movsd  0x28(%rsp),%xmm1
jmp    124e <checkQthToCoords+0x11e>
addq   $0x1,(%r15)
jmp    1281 <checkQthToCoords+0x151>

LLVM IR (-O0):
@.str = [65 x i8] c"Test failed: qth_to_coords( \22%s\22, %lu, &lat, &lng, &precision):\0A\00"
@.str.1 = [23 x i8] c"\09Invalid test sample.\0A\00"
@.str.2 = [41 x i8] c"\09Bad precision, got %lu, expected %lu. \0A\00"
@.str.3 = [64 x i8] c"\09Latitude out of acceptable range: got %f, expected %f +/- %f.\0A\00"
@.str.4 = [65 x i8] c"\09Longitude out of acceptable range: got %f, expected %f +/- %f.\0A\00"
define void @checkQthToCoords(i8* %0, i64 %1, i64 %2, double %3, double %4, double %5, i64* %6, i64* %7) {
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i64
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca i64*
%16 = alloca i64*
%17 = alloca i64
%18 = alloca double
%19 = alloca double
store i8* %0, i8** %9
store i64 %1, i64* %10
store i64 %2, i64* %11
store double %3, double* %12
store double %4, double* %13
store double %5, double* %14
store i64* %6, i64** %15
store i64* %7, i64** %16
%20 = load i64*, i64** %15
%21 = load i64, i64* %20
%22 = add i64 %21, 1
store i64 %22, i64* %20
store i64 0, i64* %17
store double -3.000000e+02, double* %18
store double -3.000000e+02, double* %19
%23 = load i8*, i8** %9
%24 = load i64, i64* %10
%25 = call i64 @qth_to_coords(i8* %23, i64 %24, double* %18, double* %19, i64* %17)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %32
27: ; preds = %8
%28 = load i8*, i8** %9
%29 = load i64, i64* %10
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i8* %28, i64 %29)
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
br label %96
32: ; preds = %8
%33 = load i64, i64* %17
%34 = load i64, i64* %11
%35 = icmp ne i64 %33, %34
br i1 %35, label %36, label %43
36: ; preds = %32
%37 = load i8*, i8** %9
%38 = load i64, i64* %10
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i8* %37, i64 %38)
%40 = load i64, i64* %17
%41 = load i64, i64* %11
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i64 %40, i64 %41)
br label %96
43: ; preds = %32
%44 = load double, double* %18
%45 = load double, double* %12
%46 = load double, double* %14
%47 = fdiv double %46, 2.000000e+00
%48 = fadd double %45, %47
%49 = fadd double %48, 0x3EB0C6F7A0B5ED8D
%50 = fcmp ogt double %44, %49
br i1 %50, label %59, label %51
51: ; preds = %43
%52 = load double, double* %18
%53 = load double, double* %12
%54 = load double, double* %14
%55 = fdiv double %54, 2.000000e+00
%56 = fsub double %53, %55
%57 = fsub double %56, 0x3EB0C6F7A0B5ED8D
%58 = fcmp olt double %52, %57
br i1 %58, label %59, label %69
59: ; preds = %51, %43
%60 = load i8*, i8** %9
%61 = load i64, i64* %10
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i8* %60, i64 %61)
%63 = load double, double* %18
%64 = load double, double* %12
%65 = load double, double* %14
%66 = fdiv double %65, 2.000000e+00
%67 = fadd double %66, 0x3EB0C6F7A0B5ED8D
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.3, i64 0, i64 0), double %63, double %64, double %67)
br label %96
69: ; preds = %51
%70 = load double, double* %19
%71 = load double, double* %13
%72 = load double, double* %14
%73 = fadd double %71, %72
%74 = fadd double %73, 0x3EB0C6F7A0B5ED8D
%75 = fcmp ogt double %70, %74
br i1 %75, label %83, label %76
76: ; preds = %69
%77 = load double, double* %19
%78 = load double, double* %13
%79 = load double, double* %14
%80 = fsub double %78, %79
%81 = fsub double %80, 0x3EB0C6F7A0B5ED8D
%82 = fcmp olt double %77, %81
br i1 %82, label %83, label %92
83: ; preds = %76, %69
%84 = load i8*, i8** %9
%85 = load i64, i64* %10
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i8* %84, i64 %85)
%87 = load double, double* %19
%88 = load double, double* %13
%89 = load double, double* %14
%90 = fadd double %89, 0x3EB0C6F7A0B5ED8D
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.4, i64 0, i64 0), double %87, double %88, double %90)
br label %96
92: ; preds = %76
%93 = load i64*, i64** %16
%94 = load i64, i64* %93
%95 = add i64 %94, 1
store i64 %95, i64* %93
br label %96
96: ; preds = %92, %83, %59, %36, %27
ret void
}

LLVM IR (-O2):
@.str = [65 x i8] c"Test failed: qth_to_coords( \22%s\22, %lu, &lat, &lng, &precision):\0A\00"
@.str.2 = [41 x i8] c"\09Bad precision, got %lu, expected %lu. \0A\00"
@.str.3 = [64 x i8] c"\09Latitude out of acceptable range: got %f, expected %f +/- %f.\0A\00"
@.str.4 = [65 x i8] c"\09Longitude out of acceptable range: got %f, expected %f +/- %f.\0A\00"
@str = [22 x i8] c"\09Invalid test sample.\00"
define void @checkQthToCoords(i8* %0, i64 %1, i64 %2, double %3, double %4, double %5, i64* nocapture %6, i64* nocapture %7) {
%9 = alloca i64
%10 = alloca double
%11 = alloca double
%12 = load i64, i64* %6
%13 = add i64 %12, 1
store i64 %13, i64* %6
%14 = bitcast i64* %9 to i8*
store i64 0, i64* %9
%15 = bitcast double* %10 to i8*
store double -3.000000e+02, double* %10
%16 = bitcast double* %11 to i8*
store double -3.000000e+02, double* %11
%17 = call i64 @qth_to_coords(i8* %0, i64 %1, double* %10, double* %11, i64* %9)
%18 = icmp eq i64 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %8
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i8* %0, i64 %1)
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
br label %61
22: ; preds = %8
%23 = load i64, i64* %9
%24 = icmp eq i64 %23, %2
br i1 %24, label %29, label %25
25: ; preds = %22
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i8* %0, i64 %1)
%27 = load i64, i64* %9
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i64 %27, i64 %2)
br label %61
29: ; preds = %22
%30 = load double, double* %10
%31 = fmul double %5, 5.000000e-01
%32 = fadd double %31, %3
%33 = fadd double %32, 0x3EB0C6F7A0B5ED8D
%34 = fcmp ogt double %30, %33
br i1 %34, label %39, label %35
35: ; preds = %29
%36 = fsub double %3, %31
%37 = fadd double %36, 0xBEB0C6F7A0B5ED8D
%38 = fcmp olt double %30, %37
br i1 %38, label %39, label %44
39: ; preds = %35, %29
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i8* %0, i64 %1)
%41 = load double, double* %10
%42 = fadd double %31, 0x3EB0C6F7A0B5ED8D
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @.str.3, i64 0, i64 0), double %41, double %3, double %42)
br label %61
44: ; preds = %35
%45 = load double, double* %11
%46 = fadd double %4, %5
%47 = fadd double %46, 0x3EB0C6F7A0B5ED8D
%48 = fcmp ogt double %45, %47
br i1 %48, label %53, label %49
49: ; preds = %44
%50 = fsub double %4, %5
%51 = fadd double %50, 0xBEB0C6F7A0B5ED8D
%52 = fcmp olt double %45, %51
br i1 %52, label %53, label %58
53: ; preds = %49, %44
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i8* %0, i64 %1)
%55 = load double, double* %11
%56 = fadd double %5, 0x3EB0C6F7A0B5ED8D
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @.str.4, i64 0, i64 0), double %55, double %4, double %56)
br label %61
58: ; preds = %49
%59 = load i64, i64* %7
%60 = add i64 %59, 1
store i64 %60, i64* %7
br label %61
61: ; preds = %58, %53, %39, %25, %19
ret void
}