#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 */
#define SIGABRT 133
#define SIGFPE 132
#define SIGILL 131
#define SIGINT 130
#define SIGSEGV 129
#define SIGTERM 128
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stdout;
void excfun(int sigid) {
  fprintf(stdout, "\n Unexpected error:");
  fflush(stdout);
  switch (sigid) {
  case SIGABRT:
    fprintf(stdout, "  Abnormal stop\n");
    exit(1);
  case SIGFPE:
    fprintf(stdout, "  Floating-point exception\n");
    exit(1);
  case SIGILL:
    fprintf(stdout, "  Illegal instruction\n");
    exit(1);
  case SIGSEGV:
    fprintf(stdout, "  Segmentation fault\n");
    exit(1);
  case SIGTERM:
  case SIGINT:
    fprintf(stdout, "  Program killed\n");
    exit(1);
  }
  exit(1);
}


x86 assembly (clang, -O0):
<excfun>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    0x2e9e(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    (%rax),%edi
lea    0xec9(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
mov    -0x4(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x5,%eax
ja     1223 <excfun+0xf3>
mov    -0x10(%rbp),%rax
lea    0xe81(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
lea    0xe94(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
lea    0xe86(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    0x2e13(%rip),%rax
mov    (%rax),%edi
lea    0xe83(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    0x2df4(%rip),%rax
mov    (%rax),%edi
lea    0xe7b(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    0x2dd5(%rip),%rax
mov    (%rax),%edi
lea    0xe72(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<excfun>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
mov    0x2ea3(%rip),%r14
mov    (%r14),%edi
lea    0xed1(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%r14),%edi
call   1040 <fflush@plt>
add    $0xffffff80,%ebx
cmp    $0x5,%ebx
ja     1178 <excfun+0x48>
lea    0xe9d(%rip),%rax
movslq (%rax,%rbx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
mov    (%r14),%edi
lea    0xf10(%rip),%rsi
jmp    11b0 <excfun+0x80>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    (%r14),%edi
lea    0xee4(%rip),%rsi
jmp    11b0 <excfun+0x80>
mov    (%r14),%edi
lea    0xec1(%rip),%rsi
jmp    11b0 <excfun+0x80>
mov    (%r14),%edi
lea    0xe88(%rip),%rsi
jmp    11b0 <excfun+0x80>
mov    (%r14),%edi
lea    0xe8d(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [20 x i8] c"\0A Unexpected error:\00"
@.str.1 = [17 x i8] c" Abnormal stop\0A\00"
@.str.2 = [28 x i8] c" Floating-point exception\0A\00"
@.str.3 = [23 x i8] c" Illegal instruction\0A\00"
@.str.4 = [22 x i8] c" Segmentation fault\0A\00"
@.str.5 = [18 x i8] c" Program killed\0A\00"
define void @excfun(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* @stdout
%4 = call i32 @fprintf(i32 %3, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%5 = load i32, i32* @stdout
%6 = call i32 @fflush(i32 %5)
%7 = load i32, i32* %2
switch i32 %7, label %28 [
i32 133, label %8
i32 132, label %12
i32 131, label %16
i32 129, label %20
i32 128, label %24
i32 130, label %24
]
8: ; preds = %1
%9 = load i32, i32* @stdout
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @exit(i32 1)
unreachable
12: ; preds = %1
%13 = load i32, i32* @stdout
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %1
%17 = load i32, i32* @stdout
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %1
%21 = load i32, i32* @stdout
%22 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
%23 = call i32 @exit(i32 1)
unreachable
24: ; preds = %1, %1
%25 = load i32, i32* @stdout
%26 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
%27 = call i32 @exit(i32 1)
unreachable
28: ; preds = %1
%29 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [20 x i8] c"\0A Unexpected error:\00"
@.str.1 = [17 x i8] c" Abnormal stop\0A\00"
@.str.2 = [28 x i8] c" Floating-point exception\0A\00"
@.str.3 = [23 x i8] c" Illegal instruction\0A\00"
@.str.4 = [22 x i8] c" Segmentation fault\0A\00"
@.str.5 = [18 x i8] c" Program killed\0A\00"
define void @excfun(i32 %0) {
%2 = load i32, i32* @stdout
%3 = tail call i32 @fprintf(i32 %2, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* @stdout
%5 = tail call i32 @fflush(i32 %4)
switch i32 %0, label %26 [
i32 133, label %6
i32 132, label %10
i32 131, label %14
i32 129, label %18
i32 128, label %22
i32 130, label %22
]
6: ; preds = %1
%7 = load i32, i32* @stdout
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %1
%11 = load i32, i32* @stdout
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %1
%15 = load i32, i32* @stdout
%16 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%17 = tail call i32 @exit(i32 1)
unreachable
18: ; preds = %1
%19 = load i32, i32* @stdout
%20 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
%21 = tail call i32 @exit(i32 1)
unreachable
22: ; preds = %1, %1
%23 = load i32, i32* @stdout
%24 = tail call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
%25 = tail call i32 @exit(i32 1)
unreachable
26: ; preds = %1
%27 = tail call i32 @exit(i32 1)
unreachable
}