#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 */
int /*<<< orphan*/ SIGABRT;
scalar_t__ SIG_DFL;
scalar_t__ SIG_IGN;
int /*<<< orphan*/ SIG_SETMASK;
int /*<<< orphan*/ _exit(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ sigaction(int /*<<< orphan*/, struct sigaction *,
                             struct sigaction *);
int /*<<< orphan*/ sigdelset(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ sigfillset(int /*<<< orphan*/ *);
int /*<<< orphan*/ sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/ *,
                               int /*<<< orphan*/ *);
void abort_exit(void) {
  sigset_t mask;
  struct sigaction action;
  sigaction(SIGABRT, NULL, &action);
  if (action.sa_handler == SIG_IGN) {
    action.sa_handler = SIG_DFL;
    sigaction(SIGABRT, &action, NULL);
  }
  if (action.sa_handler == SIG_DFL) {
    fflush(NULL);
  }
  sigfillset(&mask);
  sigdelset(&mask, SIGABRT);
  sigprocmask(SIG_SETMASK, &mask, NULL);
  fflush(NULL);
  _exit(1);
}


x86 assembly (clang, -O0):
<abort_exit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
lea    -0x10(%rbp),%rdx
call   1050 <sigaction@plt>
mov    -0x10(%rbp),%rax
mov    0x2e57(%rip),%rcx
cmp    (%rcx),%rax
jne    11b6 <abort_exit+0x56>
mov    0x2e37(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x10(%rbp)
mov    0x2e21(%rip),%rax
mov    (%rax),%edi
lea    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <sigaction@plt>
mov    -0x10(%rbp),%rax
mov    0x2e0f(%rip),%rcx
cmp    (%rcx),%rax
jne    11d3 <abort_exit+0x73>
xor    %eax,%eax
mov    %eax,%edi
call   1070 <fflush@plt>
lea    -0x4(%rbp),%rdi
call   1060 <sigfillset@plt>
mov    0x2de5(%rip),%rax
mov    (%rax),%esi
lea    -0x4(%rbp),%rdi
call   1080 <sigdelset@plt>
mov    0x2df3(%rip),%rax
mov    (%rax),%edi
lea    -0x4(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigprocmask@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1070 <fflush@plt>
mov    $0x1,%edi
call   1040 <_exit@plt>

x86 assembly (clang, -O2):
<abort_exit>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    0x2e5a(%rip),%r14
mov    (%r14),%edi
lea    0x8(%rsp),%rdx
xor    %esi,%esi
call   1050 <sigaction@plt>
mov    0x8(%rsp),%rax
mov    0x2e57(%rip),%rcx
cmp    (%rcx),%rax
jne    11b1 <abort_exit+0x51>
mov    0x2e3b(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x8(%rsp)
mov    (%r14),%edi
lea    0x8(%rsp),%rsi
xor    %edx,%edx
call   1050 <sigaction@plt>
mov    0x8(%rsp),%rax
mov    0x2e18(%rip),%rcx
cmp    (%rcx),%rax
jne    11c4 <abort_exit+0x64>
xor    %edi,%edi
call   1070 <fflush@plt>
lea    0x14(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <sigfillset@plt>
mov    (%r14),%esi
mov    %rbx,%rdi
call   1080 <sigdelset@plt>
mov    0x2e05(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
xor    %edx,%edx
call   1030 <sigprocmask@plt>
xor    %edi,%edi
call   1070 <fflush@plt>
mov    $0x1,%edi
call   1040 <_exit@plt>

LLVM IR (-O0):
%struct.sigaction = type { i64 }
@SIGABRT = global i32 0
@SIG_IGN = global i64 0
@SIG_DFL = global i64 0
@SIG_SETMASK = global i32 0
define void @abort_exit() {
%1 = alloca i32
%2 = alloca %struct.sigaction
%3 = load i32, i32* @SIGABRT
%4 = call i32 @sigaction(i32 %3, %struct.sigaction* null, %struct.sigaction* %2)
%5 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %2, i32 0, i32 0
%6 = load i64, i64* %5
%7 = load i64, i64* @SIG_IGN
%8 = icmp eq i64 %6, %7
br i1 %8, label %9, label %14
9: ; preds = %0
%10 = load i64, i64* @SIG_DFL
%11 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %2, i32 0, i32 0
store i64 %10, i64* %11
%12 = load i32, i32* @SIGABRT
%13 = call i32 @sigaction(i32 %12, %struct.sigaction* %2, %struct.sigaction* null)
br label %14
14: ; preds = %9, %0
%15 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %2, i32 0, i32 0
%16 = load i64, i64* %15
%17 = load i64, i64* @SIG_DFL
%18 = icmp eq i64 %16, %17
br i1 %18, label %19, label %21
19: ; preds = %14
%20 = call i32 @fflush(i32* null)
br label %21
21: ; preds = %19, %14
%22 = call i32 @sigfillset(i32* %1)
%23 = load i32, i32* @SIGABRT
%24 = call i32 @sigdelset(i32* %1, i32 %23)
%25 = load i32, i32* @SIG_SETMASK
%26 = call i32 @sigprocmask(i32 %25, i32* %1, i32* null)
%27 = call i32 @fflush(i32* null)
%28 = call i32 @_exit(i32 1)
unreachable
}

LLVM IR (-O2):
%struct.sigaction = type { i64 }
@SIGABRT = global i32 0
@SIG_IGN = global i64 0
@SIG_DFL = global i64 0
@SIG_SETMASK = global i32 0
define void @abort_exit() {
%1 = alloca i32
%2 = alloca %struct.sigaction
%3 = bitcast i32* %1 to i8*
%4 = bitcast %struct.sigaction* %2 to i8*
%5 = load i32, i32* @SIGABRT
%6 = call i32 @sigaction(i32 %5, %struct.sigaction* null, %struct.sigaction* %2)
%7 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %2, i64 0, i32 0
%8 = load i64, i64* %7
%9 = load i64, i64* @SIG_IGN
%10 = icmp eq i64 %8, %9
br i1 %10, label %11, label %16
11: ; preds = %0
%12 = load i64, i64* @SIG_DFL
store i64 %12, i64* %7
%13 = load i32, i32* @SIGABRT
%14 = call i32 @sigaction(i32 %13, %struct.sigaction* %2, %struct.sigaction* null)
%15 = load i64, i64* %7
br label %16
16: ; preds = %11, %0
%17 = phi i64 [ %15, %11 ], [ %8, %0 ]
%18 = load i64, i64* @SIG_DFL
%19 = icmp eq i64 %17, %18
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = call i32 @fflush(i32* null)
br label %22
22: ; preds = %20, %16
%23 = call i32 @sigfillset(i32* %1)
%24 = load i32, i32* @SIGABRT
%25 = call i32 @sigdelset(i32* %1, i32 %24)
%26 = load i32, i32* @SIG_SETMASK
%27 = call i32 @sigprocmask(i32 %26, i32* %1, i32* null)
%28 = call i32 @fflush(i32* null)
%29 = call i32 @_exit(i32 1)
unreachable
}