#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*/ SIG_BLOCK;
int /*<<< orphan*/ SIG_SETMASK;
int /*<<< orphan*/ __sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/ *,
                                 int /*<<< orphan*/ *);
int /*<<< orphan*/ sigfillset(int /*<<< orphan*/ *);
int syscall(int, ...);
int raise(int sig) {
  int pid, tid, ret;
  sigset_t set;
  sigfillset(&set);
  __sigprocmask(SIG_BLOCK, &set, &set);
  tid = syscall(224);
  pid = syscall(20);
  ret = syscall(270, pid, tid, sig);
  __sigprocmask(SIG_SETMASK, &set, 0);
  return ret;
}


x86 assembly (clang, -O0):
<raise>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x14(%rbp),%rdi
call   1040 <sigfillset@plt>
mov    0x2e8d(%rip),%rax
mov    (%rax),%edi
lea    -0x14(%rbp),%rdx
mov    %rdx,%rsi
call   1050 <__sigprocmask@plt>
mov    $0xe0,%edi
mov    $0x0,%al
call   1030 <syscall@plt>
mov    %eax,-0xc(%rbp)
mov    $0x14,%edi
mov    $0x0,%al
call   1030 <syscall@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x4(%rbp),%ecx
mov    $0x10e,%edi
mov    $0x0,%al
call   1030 <syscall@plt>
mov    %eax,-0x10(%rbp)
mov    0x2e52(%rip),%rax
mov    (%rax),%edi
lea    -0x14(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <__sigprocmask@plt>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<raise>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edi,%r14d
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <sigfillset@plt>
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
mov    %rbx,%rdx
call   1050 <__sigprocmask@plt>
mov    $0xe0,%edi
xor    %eax,%eax
call   1030 <syscall@plt>
mov    %eax,%ebp
mov    $0x14,%edi
xor    %eax,%eax
call   1030 <syscall@plt>
mov    $0x10e,%edi
mov    %eax,%esi
mov    %ebp,%edx
mov    %r14d,%ecx
xor    %eax,%eax
call   1030 <syscall@plt>
mov    %eax,%ebp
mov    0x2e56(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
xor    %edx,%edx
call   1050 <__sigprocmask@plt>
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@SIG_BLOCK = global i32 0
@SIG_SETMASK = global i32 0
define i32 @raise(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %2
%7 = call i32 @sigfillset(i32* %6)
%8 = load i32, i32* @SIG_BLOCK
%9 = call i32 @__sigprocmask(i32 %8, i32* %6, i32* %6)
%10 = call i32 (i32, ...) @syscall(i32 224)
store i32 %10, i32* %4
%11 = call i32 (i32, ...) @syscall(i32 20)
store i32 %11, i32* %3
%12 = load i32, i32* %3
%13 = load i32, i32* %4
%14 = load i32, i32* %2
%15 = call i32 (i32, ...) @syscall(i32 270, i32 %12, i32 %13, i32 %14)
store i32 %15, i32* %5
%16 = load i32, i32* @SIG_SETMASK
%17 = call i32 @__sigprocmask(i32 %16, i32* %6, i32* null)
%18 = load i32, i32* %5
ret i32 %18
}

LLVM IR (-O2):
@SIG_BLOCK = global i32 0
@SIG_SETMASK = global i32 0
define i32 @raise(i32 %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = call i32 @sigfillset(i32* %2)
%5 = load i32, i32* @SIG_BLOCK
%6 = call i32 @__sigprocmask(i32 %5, i32* %2, i32* %2)
%7 = call i32 (i32, ...) @syscall(i32 224)
%8 = call i32 (i32, ...) @syscall(i32 20)
%9 = call i32 (i32, ...) @syscall(i32 270, i32 %8, i32 %7, i32 %0)
%10 = load i32, i32* @SIG_SETMASK
%11 = call i32 @__sigprocmask(i32 %10, i32* %2, i32* null)
ret i32 %9
}