// File: /workspace/github_c_makefile_star2_O3/sgsfak[P]c-ocgeo/tests/tests.c
// Function: main
int main(int argc, char* argv[])
{

    ocgeo_dms_t dd;

    ocgeo_params_t params = ocgeo_default_params();
    ocgeo_response_t response;
    params.no_record = true;
    params.no_annotations = true;
    const char* query = "Syena, Aswan Governorate, Egypt";
    ocgeo_forward(query, "4372eff77b8343cebfc843eb4da4ddc4", &params, &response);
    TEST("Testing 402 response", response.status.code == OCGEO_CODE_QUOTA_ERROR);
    ocgeo_response_cleanup(&response);
    ocgeo_forward(query, "2e10e5e828262eb243ec0b54681d699a", &params, &response);
    TEST("Testing 403 response", response.status.code == OCGEO_CODE_FORBIDDEN);
    ocgeo_response_cleanup(&response);
    ocgeo_forward(query, "d6d0f0065f4348a4bdfe4587ba02714b", &params, &response);
    TEST("Testing 429 response", response.status.code == OCGEO_CODE_MANY_REQUESTS);
    ocgeo_response_cleanup(&response);

    params.no_annotations = false;
    ocgeo_forward(query, "6d0e711d72d74daeb2b0bfd2a5cdfdba", &params, &response);
    TEST("Testing 200 response", response.status.code == OCGEO_CODE_OK);
    TEST("Testing getting results", response.total_results > 0 && response.results != NULL);
    ocgeo_result_t* result = response.results;
    TEST("Testing currency annotation", result->currency != NULL &&
        strcmp(result->currency->iso_code, "EUR")==0 &&
        strcmp(result->currency->name, "Euro")==0 &&
        strcmp(result->currency->thousands_separator, ".")==0 &&
        strcmp(result->currency->decimal_mark, ",")==0);
    TEST("Testing road info annotation", result->roadinfo != NULL &&
        strcmp(result->roadinfo->speed_in, "km/h")==0 &&
        strcmp(result->roadinfo->drive_on, "right")==0);
    TEST("Testing 'what3words' annotation", result->what3words != NULL);
    TEST("Testing 'geohash' annotation", result->geohash != NULL);
    
    bool ok;
    const char* lat = ocgeo_response_get_str(result, "annotations.DMS.lat", &ok);
    TEST("Testing adv API, getting DMS lat", ok);
    int callingCode = ocgeo_response_get_int(result, "annotations.callingcode", &ok);
    TEST("Testing adv API, getting calling code", ok && callingCode == 49);
    printf("\t\tDMS lat = \"%s\", calling code=%d\n", lat, callingCode);

    TEST("Testing adv API, getting bounds", 
        d_eq_7(ocgeo_response_get_dbl(result, "bounds.northeast.lat", &ok), 51.9528202));
    TEST("Testing adv API, getting nonexistent string field", 
        ocgeo_response_get_str(result, "annotations.NON-EXISTENT", &ok) == NULL && !ok);

    ocgeo_response_cleanup(&response);


    TEST_DEC_TO_DEG(-10.1245839, -10, 7, 28.5);
    TEST_DEC_TO_DEG(-89.5006900, -89, 30, 2.48);
    TEST_DEC_TO_DEG(32.8247971, 32, 49, 29.27);
    TEST_DEC_TO_DEG(21.8545795, 21, 51, 16.49);

    TEST_DEG_TO_DEC(-10.1245839);
    TEST_DEG_TO_DEC(-89.5006900);

    printf("\n%d failed, %d pass\n", count_fail, count_pass);
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
leaq 0x48(%rsp), %r12
movq %r12, %rdi
callq 0x1918
movb $0x1, %al
movb %al, 0x52(%r12)
movb %al, 0x50(%r12)
leaq 0x5d0f(%rip), %rbx      # 0x703c
leaq 0x5d28(%rip), %rsi      # 0x705c
leaq 0x10(%rsp), %r14
movq %rbx, %rdi
movq %r12, %rdx
movq %r14, %rcx
callq 0x194d
cmpl $0x192, (%r14)          # imm = 0x192
leaq 0x5d28(%rip), %r15      # 0x707d
leaq 0x5d4a(%rip), %rdi      # 0x70a6
cmoveq %r15, %rdi
leaq 0x9dc5(%rip), %rbp      # 0xb12c
leaq 0x9dc2(%rip), %r13      # 0xb130
cmoveq %rbp, %r13
leaq 0x5d18(%rip), %rsi      # 0x7091
xorl %eax, %eax
callq 0x1030
incl (%r13)
movq %r14, %rdi
callq 0x1d84
leaq 0x5d27(%rip), %rsi      # 0x70ba
movq %rbx, %rdi
movq %r12, %rdx
movq %r14, %rcx
callq 0x194d
cmpl $0x193, (%r14)          # imm = 0x193
leaq 0x5cf7(%rip), %r12      # 0x70a6
movq %r12, %rdi
cmoveq %r15, %rdi
leaq 0x9d73(%rip), %r13      # 0xb130
cmoveq %rbp, %r13
leaq 0x5d13(%rip), %rsi      # 0x70db
xorl %eax, %eax
callq 0x1030
incl (%r13)
movq %r14, %rdi
callq 0x1d84
leaq 0x5d0e(%rip), %rsi      # 0x70f0
movq %rbx, %rdi
leaq 0x48(%rsp), %rdx
movq %r14, %rcx
callq 0x194d
cmpl $0x1ad, (%r14)          # imm = 0x1AD
movq %r12, %rdi
cmoveq %r15, %rdi
leaq 0x9d29(%rip), %rbx      # 0xb130
movq %rbx, %r13
cmoveq %rbp, %r13
leaq 0x5cfc(%rip), %rsi      # 0x7111
xorl %eax, %eax
callq 0x1030
incl (%r13)
movq %rbx, %r13
movq %r14, %rdi
callq 0x1d84
leaq 0x48(%rsp), %rdx
movb $0x0, 0x50(%rdx)
leaq 0x5ceb(%rip), %rsi      # 0x7126
leaq 0x5bfa(%rip), %rdi      # 0x703c
movq %r12, %rbx
movq %r14, %rcx
callq 0x194d
cmpl $0xc8, (%r14)
movq %r12, %rdi
cmoveq %r15, %rdi
movq %r13, %r12
cmoveq %rbp, %r12
leaq 0x5cde(%rip), %rsi      # 0x7147
xorl %eax, %eax
callq 0x1030
incl (%r12)
cmpl $0x0, 0x24(%r14)
setg %al
cmpq $0x0, 0x28(%r14)
setne %cl
testb %cl, %al
movq %rbx, %rdi
cmovneq %r15, %rdi
movq %r13, %r12
cmovneq %rbp, %r12
leaq 0x5cc1(%rip), %rsi      # 0x715c
xorl %eax, %eax
callq 0x1030
incl (%r12)
movq 0x28(%r14), %r14
movq 0xc8(%r14), %r12
testq %r12, %r12
je 0x14ff
movq 0x8(%r12), %rdi
leaq 0x5cb2(%rip), %rsi      # 0x7174
callq 0x11a0
testl %eax, %eax
jne 0x14ff
movq (%r12), %rdi
leaq 0x5ca2(%rip), %rsi      # 0x7178
callq 0x11a0
testl %eax, %eax
jne 0x14ff
movq 0x20(%r12), %rax
cmpb $0x2e, (%rax)
jne 0x14ff
cmpb $0x0, 0x1(%rax)
jne 0x14ff
movq 0x18(%r12), %rax
cmpb $0x2c, (%rax)
jne 0x14ff
cmpb $0x0, 0x1(%rax)
je 0x150d
leaq 0x9c2a(%rip), %rbp      # 0xb130
leaq 0x5b99(%rip), %r15      # 0x70a6
leaq 0x5c69(%rip), %rsi      # 0x717d
movq %r15, %rdi
xorl %eax, %eax
callq 0x1030
incl (%rbp)
movq 0xc0(%r14), %r15
testq %r15, %r15
je 0x1558
movq 0x8(%r15), %rdi
leaq 0x5c61(%rip), %rsi      # 0x7199
callq 0x11a0
testl %eax, %eax
jne 0x1558
movq (%r15), %rdi
leaq 0x5c53(%rip), %rsi      # 0x719e
callq 0x11a0
testl %eax, %eax
je 0x1905
leaq 0x9bd1(%rip), %r15      # 0xb130
leaq 0x5b40(%rip), %rdi      # 0x70a6
leaq 0x5c37(%rip), %rsi      # 0x71a4
xorl %eax, %eax
callq 0x1030
incl (%r15)
cmpq $0x0, 0xd8(%r14)
leaq 0x5af7(%rip), %rbp      # 0x707d
movq %rbp, %rdi
cmoveq %rbx, %rdi
leaq 0x9b98(%rip), %r12      # 0xb12c
movq %r12, %r15
cmoveq %r13, %r15
leaq 0x5c1f(%rip), %rsi      # 0x71c1
xorl %eax, %eax
callq 0x1030
incl (%r15)
cmpq $0x0, 0xd0(%r14)
movq %rbp, %rdi
cmoveq %rbx, %rdi
movq %r12, %r15
cmoveq %r13, %r15
leaq 0x5c18(%rip), %rsi      # 0x71e1
xorl %eax, %eax
callq 0x1030
incl (%r15)
leaq 0x5c24(%rip), %rsi      # 0x71fe
leaq 0x7(%rsp), %r15
movq %r14, %rdi
movq %r15, %rdx
callq 0x1e23
cmpb $0x0, (%r15)
cmoveq %rbx, %rbp
movq %rax, 0x8(%rsp)
movq %r13, %r15
movq %r12, %r13
cmoveq %r15, %r13
leaq 0x5c0a(%rip), %rsi      # 0x7212
movq %rbp, %rdi
xorl %eax, %eax
callq 0x1030
incl (%r13)
leaq 0x5c16(%rip), %rsi      # 0x7233
movq %r14, %rdi
leaq 0x7(%rsp), %r13
movq %r13, %rdx
callq 0x1f83
movl %eax, %ebp
cmpl $0x31, %eax
sete %al
testb %al, (%r13)
leaq 0x5a3d(%rip), %rdi      # 0x707d
cmoveq %rbx, %rdi
movq %r12, %r13
cmoveq %r15, %r13
leaq 0x5bf9(%rip), %rsi      # 0x724b
xorl %eax, %eax
callq 0x1030
incl (%r13)
movq %r15, %r13
leaq 0x5a16(%rip), %r15      # 0x707d
leaq 0x5c03(%rip), %rdi      # 0x7271
movq 0x8(%rsp), %rsi
movl %ebp, %edx
movq %r12, %rbp
xorl %eax, %eax
callq 0x1030
leaq 0x5c0e(%rip), %rsi      # 0x7294
movq %r14, %rdi
leaq 0x7(%rsp), %rdx
callq 0x1fcc
mulsd 0x596d(%rip), %xmm0     # 0x7008
cvtsd2ss %xmm0, %xmm0
callq 0x1190
movq %rax, %r12
movss 0x5961(%rip), %xmm0     # 0x7010
callq 0x1190
cmpq %rax, %r12
movq %rbx, %rdi
cmoveq %r15, %rdi
movq %r13, %r12
cmoveq %rbp, %r12
leaq 0x5bdd(%rip), %rsi      # 0x72a9
xorl %eax, %eax
callq 0x1030
incl (%r12)
leaq 0x5beb(%rip), %rsi      # 0x72c9
movq %r14, %rdi
leaq 0x7(%rsp), %rdx
callq 0x1e23
testq %rax, %rax
jne 0x1705
cmpb $0x1, 0x7(%rsp)
leaq 0x5981(%rip), %rdi      # 0x707d
leaq 0x9a29(%rip), %r14      # 0xb12c
jne 0x170b
movq %rbx, %rdi
movq %r13, %r14
leaq 0x5bd0(%rip), %rsi      # 0x72e2
xorl %eax, %eax
callq 0x1030
incl (%r14)
leaq 0x10(%rsp), %rdi
callq 0x1d84
movss 0x58e6(%rip), %xmm0     # 0x7014
callq 0x1190
movq %rax, %r14
movss 0x58da(%rip), %xmm0     # 0x7018
callq 0x1190
cmpq %rax, %r14
movq %rbx, %rdi
leaq 0x592d(%rip), %r15      # 0x707d
cmoveq %r15, %rdi
movq %r13, %r14
leaq 0x99ce(%rip), %r12      # 0xb12c
cmoveq %r12, %r14
leaq 0x5bab(%rip), %rsi      # 0x7314
xorl %eax, %eax
callq 0x1030
incl (%r14)
movss 0x58a1(%rip), %xmm0     # 0x701c
callq 0x1190
movq %rax, %r14
movss 0x5895(%rip), %xmm0     # 0x7020
callq 0x1190
cmpq %rax, %r14
movq %rbx, %rdi
cmoveq %r15, %rdi
movq %r13, %r14
cmoveq %r12, %r14
leaq 0x5ba7(%rip), %rsi      # 0x734f
xorl %eax, %eax
callq 0x1030
incl (%r14)
movss 0x586a(%rip), %xmm0     # 0x7024
callq 0x1190
movq %rax, %r14
movss 0x585e(%rip), %xmm0     # 0x7028
callq 0x1190
cmpq %rax, %r14
movq %rbx, %rdi
cmoveq %r15, %rdi
movq %r13, %r14
cmoveq %r12, %r14
leaq 0x5ba4(%rip), %rsi      # 0x738b
xorl %eax, %eax
callq 0x1030
incl (%r14)
movss 0x5833(%rip), %xmm0     # 0x702c
callq 0x1190
movq %rax, %r14
movss 0x5827(%rip), %xmm0     # 0x7030
callq 0x1190
cmpq %rax, %r14
movq %rbx, %rdi
cmoveq %r15, %rdi
movq %r13, %r14
cmoveq %r12, %r14
leaq 0x5ba0(%rip), %rsi      # 0x73c6
xorl %eax, %eax
callq 0x1030
incl (%r14)
movss 0x57fc(%rip), %xmm0     # 0x7034
callq 0x1190
movq %rax, %r14
movss 0x57ec(%rip), %xmm0     # 0x7034
callq 0x1190
cmpq %rax, %r14
cmoveq %r15, %rbx
cmoveq %r12, %r13
leaq 0x5ba2(%rip), %rsi      # 0x7401
movq %rbx, %rdi
xorl %eax, %eax
callq 0x1030
incl (%r13)
movss 0x57c3(%rip), %xmm0     # 0x7038
callq 0x1190
movq %rax, %rbx
movss 0x57b3(%rip), %xmm0     # 0x7038
callq 0x1190
cmpq %rax, %rbx
jne 0x18ba
leaq 0x57e7(%rip), %rdi      # 0x707d
leaq 0x5b8c(%rip), %rsi      # 0x7429
xorl %eax, %eax
callq 0x1030
movl 0x9882(%rip), %edx      # 0xb12c
incl %edx
movl %edx, 0x987a(%rip)      # 0xb12c
movl 0x9878(%rip), %esi      # 0xb130
jmp 0x18e3
leaq 0x57e5(%rip), %rdi      # 0x70a6
leaq 0x5b61(%rip), %rsi      # 0x7429
xorl %eax, %eax
callq 0x1030
movl 0x985b(%rip), %esi      # 0xb130
incl %esi
movl %esi, 0x9853(%rip)      # 0xb130
movl 0x9849(%rip), %edx      # 0xb12c
leaq 0x5b67(%rip), %rdi      # 0x7451
xorl %eax, %eax
callq 0x1030
xorl %eax, %eax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x9820(%rip), %r15      # 0xb12c
leaq 0x576a(%rip), %rdi      # 0x707d
jmp 0x1566