#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 {
  void (*sa_handler)(int);
  int /*<<< orphan*/ sa_flags;
  int /*<<< orphan*/ sa_mask;
};
typedef int /*<<< orphan*/ sigset_t;

/* Variables and functions */
int /*<<< orphan*/ SA_RESTART;
int /*<<< orphan*/ sigaction(int, struct sigaction *, int /*<<< orphan*/ *);
int /*<<< orphan*/ sigfillset(int /*<<< orphan*/ *);
void register_signal(int signal, void (*handler)(int)) {
  sigset_t block_mask;
  struct sigaction saction;
  sigfillset(&block_mask);
  saction.sa_handler = handler;
  saction.sa_mask = block_mask;
  saction.sa_flags = SA_RESTART;
  sigaction(signal, &saction, NULL);
}


x86 assembly (clang, -O0):
<register_signal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x14(%rbp),%rdi
call   1040 <sigfillset@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2e9b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x28(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigaction@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<register_signal>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0x4(%rsp),%rdi
call   1040 <sigfillset@plt>
mov    %rbx,0x8(%rsp)
mov    0x4(%rsp),%eax
mov    %eax,0x14(%rsp)
mov    0x2e9f(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x10(%rsp)
lea    0x8(%rsp),%rsi
mov    %ebp,%edi
xor    %edx,%edx
call   1030 <sigaction@plt>
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.sigaction = type { void (i32)*, i32, i32 }
@SA_RESTART = global i32 0
define void @register_signal(i32 %0, void (i32)* %1) {
%3 = alloca i32
%4 = alloca void (i32)*
%5 = alloca i32
%6 = alloca %struct.sigaction
store i32 %0, i32* %3
store void (i32)* %1, void (i32)** %4
%7 = call i32 @sigfillset(i32* %5)
%8 = load void (i32)*, void (i32)** %4
%9 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %6, i32 0, i32 0
store void (i32)* %8, void (i32)** %9
%10 = load i32, i32* %5
%11 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %6, i32 0, i32 2
store i32 %10, i32* %11
%12 = load i32, i32* @SA_RESTART
%13 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %6, i32 0, i32 1
store i32 %12, i32* %13
%14 = load i32, i32* %3
%15 = call i32 @sigaction(i32 %14, %struct.sigaction* %6, i32* null)
ret void
}

LLVM IR (-O2):
%struct.sigaction = type { void (i32)*, i32, i32 }
@SA_RESTART = global i32 0
define void @register_signal(i32 %0, void (i32)* %1) {
%3 = alloca i32
%4 = alloca %struct.sigaction
%5 = bitcast i32* %3 to i8*
%6 = bitcast %struct.sigaction* %4 to i8*
%7 = call i32 @sigfillset(i32* %3)
%8 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %4, i64 0, i32 0
store void (i32)* %1, void (i32)** %8
%9 = load i32, i32* %3
%10 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %4, i64 0, i32 2
store i32 %9, i32* %10
%11 = load i32, i32* @SA_RESTART
%12 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %4, i64 0, i32 1
store i32 %11, i32* %12
%13 = call i32 @sigaction(i32 %0, %struct.sigaction* %4, i32* null)
ret void
}