#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__ coords_to_qth(double, double, size_t, char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
size_t strlen(char *);
scalar_t__ strncmp(char const *, char *, size_t);
void checkCoordsToQth(double Lat, double Lng, size_t expectedPrecisionLvl,
                      const char *expectedQth, size_t expectedQthStringSize,
                      size_t *takenTests, size_t *passedTests) {
  ++(*takenTests);
  char qth[13];
  memset(qth, 0, 13);
  if (coords_to_qth(Lat, Lng, expectedPrecisionLvl, qth) != 0) {
    printf("Test failed: coords_to_qth( %lf, %lf, %lu, &qth):\n", Lat, Lng,
           expectedPrecisionLvl);
    printf("\tInvalid test sample.\n");
    return;
  }
  if (strlen(qth) != expectedQthStringSize) {
    printf("Test failed: coords_to_qth( %lf, %lf, %lu, &qth):\n", Lat, Lng,
           expectedPrecisionLvl);
    printf("\tQTH not matching: got \"%s\", expected \"%s\".\n", qth,
           expectedQth);
    return;
  }
  if (strncmp(expectedQth, qth,
              (expectedQthStringSize < 12) ? expectedQthStringSize : 12) != 0) {
    printf("Test failed: coords_to_qth( %lf, %lf, %lu, &qth):\n", Lat, Lng,
           expectedPrecisionLvl);
    printf("\tQTH not matching: got \"%s\", expected \"%s\".\n", qth,
           expectedQth);
    return;
  }
  ++(*passedTests);
  return;
}


x86 assembly (clang, -O0):
<checkCoordsToQth>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
mov    %rcx,-0x30(%rbp)
mov    %r8,-0x38(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
lea    -0x45(%rbp),%rdi
xor    %esi,%esi
mov    $0xd,%edx
call   1070 <memset@plt>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
mov    -0x18(%rbp),%rdi
lea    -0x45(%rbp),%rsi
call   1040 <coords_to_qth@plt>
cmp    $0x0,%rax
je     11e4 <checkCoordsToQth+0x94>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
mov    -0x18(%rbp),%rsi
lea    0xe36(%rip),%rdi
mov    $0x2,%al
call   1060 <printf@plt>
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    12c4 <checkCoordsToQth+0x174>
lea    -0x45(%rbp),%rdi
call   1050 <strlen@plt>
cmp    -0x28(%rbp),%rax
je     122e <checkCoordsToQth+0xde>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
mov    -0x18(%rbp),%rsi
lea    0xdf4(%rip),%rdi
mov    $0x2,%al
call   1060 <printf@plt>
lea    -0x45(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    12c4 <checkCoordsToQth+0x174>
mov    -0x20(%rbp),%rax
mov    %rax,-0x58(%rbp)
lea    -0x45(%rbp),%rax
mov    %rax,-0x50(%rbp)
cmpq   $0xc,-0x28(%rbp)
jae    1256 <checkCoordsToQth+0x106>
mov    -0x28(%rbp),%rax
mov    %rax,-0x60(%rbp)
jmp    1264 <checkCoordsToQth+0x114>
mov    $0xc,%eax
mov    %rax,-0x60(%rbp)
jmp    1264 <checkCoordsToQth+0x114>
mov    -0x50(%rbp),%rsi
mov    -0x58(%rbp),%rdi
mov    -0x60(%rbp),%rdx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     12b6 <checkCoordsToQth+0x166>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
mov    -0x18(%rbp),%rsi
lea    0xd6c(%rip),%rdi
mov    $0x2,%al
call   1060 <printf@plt>
lea    -0x45(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xda0(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    12c4 <checkCoordsToQth+0x174>
mov    -0x38(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkCoordsToQth>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %r8,%r15
mov    %rdx,%r12
mov    %rsi,%r14
mov    %rdi,%r13
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,(%rsp)
addq   $0x1,(%rcx)
lea    0x13(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xd,%edx
call   1080 <memset@plt>
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
mov    %r13,%rdi
mov    %rbx,%rsi
call   1050 <coords_to_qth@plt>
test   %rax,%rax
je     11e1 <checkCoordsToQth+0x81>
lea    0xe42(%rip),%rdi
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
mov    %r13,%rsi
mov    $0x2,%al
call   1070 <printf@plt>
lea    0xe86(%rip),%rdi
call   1040 <puts@plt>
jmp    1247 <checkCoordsToQth+0xe7>
lea    0x13(%rsp),%rdi
call   1060 <strlen@plt>
cmp    %r12,%rax
jne    120f <checkCoordsToQth+0xaf>
cmp    $0xc,%r12
mov    $0xc,%edx
cmovb  %r12,%rdx
lea    0x13(%rsp),%rsi
mov    %r14,%rdi
call   1030 <strncmp@plt>
test   %rax,%rax
je     1243 <checkCoordsToQth+0xe3>
lea    0xdea(%rip),%rdi
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
mov    %r13,%rsi
mov    $0x2,%al
call   1070 <printf@plt>
lea    0xe01(%rip),%rdi
lea    0x13(%rsp),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1070 <printf@plt>
jmp    1247 <checkCoordsToQth+0xe7>
addq   $0x1,(%r15)
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [51 x i8] c"Test failed: coords_to_qth( %lf, %lf, %lu, &qth):\0A\00"
@.str.1 = [23 x i8] c"\09Invalid test sample.\0A\00"
@.str.2 = [45 x i8] c"\09QTH not matching: got \22%s\22, expected \22%s\22.\0A\00"
define void @checkCoordsToQth(double %0, double %1, i64 %2, i8* %3, i64 %4, i64* %5, i64* %6) {
%8 = alloca double
%9 = alloca double
%10 = alloca i64
%11 = alloca i8*
%12 = alloca i64
%13 = alloca i64*
%14 = alloca i64*
%15 = alloca [13 x i8]
store double %0, double* %8
store double %1, double* %9
store i64 %2, i64* %10
store i8* %3, i8** %11
store i64 %4, i64* %12
store i64* %5, i64** %13
store i64* %6, i64** %14
%16 = load i64*, i64** %13
%17 = load i64, i64* %16
%18 = add i64 %17, 1
store i64 %18, i64* %16
%19 = getelementptr inbounds [13 x i8], [13 x i8]* %15, i64 0, i64 0
%20 = call i32 @memset(i8* %19, i32 0, i32 13)
%21 = load double, double* %8
%22 = load double, double* %9
%23 = load i64, i64* %10
%24 = getelementptr inbounds [13 x i8], [13 x i8]* %15, i64 0, i64 0
%25 = call i64 @coords_to_qth(double %21, double %22, i64 %23, i8* %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %33
27: ; preds = %7
%28 = load double, double* %8
%29 = load double, double* %9
%30 = load i64, i64* %10
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), double %28, double %29, i64 %30)
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
br label %70
33: ; preds = %7
%34 = getelementptr inbounds [13 x i8], [13 x i8]* %15, i64 0, i64 0
%35 = call i64 @strlen(i8* %34)
%36 = load i64, i64* %12
%37 = icmp ne i64 %35, %36
br i1 %37, label %38, label %46
38: ; preds = %33
%39 = load double, double* %8
%40 = load double, double* %9
%41 = load i64, i64* %10
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), double %39, double %40, i64 %41)
%43 = getelementptr inbounds [13 x i8], [13 x i8]* %15, i64 0, i64 0
%44 = load i8*, i8** %11
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i8* %43, i8* %44)
br label %70
46: ; preds = %33
%47 = load i8*, i8** %11
%48 = getelementptr inbounds [13 x i8], [13 x i8]* %15, i64 0, i64 0
%49 = load i64, i64* %12
%50 = icmp ult i64 %49, 12
br i1 %50, label %51, label %53
51: ; preds = %46
%52 = load i64, i64* %12
br label %54
53: ; preds = %46
br label %54
54: ; preds = %53, %51
%55 = phi i64 [ %52, %51 ], [ 12, %53 ]
%56 = call i64 @strncmp(i8* %47, i8* %48, i64 %55)
%57 = icmp ne i64 %56, 0
br i1 %57, label %58, label %66
58: ; preds = %54
%59 = load double, double* %8
%60 = load double, double* %9
%61 = load i64, i64* %10
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), double %59, double %60, i64 %61)
%63 = getelementptr inbounds [13 x i8], [13 x i8]* %15, i64 0, i64 0
%64 = load i8*, i8** %11
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i8* %63, i8* %64)
br label %70
66: ; preds = %54
%67 = load i64*, i64** %14
%68 = load i64, i64* %67
%69 = add i64 %68, 1
store i64 %69, i64* %67
br label %70
70: ; preds = %66, %58, %38, %27
ret void
}

