#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*/ sigset_t;

/* Variables and functions */
int /*<<< orphan*/ SIGABRT;
int /*<<< orphan*/ SIG_UNBLOCK;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ getpid();
scalar_t__ kill(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sigaddset(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ sigemptyset(int /*<<< orphan*/ *);
int /*<<< orphan*/ sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/ *,
                               int /*<<< orphan*/);
void __attribute__((noreturn)) uml_abort(void) {
  sigset_t sig;
  fflush(NULL);
  if (!sigemptyset(&sig) && !sigaddset(&sig, SIGABRT))
    sigprocmask(SIG_UNBLOCK, &sig, 0);
  for (;;)
    if (kill(getpid(), SIGABRT) < 0)
      exit(127);
}


x86 assembly (clang, -O0):
<uml_abort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xor    %eax,%eax
mov    %eax,%edi
call   1070 <fflush@plt>
lea    -0x4(%rbp),%rdi
call   1050 <sigemptyset@plt>
cmp    $0x0,%eax
jne    11c2 <uml_abort+0x52>
mov    0x2e3e(%rip),%rax
mov    (%rax),%esi
lea    -0x4(%rbp),%rdi
call   1090 <sigaddset@plt>
cmp    $0x0,%eax
jne    11c2 <uml_abort+0x52>
mov    0x2e33(%rip),%rax
mov    (%rax),%edi
lea    -0x4(%rbp),%rsi
xor    %edx,%edx
call   1030 <sigprocmask@plt>
jmp    11c7 <uml_abort+0x57>
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,%edi
mov    0x2e01(%rip),%rax
mov    (%rax),%esi
call   1060 <kill@plt>
cmp    $0x0,%rax
jge    11f2 <uml_abort+0x82>
mov    $0x7f,%edi
call   1080 <exit@plt>
jmp    11c7 <uml_abort+0x57>

x86 assembly (clang, -O2):
<uml_abort>:
push   %rbx
sub    $0x10,%rsp
xor    %edi,%edi
call   1070 <fflush@plt>
lea    0xc(%rsp),%rdi
call   1050 <sigemptyset@plt>
test   %eax,%eax
jne    11b6 <uml_abort+0x46>
mov    0x2e47(%rip),%rax
mov    (%rax),%esi
lea    0xc(%rsp),%rdi
call   1090 <sigaddset@plt>
test   %eax,%eax
jne    11b6 <uml_abort+0x46>
mov    0x2e40(%rip),%rax
mov    (%rax),%edi
lea    0xc(%rsp),%rsi
xor    %edx,%edx
call   1030 <sigprocmask@plt>
mov    0x2e1b(%rip),%rbx
nopl   (%rax)
xor    %eax,%eax
call   1040 <getpid@plt>
mov    (%rbx),%esi
mov    %eax,%edi
call   1060 <kill@plt>
test   %rax,%rax
jns    11c0 <uml_abort+0x50>
mov    $0x7f,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@SIGABRT = global i32 0
@SIG_UNBLOCK = global i32 0
define void @uml_abort() {
%1 = alloca i32
%2 = call i32 @fflush(i32* null)
%3 = call i32 @sigemptyset(i32* %1)
%4 = icmp ne i32 %3, 0
br i1 %4, label %12, label %5
5: ; preds = %0
%6 = load i32, i32* @SIGABRT
%7 = call i32 @sigaddset(i32* %1, i32 %6)
%8 = icmp ne i32 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %5
%10 = load i32, i32* @SIG_UNBLOCK
%11 = call i32 @sigprocmask(i32 %10, i32* %1, i32 0)
br label %12
12: ; preds = %9, %5, %0
br label %13
13: ; preds = %20, %12
%14 = call i32 (...) @getpid()
%15 = load i32, i32* @SIGABRT
%16 = call i64 @kill(i32 %14, i32 %15)
%17 = icmp slt i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = call i32 @exit(i32 127)
unreachable
20: ; preds = %13
br label %13
}

LLVM IR (-O2):
@SIGABRT = global i32 0
@SIG_UNBLOCK = global i32 0
define void @uml_abort() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @fflush(i32* null)
%4 = call i32 @sigemptyset(i32* %1)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %13
6: ; preds = %0
%7 = load i32, i32* @SIGABRT
%8 = call i32 @sigaddset(i32* %1, i32 %7)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %6
%11 = load i32, i32* @SIG_UNBLOCK
%12 = call i32 @sigprocmask(i32 %11, i32* %1, i32 0)
br label %13
13: ; preds = %10, %6, %0
br label %14
14: ; preds = %13, %14
%15 = call i32 (...) @getpid()
%16 = load i32, i32* @SIGABRT
%17 = call i64 @kill(i32 %15, i32 %16)
%18 = icmp slt i64 %17, 0
br i1 %18, label %19, label %14
19: ; preds = %14
%20 = call i32 @exit(i32 127)
unreachable
}