#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
void passfail(const int count, const char *source, const unsigned line,
              const char *msg) {
  const char *pf[2] = {"[PASS]", "[FAIL]"};
  static int tally[2] = {0, 0};
  static int disable = 0;
  FILE *handle = fopen("PassFail.out", "a");
  if (msg[0] == 0) {
    if (count == 1) {
      disable = 1;
    } else if (!disable) {
      fprintf(handle, "%s (%s:%u) %d\t", pf[0], source, line, tally[0]);
      if (tally[1] != count)
        fprintf(handle, "\n");
      fprintf(handle, "%s (%s:%u) %d\t", pf[1], source, line, tally[1]);
      fprintf(handle, "RESULT\n");
    }
  } else if (!disable) {
    tally[!count]++;
    fprintf(handle, "%s (%s:%u) %s\n", pf[!count], source, line, msg);
  }
  fclose(handle);
}


x86 assembly (clang, -O0):
<passfail>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    0x2cc3(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2cc0(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xeab(%rip),%rdi
lea    0xeb1(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1230 <passfail+0x100>
cmpl   $0x1,-0x4(%rbp)
jne    119c <passfail+0x6c>
movl   $0x1,0x2ead(%rip)
jmp    122b <passfail+0xfb>
cmpl   $0x0,0x2ea1(%rip)
jne    1226 <passfail+0xf6>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    -0x14(%rbp),%r8d
mov    0x2e7c(%rip),%r9d
lea    0xe56(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e6c(%rip),%eax
cmp    -0x4(%rbp),%eax
je     11ef <passfail+0xbf>
mov    -0x38(%rbp),%rdi
lea    0xe4a(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x38(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    -0x14(%rbp),%r8d
mov    0x2e3a(%rip),%r9d
lea    0xe10(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x38(%rbp),%rdi
lea    0xe0d(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    122b <passfail+0xfb>
jmp    129d <passfail+0x16d>
cmpl   $0x0,0x2e0d(%rip)
jne    1298 <passfail+0x168>
cmpl   $0x0,-0x4(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
movslq %eax,%rcx
lea    0x2de7(%rip),%rax
mov    (%rax,%rcx,4),%edx
add    $0x1,%edx
lea    0x2dda(%rip),%rax
mov    %edx,(%rax,%rcx,4)
mov    -0x38(%rbp),%rdi
cmpl   $0x0,-0x4(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
cltq
mov    -0x30(%rbp,%rax,8),%rdx
mov    -0x10(%rbp),%rcx
mov    -0x14(%rbp),%r8d
mov    -0x20(%rbp),%r9
lea    0xda3(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    129d <passfail+0x16d>
mov    -0x38(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<passfail>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%rbx
mov    %edx,%r14d
mov    %rsi,%r15
mov    %edi,%ebp
lea    0xea4(%rip),%rdi
lea    0xeaa(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r12
cmpb   $0x0,(%rbx)
je     11ca <passfail+0x7a>
cmpb   $0x0,0x2ecf(%rip)
jne    125e <passfail+0x10e>
xor    %eax,%eax
test   %ebp,%ebp
sete   %al
lea    0x2eb3(%rip),%rcx
addl   $0x1,(%rcx,%rax,4)
lea    0xea0(%rip),%rcx
movslq (%rcx,%rax,4),%rdx
add    %rcx,%rdx
lea    0xe82(%rip),%rsi
mov    %r12,%rdi
mov    %r15,%rcx
mov    %r14d,%r8d
mov    %rbx,%r9
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    125e <passfail+0x10e>
cmp    $0x1,%ebp
jne    11db <passfail+0x8b>
movb   $0x1,0x2e7e(%rip)
jmp    125e <passfail+0x10e>
cmpb   $0x0,0x2e72(%rip)
jne    125e <passfail+0x10e>
mov    0x2e61(%rip),%r9d
lea    0xe2b(%rip),%rsi
lea    0xe07(%rip),%rdx
mov    %r12,%rdi
mov    %r15,%rcx
mov    %r14d,%r8d
xor    %eax,%eax
call   1050 <fprintf@plt>
cmp    %ebp,0x2e41(%rip)
je     1224 <passfail+0xd4>
mov    $0xa,%edi
mov    %r12,%rsi
call   1040 <fputc@plt>
mov    0x2e2c(%rip),%ebp
lea    0xdf2(%rip),%rsi
lea    0xdd5(%rip),%rdx
mov    %r12,%rdi
mov    %r15,%rcx
mov    %r14d,%r8d
mov    %ebp,%r9d
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    0xde0(%rip),%rdi
mov    $0x7,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1070 <fwrite@plt>
mov    %r12,%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"[PASS]\00"
@.str.1 = [7 x i8] c"[FAIL]\00"
@__const.passfail.pf = [2 x i8*] [i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i32 0, i32 0)]
@passfail.tally = internal global [2 x i32] zeroinitializer
@passfail.disable = internal global i32 0
@.str.2 = [13 x i8] c"PassFail.out\00"
@.str.3 = [2 x i8] c"a\00"
@.str.4 = [15 x i8] c"%s (%s:%u) %d\09\00"
@.str.5 = [2 x i8] c"\0A\00"
@.str.6 = [8 x i8] c"RESULT\0A\00"
@.str.7 = [15 x i8] c"%s (%s:%u) %s\0A\00"
define void @passfail(i32 %0, i8* %1, i32 %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca [2 x i8*]
%10 = alloca i32*
store i32 %0, i32* %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i8* %3, i8** %8
%11 = bitcast [2 x i8*]* %9 to i8*
%12 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %12, i32** %10
%13 = load i8*, i8** %8
%14 = getelementptr inbounds i8, i8* %13, i64 0
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %51
18: ; preds = %4
%19 = load i32, i32* %5
%20 = icmp eq i32 %19, 1
br i1 %20, label %21, label %22
21: ; preds = %18
store i32 1, i32* @passfail.disable
br label %50
22: ; preds = %18
%23 = load i32, i32* @passfail.disable
%24 = icmp ne i32 %23, 0
br i1 %24, label %49, label %25
25: ; preds = %22
%26 = load i32*, i32** %10
%27 = getelementptr inbounds [2 x i8*], [2 x i8*]* %9, i64 0, i64 0
%28 = load i8*, i8** %27
%29 = load i8*, i8** %6
%30 = load i32, i32* %7
%31 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @passfail.tally, i64 0, i64 0)
%32 = call i32 (i32*, i8*, ...) @fprintf(i32* %26, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* %28, i8* %29, i32 %30, i32 %31)
%33 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @passfail.tally, i64 0, i64 1)
%34 = load i32, i32* %5
%35 = icmp ne i32 %33, %34
br i1 %35, label %36, label %39
36: ; preds = %25
%37 = load i32*, i32** %10
%38 = call i32 (i32*, i8*, ...) @fprintf(i32* %37, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %39
39: ; preds = %36, %25
%40 = load i32*, i32** %10
%41 = getelementptr inbounds [2 x i8*], [2 x i8*]* %9, i64 0, i64 1
%42 = load i8*, i8** %41
%43 = load i8*, i8** %6
%44 = load i32, i32* %7
%45 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @passfail.tally, i64 0, i64 1)
%46 = call i32 (i32*, i8*, ...) @fprintf(i32* %40, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* %42, i8* %43, i32 %44, i32 %45)
%47 = load i32*, i32** %10
%48 = call i32 (i32*, i8*, ...) @fprintf(i32* %47, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
br label %49
49: ; preds = %39, %22
br label %50
50: ; preds = %49, %21
br label %76
51: ; preds = %4
%52 = load i32, i32* @passfail.disable
%53 = icmp ne i32 %52, 0
br i1 %53, label %75, label %54
54: ; preds = %51
%55 = load i32, i32* %5
%56 = icmp ne i32 %55, 0
%57 = xor i1 %56, true
%58 = zext i1 %57 to i32
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [2 x i32], [2 x i32]* @passfail.tally, i64 0, i64 %59
%61 = load i32, i32* %60
%62 = add nsw i32 %61, 1
store i32 %62, i32* %60
%63 = load i32*, i32** %10
%64 = load i32, i32* %5
%65 = icmp ne i32 %64, 0
%66 = xor i1 %65, true
%67 = zext i1 %66 to i32
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [2 x i8*], [2 x i8*]* %9, i64 0, i64 %68
%70 = load i8*, i8** %69
%71 = load i8*, i8** %6
%72 = load i32, i32* %7
%73 = load i8*, i8** %8
%74 = call i32 (i32*, i8*, ...) @fprintf(i32* %63, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i8* %70, i8* %71, i32 %72, i8* %73)
br label %75
75: ; preds = %54, %51
br label %76
76: ; preds = %75, %50
%77 = load i32*, i32** %10
%78 = call i32 @fclose(i32* %77)
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"[PASS]\00"
@.str.1 = [7 x i8] c"[FAIL]\00"
@reltable.passfail = [2 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str to i64), i64 ptrtoint ([2 x i32]* @reltable.passfail to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.1 to i64), i64 ptrtoint ([2 x i32]* @reltable.passfail to i64)) to i32)]
@passfail.tally = internal unnamed_addr global [2 x i32] zeroinitializer
@passfail.disable = internal unnamed_addr global i1 false
@.str.2 = [13 x i8] c"PassFail.out\00"
@.str.3 = [2 x i8] c"a\00"
@.str.4 = [15 x i8] c"%s (%s:%u) %d\09\00"
@.str.6 = [8 x i8] c"RESULT\0A\00"
@.str.7 = [15 x i8] c"%s (%s:%u) %s\0A\00"
define void @passfail(i32 %0, i8* %1, i32 %2, i8* %3) {
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%6 = load i8, i8* %3
%7 = icmp eq i8 %6, 0
br i1 %7, label %8, label %25
8: ; preds = %4
%9 = icmp eq i32 %0, 1
br i1 %9, label %10, label %11
10: ; preds = %8
store i1 true, i1* @passfail.disable
br label %36
11: ; preds = %8
%12 = load i1, i1* @passfail.disable
br i1 %12, label %36, label %13
13: ; preds = %11
%14 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @passfail.tally, i64 0, i64 0)
%15 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %5, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %1, i32 %2, i32 %14)
%16 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @passfail.tally, i64 0, i64 1)
%17 = icmp eq i32 %16, %0
br i1 %17, label %21, label %18
18: ; preds = %13
%19 = tail call i32 @fputc(i32 10, i32* %5)
%20 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @passfail.tally, i64 0, i64 1)
br label %21
21: ; preds = %18, %13
%22 = phi i32 [ %20, %18 ], [ %0, %13 ]
%23 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %5, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %1, i32 %2, i32 %22)
%24 = tail call i64 @fwrite(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i64 7, i64 1, i32* %5)
br label %36
25: ; preds = %4
%26 = load i1, i1* @passfail.disable
br i1 %26, label %36, label %27
27: ; preds = %25
%28 = icmp eq i32 %0, 0
%29 = zext i1 %28 to i64
%30 = getelementptr inbounds [2 x i32], [2 x i32]* @passfail.tally, i64 0, i64 %29
%31 = load i32, i32* %30
%32 = add nsw i32 %31, 1
store i32 %32, i32* %30
%33 = shl i64 %29, 2
%34 = call i8* @llvm.load.relative.i64(i8* bitcast ([2 x i32]* @reltable.passfail to i8*), i64 %33)
%35 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %5, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i8* %34, i8* %1, i32 %2, i8* %3)
br label %36
36: ; preds = %25, %27, %10, %21, %11
%37 = tail call i32 @fclose(i32* %5)
ret void
}