LLVM IR (-O2):
@.str = [51 x i8] c"Test failed: coords_to_qth( %lf, %lf, %lu, &qth):\0A\00"
@.str.2 = [45 x i8] c"\09QTH not matching: got \22%s\22, expected \22%s\22.\0A\00"
@str = [22 x i8] c"\09Invalid test sample.\00"
define void @checkCoordsToQth(double %0, double %1, i64 %2, i8* %3, i64 %4, i64* nocapture %5, i64* nocapture %6) {
%8 = alloca [13 x i8]
%9 = load i64, i64* %5
%10 = add i64 %9, 1
store i64 %10, i64* %5
%11 = getelementptr inbounds [13 x i8], [13 x i8]* %8, i64 0, i64 0
%12 = call i32 @memset(i8* %11, i32 0, i32 13)
%13 = call i64 @coords_to_qth(double %0, double %1, i64 %2, i8* %11)
%14 = icmp eq i64 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %7
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), double %0, double %1, i64 %2)
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
br label %35
18: ; preds = %7
%19 = call i64 @strlen(i8* %11)
%20 = icmp eq i64 %19, %4
br i1 %20, label %24, label %21
21: ; preds = %18
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), double %0, double %1, i64 %2)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i8* %11, i8* %3)
br label %35
24: ; preds = %18
%25 = icmp ult i64 %4, 12
%26 = select i1 %25, i64 %4, i64 12
%27 = call i64 @strncmp(i8* %3, i8* %11, i64 %26)
%28 = icmp eq i64 %27, 0
br i1 %28, label %32, label %29
29: ; preds = %24
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), double %0, double %1, i64 %2)
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i8* %11, i8* %3)
br label %35
32: ; preds = %24
%33 = load i64, i64* %6
%34 = add i64 %33, 1
store i64 %34, i64* %6
br label %35
35: ; preds = %32, %29, %21, %15
ret void
}