#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 sa_flags;
  int /*<<< orphan*/ sa_mask;
};
typedef int /*<<< orphan*/ sigset_t;

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


x86 assembly (clang, -O0):
<register_signal_f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
lea    -0x18(%rbp),%rdi
call   1040 <sigfillset@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%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_f>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %edx,%ebp
mov    %rsi,%rbx
mov    %edi,%r14d
lea    0xc(%rsp),%rdi
call   1040 <sigfillset@plt>
mov    %rbx,0x10(%rsp)
mov    0xc(%rsp),%eax
mov    %eax,0x1c(%rsp)
mov    %ebp,0x18(%rsp)
lea    0x10(%rsp),%rsi
mov    %r14d,%edi
xor    %edx,%edx
call   1030 <sigaction@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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