#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 */
struct sigaction {
  scalar_t__ sa_handler;
};
typedef int /*<<< orphan*/ sigset_t;

/* Variables and functions */
scalar_t__ EOF;
int /*<<< orphan*/ SIGABRT;
scalar_t__ SIG_DFL;
scalar_t__ SIG_IGN;
int /*<<< orphan*/ SIG_UNBLOCK;
int /*<<< orphan*/ STDERR_FILENO;
int /*<<< orphan*/ STDOUT_FILENO;
int close(int /*<<< orphan*/);
scalar_t__ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ pexit(char *);
int /*<<< orphan*/ raise(int /*<<< orphan*/);
int sigaction(int /*<<< orphan*/, struct sigaction *, struct sigaction *);
int /*<<< orphan*/ sigaddset(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ sigemptyset(int /*<<< orphan*/ *);
int sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
void _abort() {
  sigset_t sigabrt;
  struct sigaction oldHandler;
  sigemptyset(&sigabrt);
  sigaddset(&sigabrt, SIGABRT);
  if (sigprocmask(SIG_UNBLOCK, &sigabrt, NULL) == -1) {
    pexit("sigprocmask");
  }
  if (sigaction(SIGABRT, NULL, &oldHandler) == -1) {
    pexit("sigaction");
  }
  if (oldHandler.sa_handler == SIG_IGN) {
    oldHandler.sa_handler = SIG_DFL;
    if (sigaction(SIGABRT, &oldHandler, NULL) == -1) {
      pexit("sigaction");
    }
  }
  if (oldHandler.sa_handler != SIG_DFL) {
    raise(SIGABRT);
    oldHandler.sa_handler = SIG_DFL;
    if (sigaction(SIGABRT, &oldHandler, NULL) == -1) {
      pexit("sigaction");
    }
  }
  if (fflush(stdout) == EOF) {
    pexit("fflush");
  }
  if (fflush(stderr) == EOF) {
    pexit("fflush");
  }
  if (close(STDOUT_FILENO) == -1) {
    pexit("close");
  }
  if (close(STDERR_FILENO) == -1) {
    pexit("close");
  }
  raise(SIGABRT);
}


x86 assembly (clang, -O0):
<_abort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x4(%rbp),%rdi
call   1070 <sigemptyset@plt>
mov    0x2e08(%rip),%rax
mov    (%rax),%esi
lea    -0x4(%rbp),%rdi
call   10a0 <sigaddset@plt>
mov    0x2e36(%rip),%rax
mov    (%rax),%edi
lea    -0x4(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigprocmask@plt>
cmp    $0xffffffff,%eax
jne    11ce <_abort+0x4e>
lea    0xe37(%rip),%rdi
call   1090 <pexit@plt>
mov    0x2dcb(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
lea    -0x10(%rbp),%rdx
call   1050 <sigaction@plt>
cmp    $0xffffffff,%eax
jne    11f9 <_abort+0x79>
lea    0xe18(%rip),%rdi
call   1090 <pexit@plt>
mov    -0x10(%rbp),%rax
mov    0x2dcc(%rip),%rcx
cmp    (%rcx),%rax
jne    124b <_abort+0xcb>
mov    0x2d9c(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x10(%rbp)
mov    0x2d7e(%rip),%rax
mov    (%rax),%edi
lea    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <sigaction@plt>
cmp    $0xffffffff,%eax
jne    1246 <_abort+0xc6>
lea    0xdcb(%rip),%rdi
call   1090 <pexit@plt>
jmp    124b <_abort+0xcb>
mov    -0x10(%rbp),%rax
mov    0x2d5a(%rip),%rcx
cmp    (%rcx),%rax
je     12ab <_abort+0x12b>
mov    0x2d3a(%rip),%rax
mov    (%rax),%edi
call   1040 <raise@plt>
mov    0x2d3c(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x10(%rbp)
mov    0x2d1e(%rip),%rax
mov    (%rax),%edi
lea    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <sigaction@plt>
cmp    $0xffffffff,%eax
jne    12a6 <_abort+0x126>
lea    0xd6b(%rip),%rdi
call   1090 <pexit@plt>
jmp    12ab <_abort+0x12b>
mov    0x2cf6(%rip),%rax
mov    (%rax),%edi
call   1080 <fflush@plt>
mov    0x2d18(%rip),%rcx
cmp    (%rcx),%rax
jne    12d5 <_abort+0x155>
lea    0xd46(%rip),%rdi
call   1090 <pexit@plt>
mov    0x2ce4(%rip),%rax
mov    (%rax),%edi
call   1080 <fflush@plt>
mov    0x2cee(%rip),%rcx
cmp    (%rcx),%rax
jne    12ff <_abort+0x17f>
lea    0xd1c(%rip),%rdi
call   1090 <pexit@plt>
mov    0x2cea(%rip),%rax
mov    (%rax),%edi
call   1060 <close@plt>
cmp    $0xffffffff,%eax
jne    1322 <_abort+0x1a2>
lea    0xd00(%rip),%rdi
call   1090 <pexit@plt>
mov    0x2c8f(%rip),%rax
mov    (%rax),%edi
call   1060 <close@plt>
cmp    $0xffffffff,%eax
jne    1345 <_abort+0x1c5>
lea    0xcdd(%rip),%rdi
call   1090 <pexit@plt>
mov    0x2c54(%rip),%rax
mov    (%rax),%edi
call   1040 <raise@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_abort>:
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0x14(%rsp),%rbx
mov    %rbx,%rdi
call   1070 <sigemptyset@plt>
mov    0x2e05(%rip),%r14
mov    (%r14),%esi
mov    %rbx,%rdi
call   10a0 <sigaddset@plt>
mov    0x2e33(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
xor    %edx,%edx
call   1030 <sigprocmask@plt>
cmp    $0xffffffff,%eax
jne    11ca <_abort+0x4a>
lea    0xe3b(%rip),%rdi
call   1090 <pexit@plt>
mov    (%r14),%edi
lea    0x8(%rsp),%rdx
xor    %esi,%esi
call   1050 <sigaction@plt>
cmp    $0xffffffff,%eax
jne    11ea <_abort+0x6a>
lea    0xe27(%rip),%rdi
call   1090 <pexit@plt>
mov    0x8(%rsp),%rax
mov    0x2dda(%rip),%rcx
cmp    (%rcx),%rax
jne    122a <_abort+0xaa>
mov    0x2dae(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x8(%rsp)
mov    (%r14),%edi
lea    0x8(%rsp),%rsi
xor    %edx,%edx
call   1050 <sigaction@plt>
cmp    $0xffffffff,%eax
jne    122a <_abort+0xaa>
lea    0xde7(%rip),%rdi
call   1090 <pexit@plt>
mov    0x8(%rsp),%rax
mov    0x2d7a(%rip),%rbx
cmp    (%rbx),%rax
je     126b <_abort+0xeb>
mov    (%r14),%edi
call   1040 <raise@plt>
mov    (%rbx),%rax
mov    %rax,0x8(%rsp)
mov    (%r14),%edi
lea    0x8(%rsp),%rsi
xor    %edx,%edx
call   1050 <sigaction@plt>
cmp    $0xffffffff,%eax
jne    126b <_abort+0xeb>
lea    0xda6(%rip),%rdi
call   1090 <pexit@plt>
mov    0x2d36(%rip),%rax
mov    (%rax),%edi
call   1080 <fflush@plt>
mov    0x2d58(%rip),%rbx
cmp    (%rbx),%rax
jne    1291 <_abort+0x111>
lea    0xd8a(%rip),%rdi
call   1090 <pexit@plt>
mov    0x2d28(%rip),%rax
mov    (%rax),%edi
call   1080 <fflush@plt>
cmp    (%rbx),%rax
jne    12b0 <_abort+0x130>
lea    0xd6b(%rip),%rdi
call   1090 <pexit@plt>
mov    0x2d39(%rip),%rax
mov    (%rax),%edi
call   1060 <close@plt>
cmp    $0xffffffff,%eax
jne    12cf <_abort+0x14f>
lea    0xd53(%rip),%rdi
call   1090 <pexit@plt>
mov    0x2ce2(%rip),%rax
mov    (%rax),%edi
call   1060 <close@plt>
cmp    $0xffffffff,%eax
jne    12ee <_abort+0x16e>
lea    0xd34(%rip),%rdi
call   1090 <pexit@plt>
mov    (%r14),%edi
call   1040 <raise@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.sigaction = type { i64 }
@SIGABRT = global i32 0
@SIG_UNBLOCK = global i32 0
@.str = [12 x i8] c"sigprocmask\00"
@.str.1 = [10 x i8] c"sigaction\00"
@SIG_IGN = global i64 0
@SIG_DFL = global i64 0
@stdout = global i32 0
@EOF = global i64 0
@.str.2 = [7 x i8] c"fflush\00"
@stderr = global i32 0
@STDOUT_FILENO = global i32 0
@.str.3 = [6 x i8] c"close\00"
@STDERR_FILENO = global i32 0
define void @_abort() {
%1 = alloca i32
%2 = alloca %struct.sigaction
%3 = call i32 @sigemptyset(i32* %1)
%4 = load i32, i32* @SIGABRT
%5 = call i32 @sigaddset(i32* %1, i32 %4)
%6 = load i32, i32* @SIG_UNBLOCK
%7 = call i32 @sigprocmask(i32 %6, i32* %1, i32* null)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 @pexit(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %0
%12 = load i32, i32* @SIGABRT
%13 = call i32 @sigaction(i32 %12, %struct.sigaction* null, %struct.sigaction* %2)
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = call i32 @pexit(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %17
17: ; preds = %15, %11
%18 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %2, i32 0, i32 0
%19 = load i64, i64* %18
%20 = load i64, i64* @SIG_IGN
%21 = icmp eq i64 %19, %20
br i1 %21, label %22, label %31
22: ; preds = %17
%23 = load i64, i64* @SIG_DFL
%24 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %2, i32 0, i32 0
store i64 %23, i64* %24
%25 = load i32, i32* @SIGABRT
%26 = call i32 @sigaction(i32 %25, %struct.sigaction* %2, %struct.sigaction* null)
%27 = icmp eq i32 %26, -1
br i1 %27, label %28, label %30
28: ; preds = %22
%29 = call i32 @pexit(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %30
30: ; preds = %28, %22
br label %31
31: ; preds = %30, %17
%32 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %2, i32 0, i32 0
%33 = load i64, i64* %32
%34 = load i64, i64* @SIG_DFL
%35 = icmp ne i64 %33, %34
br i1 %35, label %36, label %47
36: ; preds = %31
%37 = load i32, i32* @SIGABRT
%38 = call i32 @raise(i32 %37)
%39 = load i64, i64* @SIG_DFL
%40 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %2, i32 0, i32 0
store i64 %39, i64* %40
%41 = load i32, i32* @SIGABRT
%42 = call i32 @sigaction(i32 %41, %struct.sigaction* %2, %struct.sigaction* null)
%43 = icmp eq i32 %42, -1
br i1 %43, label %44, label %46
44: ; preds = %36
%45 = call i32 @pexit(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %46
46: ; preds = %44, %36
br label %47
47: ; preds = %46, %31
%48 = load i32, i32* @stdout
%49 = call i64 @fflush(i32 %48)
%50 = load i64, i64* @EOF
%51 = icmp eq i64 %49, %50
br i1 %51, label %52, label %54
52: ; preds = %47
%53 = call i32 @pexit(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %54
54: ; preds = %52, %47
%55 = load i32, i32* @stderr
%56 = call i64 @fflush(i32 %55)
%57 = load i64, i64* @EOF
%58 = icmp eq i64 %56, %57
br i1 %58, label %59, label %61
59: ; preds = %54
%60 = call i32 @pexit(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %61
61: ; preds = %59, %54
%62 = load i32, i32* @STDOUT_FILENO
%63 = call i32 @close(i32 %62)
%64 = icmp eq i32 %63, -1
br i1 %64, label %65, label %67
65: ; preds = %61
%66 = call i32 @pexit(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %67
67: ; preds = %65, %61
%68 = load i32, i32* @STDERR_FILENO
%69 = call i32 @close(i32 %68)
%70 = icmp eq i32 %69, -1
br i1 %70, label %71, label %73
71: ; preds = %67
%72 = call i32 @pexit(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %73
73: ; preds = %71, %67
%74 = load i32, i32* @SIGABRT
%75 = call i32 @raise(i32 %74)
ret void
}

LLVM IR (-O2):
%struct.sigaction = type { i64 }
@SIGABRT = global i32 0
@SIG_UNBLOCK = global i32 0
@.str = [12 x i8] c"sigprocmask\00"
@.str.1 = [10 x i8] c"sigaction\00"
@SIG_IGN = global i64 0
@SIG_DFL = global i64 0
@stdout = global i32 0
@EOF = global i64 0
@.str.2 = [7 x i8] c"fflush\00"
@stderr = global i32 0
@STDOUT_FILENO = global i32 0
@.str.3 = [6 x i8] c"close\00"
@STDERR_FILENO = global i32 0
define void @_abort() {
%1 = alloca i32
%2 = alloca %struct.sigaction
%3 = bitcast i32* %1 to i8*
%4 = bitcast %struct.sigaction* %2 to i8*
%5 = call i32 @sigemptyset(i32* %1)
%6 = load i32, i32* @SIGABRT
%7 = call i32 @sigaddset(i32* %1, i32 %6)
%8 = load i32, i32* @SIG_UNBLOCK
%9 = call i32 @sigprocmask(i32 %8, i32* %1, i32* null)
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = call i32 @pexit(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %11, %0
%14 = load i32, i32* @SIGABRT
%15 = call i32 @sigaction(i32 %14, %struct.sigaction* null, %struct.sigaction* %2)
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = call i32 @pexit(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %19
19: ; preds = %17, %13
%20 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %2, i64 0, i32 0
%21 = load i64, i64* %20
%22 = load i64, i64* @SIG_IGN
%23 = icmp eq i64 %21, %22
br i1 %23, label %24, label %31
24: ; preds = %19
%25 = load i64, i64* @SIG_DFL
store i64 %25, i64* %20
%26 = load i32, i32* @SIGABRT
%27 = call i32 @sigaction(i32 %26, %struct.sigaction* %2, %struct.sigaction* null)
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %31
29: ; preds = %24
%30 = call i32 @pexit(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %31
31: ; preds = %24, %29, %19
%32 = load i64, i64* %20
%33 = load i64, i64* @SIG_DFL
%34 = icmp eq i64 %32, %33
br i1 %34, label %44, label %35
35: ; preds = %31
%36 = load i32, i32* @SIGABRT
%37 = call i32 @raise(i32 %36)
%38 = load i64, i64* @SIG_DFL
store i64 %38, i64* %20
%39 = load i32, i32* @SIGABRT
%40 = call i32 @sigaction(i32 %39, %struct.sigaction* %2, %struct.sigaction* null)
%41 = icmp eq i32 %40, -1
br i1 %41, label %42, label %44
42: ; preds = %35
%43 = call i32 @pexit(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %44
44: ; preds = %35, %42, %31
%45 = load i32, i32* @stdout
%46 = call i64 @fflush(i32 %45)
%47 = load i64, i64* @EOF
%48 = icmp eq i64 %46, %47
br i1 %48, label %49, label %51
49: ; preds = %44
%50 = call i32 @pexit(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %51
51: ; preds = %49, %44
%52 = load i32, i32* @stderr
%53 = call i64 @fflush(i32 %52)
%54 = load i64, i64* @EOF
%55 = icmp eq i64 %53, %54
br i1 %55, label %56, label %58
56: ; preds = %51
%57 = call i32 @pexit(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %58
58: ; preds = %56, %51
%59 = load i32, i32* @STDOUT_FILENO
%60 = call i32 @close(i32 %59)
%61 = icmp eq i32 %60, -1
br i1 %61, label %62, label %64
62: ; preds = %58
%63 = call i32 @pexit(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %64
64: ; preds = %62, %58
%65 = load i32, i32* @STDERR_FILENO
%66 = call i32 @close(i32 %65)
%67 = icmp eq i32 %66, -1
br i1 %67, label %68, label %70
68: ; preds = %64
%69 = call i32 @pexit(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %70
70: ; preds = %68, %64
%71 = load i32, i32* @SIGABRT
%72 = call i32 @raise(i32 %71)
ret void
}