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

/* Variables and functions */
#define SIGBUS 131
#define SIGSEGV 130
#define SIGUSR1 129
#define SIGUSR2 128
int /*<<< orphan*/ _IOLBF;
int /*<<< orphan*/ setvbuf(int /*<<< orphan*/, int /*<<< orphan*/ *,
                           int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ test(int, int const, int const);
int main() {
  static const int catch[] = {SIGSEGV, SIGUSR1};
  static const int fatal[] = {SIGBUS, SIGUSR2};
  int block, catchidx, fatalidx;
  setvbuf(stdout, NULL, _IOLBF, 0);
  for (block = 0; block < 2; block++)
    for (catchidx = 0; catchidx < sizeof(catch) / sizeof(*catch); catchidx++)
      for (fatalidx = 0; fatalidx < sizeof(fatal) / sizeof(*fatal); fatalidx++)
        test(block, catch[catchidx], fatal[fatalidx]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2ea2(%rip),%rax
mov    (%rax),%edi
mov    0x2ea1(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
xor    %ecx,%ecx
call   1030 <setvbuf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11df <main+0xbf>
movl   $0x0,-0xc(%rbp)
movslq -0xc(%rbp),%rax
cmp    $0x2,%rax
jae    11cc <main+0xac>
movl   $0x0,-0x10(%rbp)
movslq -0x10(%rbp),%rax
cmp    $0x2,%rax
jae    11b9 <main+0x99>
mov    -0x8(%rbp),%edi
movslq -0xc(%rbp),%rcx
lea    0xe6b(%rip),%rax
mov    (%rax,%rcx,4),%esi
movslq -0x10(%rbp),%rcx
lea    0xe65(%rip),%rax
mov    (%rax,%rcx,4),%edx
call   1040 <test@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1179 <main+0x59>
jmp    11be <main+0x9e>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1164 <main+0x44>
jmp    11d1 <main+0xb1>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1153 <main+0x33>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    0x2eb0(%rip),%rax
mov    (%rax),%edi
mov    0x2eaf(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
xor    %ecx,%ecx
call   1030 <setvbuf@plt>
xor    %edi,%edi
mov    $0x82,%esi
mov    $0x83,%edx
call   1040 <test@plt>
xor    %edi,%edi
mov    $0x82,%esi
mov    $0x80,%edx
call   1040 <test@plt>
xor    %edi,%edi
mov    $0x81,%esi
mov    $0x83,%edx
call   1040 <test@plt>
xor    %edi,%edi
mov    $0x81,%esi
mov    $0x80,%edx
call   1040 <test@plt>
mov    $0x1,%edi
mov    $0x82,%esi
mov    $0x83,%edx
call   1040 <test@plt>
mov    $0x1,%edi
mov    $0x82,%esi
mov    $0x80,%edx
call   1040 <test@plt>
mov    $0x1,%edi
mov    $0x81,%esi
mov    $0x83,%edx
call   1040 <test@plt>
mov    $0x1,%edi
mov    $0x81,%esi
mov    $0x80,%edx
call   1040 <test@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@main.catch = internal constant [2 x i32] [i32 130, i32 129]
@main.fatal = internal constant [2 x i32] [i32 131, i32 128]
@stdout = global i32 0
@_IOLBF = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = load i32, i32* @stdout
%6 = load i32, i32* @_IOLBF
%7 = call i32 @setvbuf(i32 %5, i32* null, i32 %6, i32 0)
store i32 0, i32* %2
br label %8
8: ; preds = %40, %0
%9 = load i32, i32* %2
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %43
11: ; preds = %8
store i32 0, i32* %3
br label %12
12: ; preds = %36, %11
%13 = load i32, i32* %3
%14 = sext i32 %13 to i64
%15 = icmp ult i64 %14, 2
br i1 %15, label %16, label %39
16: ; preds = %12
store i32 0, i32* %4
br label %17
17: ; preds = %32, %16
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = icmp ult i64 %19, 2
br i1 %20, label %21, label %35
21: ; preds = %17
%22 = load i32, i32* %2
%23 = load i32, i32* %3
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [2 x i32], [2 x i32]* @main.catch, i64 0, i64 %24
%26 = load i32, i32* %25
%27 = load i32, i32* %4
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [2 x i32], [2 x i32]* @main.fatal, i64 0, i64 %28
%30 = load i32, i32* %29
%31 = call i32 @test(i32 %22, i32 %26, i32 %30)
br label %32
32: ; preds = %21
%33 = load i32, i32* %4
%34 = add nsw i32 %33, 1
store i32 %34, i32* %4
br label %17
35: ; preds = %17
br label %36
36: ; preds = %35
%37 = load i32, i32* %3
%38 = add nsw i32 %37, 1
store i32 %38, i32* %3
br label %12
39: ; preds = %12
br label %40
40: ; preds = %39
%41 = load i32, i32* %2
%42 = add nsw i32 %41, 1
store i32 %42, i32* %2
br label %8
43: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
@stdout = global i32 0
@_IOLBF = global i32 0
define i32 @main() {
%1 = load i32, i32* @stdout
%2 = load i32, i32* @_IOLBF
%3 = tail call i32 @setvbuf(i32 %1, i32* null, i32 %2, i32 0)
%4 = tail call i32 @test(i32 0, i32 130, i32 131)
%5 = tail call i32 @test(i32 0, i32 130, i32 128)
%6 = tail call i32 @test(i32 0, i32 129, i32 131)
%7 = tail call i32 @test(i32 0, i32 129, i32 128)
%8 = tail call i32 @test(i32 1, i32 130, i32 131)
%9 = tail call i32 @test(i32 1, i32 130, i32 128)
%10 = tail call i32 @test(i32 1, i32 129, i32 131)
%11 = tail call i32 @test(i32 1, i32 129, i32 128)
ret i32 0
}