#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*/ _exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
void test_fail() {
  do {
    printf("test_fail"
           "\n");
    fflush(stdout);
  } while (0);
  {
    int i = 1;
    printf("this test will fail due to a false assert\n");
    do {
      if (!(i == 0)) {
        printf("Assertion failed: "
               "i == 0"
               "\n");
        do {
          fclose(stdout);
          fclose(stderr);
          _exit(1);
        } while (0);
      }
    } while (0);
  }
}


x86 assembly (clang, -O0):
<test_fail>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
call   1050 <printf@plt>
mov    0x2e7d(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
movl   $0x1,-0x4(%rbp)
lea    0xe9b(%rip),%rdi
call   1050 <printf@plt>
cmpl   $0x0,-0x4(%rbp)
je     11b1 <test_fail+0x71>
lea    0xeb0(%rip),%rdi
call   1050 <printf@plt>
mov    0x2e46(%rip),%rax
mov    (%rax),%edi
call   1040 <fclose@plt>
mov    0x2e40(%rip),%rax
mov    (%rax),%edi
call   1040 <fclose@plt>
mov    $0x1,%edi
call   1030 <_exit@plt>
jmp    11b6 <test_fail+0x76>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_fail>:
push   %rbx
lea    0xeb8(%rip),%rdi
call   1040 <puts@plt>
mov    0x2e84(%rip),%rbx
mov    (%rbx),%edi
call   1060 <fflush@plt>
lea    0xea8(%rip),%rdi
call   1040 <puts@plt>
lea    0xec6(%rip),%rdi
call   1040 <puts@plt>
mov    (%rbx),%edi
call   1050 <fclose@plt>
mov    0x2e5f(%rip),%rax
mov    (%rax),%edi
call   1050 <fclose@plt>
mov    $0x1,%edi
call   1030 <_exit@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"test_fail\0A\00"
@stdout = global i32 0
@.str.1 = [43 x i8] c"this test will fail due to a false assert\0A\00"
@.str.2 = [26 x i8] c"Assertion failed: i == 0\0A\00"
@stderr = global i32 0
define void @test_fail() {
%1 = alloca i32
br label %2
2: ; preds = %0
%3 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* @stdout
%5 = call i32 @fflush(i32 %4)
br label %6
6: ; preds = %2
store i32 1, i32* %1
%7 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
br label %8
8: ; preds = %6
%9 = load i32, i32* %1
%10 = icmp eq i32 %9, 0
br i1 %10, label %20, label %11
11: ; preds = %8
%12 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %13
13: ; preds = %11
%14 = load i32, i32* @stdout
%15 = call i32 @fclose(i32 %14)
%16 = load i32, i32* @stderr
%17 = call i32 @fclose(i32 %16)
%18 = call i32 @_exit(i32 1)
unreachable
19: ; No predecessors!
br label %20
20: ; preds = %19, %8
br label %21
21: ; preds = %20
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
@stderr = global i32 0
@str = [10 x i8] c"test_fail\00"
@str.3 = [42 x i8] c"this test will fail due to a false assert\00"
@str.4 = [25 x i8] c"Assertion failed: i == 0\00"
define void @test_fail() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
%2 = load i32, i32* @stdout
%3 = tail call i32 @fflush(i32 %2)
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.3, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.4, i64 0, i64 0))
%6 = load i32, i32* @stdout
%7 = tail call i32 @fclose(i32 %6)
%8 = load i32, i32* @stderr
%9 = tail call i32 @fclose(i32 %8)
%10 = tail call i32 @_exit(i32 1)
unreachable
}