#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 is_valid_qth(char const *, size_t, size_t *);
int /*<<< orphan*/ printf(char *, char const *, size_t, int, int);
void testQthValidity(const char *qth, size_t qthStringSize, int expectedRetCode,
                     size_t expectedPrecision, size_t *takenTests,
                     size_t *passedTests) {
  ++(*takenTests);
  size_t precision = 0;
  int retcode = is_valid_qth(qth, qthStringSize, &precision);
  if (retcode == expectedRetCode) {
    if (retcode == 0 && precision != expectedPrecision) {
      printf("Test failed: is_valid_qth( \"%s\", %lu, &precision): got "
             "precision level %lu, expected level %lu. \n",
             qth, qthStringSize, precision, expectedPrecision);
      return;
    }
    ++(*passedTests);
    return;
  }
  printf("Test failed: is_valid_qth( \"%s\", %lu, &precision): got errcode %u, "
         "expected %d.\n",
         qth, qthStringSize, retcode, expectedRetCode);
  return;
}


x86 assembly (clang, -O0):
<testQthValidity>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
movq   $0x0,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x38(%rbp),%rdx
call   1030 <is_valid_qth@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jne    11c6 <testQthValidity+0xa6>
cmpl   $0x0,-0x3c(%rbp)
jne    11b3 <testQthValidity+0x93>
mov    -0x38(%rbp),%rax
cmp    -0x20(%rbp),%rax
je     11b3 <testQthValidity+0x93>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x38(%rbp),%rax
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %eax,%r8d
lea    0xe57(%rip),%rdi
call   1040 <printf@plt>
jmp    11e1 <testQthValidity+0xc1>
mov    -0x30(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
jmp    11e1 <testQthValidity+0xc1>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x3c(%rbp),%ecx
mov    -0x14(%rbp),%r8d
lea    0xe86(%rip),%rdi
call   1040 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testQthValidity>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %r9,%r12
mov    %rcx,%r14
mov    %edx,%ebp
mov    %rsi,%r15
mov    %rdi,%rbx
addq   $0x1,(%r8)
movq   $0x0,0x8(%rsp)
lea    0x8(%rsp),%rdx
call   1030 <is_valid_qth@plt>
cmp    %ebp,%eax
jne    116a <testQthValidity+0x4a>
test   %ebp,%ebp
jne    1163 <testQthValidity+0x43>
mov    0x8(%rsp),%rcx
cmp    %r14,%rcx
jne    118e <testQthValidity+0x6e>
addq   $0x1,(%r12)
jmp    1181 <testQthValidity+0x61>
lea    0xef1(%rip),%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %eax,%ecx
mov    %ebp,%r8d
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe6b(%rip),%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %r14d,%r8d
jmp    117c <testQthValidity+0x5c>

LLVM IR (-O0):
@.str = [98 x i8] c"Test failed: is_valid_qth( \22%s\22, %lu, &precision): got precision level %lu, expected level %lu. \0A\00"
@.str.1 = [81 x i8] c"Test failed: is_valid_qth( \22%s\22, %lu, &precision): got errcode %u, expected %d.\0A\00"
define void @testQthValidity(i8* %0, i64 %1, i32 %2, i64 %3, i64* %4, i64* %5) {
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
%10 = alloca i64
%11 = alloca i64*
%12 = alloca i64*
%13 = alloca i64
%14 = alloca i32
store i8* %0, i8** %7
store i64 %1, i64* %8
store i32 %2, i32* %9
store i64 %3, i64* %10
store i64* %4, i64** %11
store i64* %5, i64** %12
%15 = load i64*, i64** %11
%16 = load i64, i64* %15
%17 = add i64 %16, 1
store i64 %17, i64* %15
store i64 0, i64* %13
%18 = load i8*, i8** %7
%19 = load i64, i64* %8
%20 = call i32 @is_valid_qth(i8* %18, i64 %19, i64* %13)
store i32 %20, i32* %14
%21 = load i32, i32* %14
%22 = load i32, i32* %9
%23 = icmp eq i32 %21, %22
br i1 %23, label %24, label %43
24: ; preds = %6
%25 = load i32, i32* %14
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %39
27: ; preds = %24
%28 = load i64, i64* %13
%29 = load i64, i64* %10
%30 = icmp ne i64 %28, %29
br i1 %30, label %31, label %39
31: ; preds = %27
%32 = load i8*, i8** %7
%33 = load i64, i64* %8
%34 = load i64, i64* %13
%35 = trunc i64 %34 to i32
%36 = load i64, i64* %10
%37 = trunc i64 %36 to i32
%38 = call i32 @printf(i8* getelementptr inbounds ([98 x i8], [98 x i8]* @.str, i64 0, i64 0), i8* %32, i64 %33, i32 %35, i32 %37)
br label %49
39: ; preds = %27, %24
%40 = load i64*, i64** %12
%41 = load i64, i64* %40
%42 = add i64 %41, 1
store i64 %42, i64* %40
br label %49
43: ; preds = %6
%44 = load i8*, i8** %7
%45 = load i64, i64* %8
%46 = load i32, i32* %14
%47 = load i32, i32* %9
%48 = call i32 @printf(i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.1, i64 0, i64 0), i8* %44, i64 %45, i32 %46, i32 %47)
br label %49
49: ; preds = %43, %39, %31
ret void
}

LLVM IR (-O2):
@.str = [98 x i8] c"Test failed: is_valid_qth( \22%s\22, %lu, &precision): got precision level %lu, expected level %lu. \0A\00"
@.str.1 = [81 x i8] c"Test failed: is_valid_qth( \22%s\22, %lu, &precision): got errcode %u, expected %d.\0A\00"
define void @testQthValidity(i8* %0, i64 %1, i32 %2, i64 %3, i64* nocapture %4, i64* nocapture %5) {
%7 = alloca i64
%8 = load i64, i64* %4
%9 = add i64 %8, 1
store i64 %9, i64* %4
%10 = bitcast i64* %7 to i8*
store i64 0, i64* %7
%11 = call i32 @is_valid_qth(i8* %0, i64 %1, i64* %7)
%12 = icmp eq i32 %11, %2
br i1 %12, label %13, label %25
13: ; preds = %6
%14 = icmp eq i32 %2, 0
br i1 %14, label %15, label %22
15: ; preds = %13
%16 = load i64, i64* %7
%17 = icmp eq i64 %16, %3
br i1 %17, label %22, label %18
18: ; preds = %15
%19 = trunc i64 %16 to i32
%20 = trunc i64 %3 to i32
%21 = call i32 @printf(i8* getelementptr inbounds ([98 x i8], [98 x i8]* @.str, i64 0, i64 0), i8* %0, i64 %1, i32 %19, i32 %20)
br label %27
22: ; preds = %15, %13
%23 = load i64, i64* %5
%24 = add i64 %23, 1
store i64 %24, i64* %5
br label %27
25: ; preds = %6
%26 = call i32 @printf(i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.1, i64 0, i64 0), i8* %0, i64 %1, i32 %11, i32 %2)
br label %27
27: ; preds = %25, %22, %18
ret void
}