#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 134
#define SIGHUP 133
#define SIGILL 132
#define SIGINT 131
#define SIGKILL 130
#define SIGSEGV 129
#define SIGTERM 128
int /*<<< orphan*/ _exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ handle_fd(int /*<<< orphan*/, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
void abort_program(int signum) {
  handle_fd(0, 2);
  switch (signum) {
  case SIGABRT:
  case SIGHUP:
    fprintf(stderr, "\033[1;41merror:\033[0m"
                    "abnormal termination: exit");
    break;
  case SIGILL:
  case SIGSEGV:
    fprintf(stderr, "\033[1;41merror:\033[0m"
                    "invalid instruction: please contact the maintainer");
    break;
  case SIGINT:
    fprintf(stdout, "\033[1;44minfo:\033[0m"
                    "exit");
    break;
  case SIGTERM:
  case SIGKILL:
    fprintf(stdout, "\033[1;44minfo:\033[0m"
                    "termination request: exit");
    signum = 0;
    break;
  }
  _exit((signum > 0) ? 1 : 0);
}


x86 assembly (clang, -O0):
<abort_program>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
xor    %edi,%edi
mov    $0x2,%esi
call   1050 <handle_fd@plt>
mov    -0x4(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x6,%eax
ja     11da <abort_program+0xaa>
mov    -0x10(%rbp),%rax
lea    0xe99(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
lea    0xe9c(%rip),%rsi
call   1040 <fprintf@plt>
jmp    11da <abort_program+0xaa>
mov    0x2e4f(%rip),%rax
mov    (%rax),%edi
lea    0xeae(%rip),%rsi
call   1040 <fprintf@plt>
jmp    11da <abort_program+0xaa>
mov    0x2e2d(%rip),%rax
mov    (%rax),%edi
lea    0xed8(%rip),%rsi
call   1040 <fprintf@plt>
jmp    11da <abort_program+0xaa>
mov    0x2e13(%rip),%rax
mov    (%rax),%edi
lea    0xed3(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%ecx
xor    %edi,%edi
mov    $0x1,%eax
cmp    $0x0,%ecx
cmovg  %eax,%edi
call   1030 <_exit@plt>

x86 assembly (clang, -O2):
<abort_program>:
push   %rbx
mov    %edi,%ebx
xor    %edi,%edi
mov    $0x2,%esi
call   1050 <handle_fd@plt>
lea    -0x80(%rbx),%eax
cmp    $0x6,%eax
ja     1173 <abort_program+0x43>
cltq
lea    0x2c98(%rip),%rcx
mov    (%rcx,%rax,8),%rcx
lea    0xf55(%rip),%rdx
movslq (%rdx,%rax,4),%rsi
add    %rdx,%rsi
lea    0xf63(%rip),%rdx
mov    (%rdx,%rax,4),%ebx
mov    (%rcx),%edi
call   1040 <fprintf@plt>
xor    %edi,%edi
test   %ebx,%ebx
setg   %dil
call   1030 <_exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [44 x i8] c"\1B[1;41merror:\1B[0mabnormal termination: exit\00"
@.str.1 = [68 x i8] c"\1B[1;41merror:\1B[0minvalid instruction: please contact the maintainer\00"
@stdout = global i32 0
@.str.2 = [21 x i8] c"\1B[1;44minfo:\1B[0mexit\00"
@.str.3 = [42 x i8] c"\1B[1;44minfo:\1B[0mtermination request: exit\00"
define void @abort_program(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = call i32 @handle_fd(i32 0, i32 2)
%4 = load i32, i32* %2
switch i32 %4, label %17 [
i32 134, label %5
i32 133, label %5
i32 132, label %8
i32 129, label %8
i32 131, label %11
i32 128, label %14
i32 130, label %14
]
5: ; preds = %1, %1
%6 = load i32, i32* @stderr
%7 = call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
br label %17
8: ; preds = %1, %1
%9 = load i32, i32* @stderr
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.1, i64 0, i64 0))
br label %17
11: ; preds = %1
%12 = load i32, i32* @stdout
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
br label %17
14: ; preds = %1, %1
%15 = load i32, i32* @stdout
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %2
br label %17
17: ; preds = %1, %14, %11, %8, %5
%18 = load i32, i32* %2
%19 = icmp sgt i32 %18, 0
%20 = zext i1 %19 to i64
%21 = select i1 %19, i32 1, i32 0
%22 = call i32 @_exit(i32 %21)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [44 x i8] c"\1B[1;41merror:\1B[0mabnormal termination: exit\00"
@.str.1 = [68 x i8] c"\1B[1;41merror:\1B[0minvalid instruction: please contact the maintainer\00"
@stdout = global i32 0
@.str.2 = [21 x i8] c"\1B[1;44minfo:\1B[0mexit\00"
@.str.3 = [42 x i8] c"\1B[1;44minfo:\1B[0mtermination request: exit\00"
@switch.table.abort_program = [7 x i32*] [i32* @stdout, i32* @stderr, i32* @stdout, i32* @stdout, i32* @stderr, i32* @stderr, i32* @stderr]
@reltable.abort_program = [7 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([42 x i8]* @.str.3 to i64), i64 ptrtoint ([7 x i32]* @reltable.abort_program to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([68 x i8]* @.str.1 to i64), i64 ptrtoint ([7 x i32]* @reltable.abort_program to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([42 x i8]* @.str.3 to i64), i64 ptrtoint ([7 x i32]* @reltable.abort_program to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([21 x i8]* @.str.2 to i64), i64 ptrtoint ([7 x i32]* @reltable.abort_program to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([68 x i8]* @.str.1 to i64), i64 ptrtoint ([7 x i32]* @reltable.abort_program to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([44 x i8]* @.str to i64), i64 ptrtoint ([7 x i32]* @reltable.abort_program to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([44 x i8]* @.str to i64), i64 ptrtoint ([7 x i32]* @reltable.abort_program to i64)) to i32)]
@switch.table.abort_program.5 = [7 x i32] [i32 0, i32 129, i32 0, i32 131, i32 132, i32 133, i32 134]
define void @abort_program(i32 %0) {
%2 = tail call i32 @handle_fd(i32 0, i32 2)
%3 = add i32 %0, -128
%4 = icmp ult i32 %3, 7
br i1 %4, label %5, label %17
5: ; preds = %1
%6 = sext i32 %3 to i64
%7 = getelementptr inbounds [7 x i32*], [7 x i32*]* @switch.table.abort_program, i64 0, i64 %6
%8 = load i32*, i32** %7
%9 = sext i32 %3 to i64
%10 = shl i64 %9, 2
%11 = call i8* @llvm.load.relative.i64(i8* bitcast ([7 x i32]* @reltable.abort_program to i8*), i64 %10)
%12 = sext i32 %3 to i64
%13 = getelementptr inbounds [7 x i32], [7 x i32]* @switch.table.abort_program.5, i64 0, i64 %12
%14 = load i32, i32* %13
%15 = load i32, i32* %8
%16 = tail call i32 @fprintf(i32 %15, i8* %11)
br label %17
17: ; preds = %1, %5
%18 = phi i32 [ %0, %1 ], [ %14, %5 ]
%19 = icmp sgt i32 %18, 0
%20 = zext i1 %19 to i32
%21 = tail call i32 @_exit(i32 %20)
unreachable
}