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

/* Variables and functions */
int /*<<< orphan*/ SIGINT;
int /*<<< orphan*/ SIGQUIT;
int /*<<< orphan*/ SIGTERM;
scalar_t__ linux_sigaction(int /*<<< orphan*/, void (*)(int));
int /*<<< orphan*/ printf(char *);
int ofp_sigactions_set(void (*sig_func)(int)) {
  if (linux_sigaction(SIGINT, sig_func)) {
    printf("Error: ODP sighandler setup failed: SIGINT.\n");
    return -1;
  }
  if (linux_sigaction(SIGQUIT, sig_func)) {
    printf("Error: ODP sighandler setup failed: SIGQUIT.\n");
    return -1;
  }
  if (linux_sigaction(SIGTERM, sig_func)) {
    printf("Error: ODP sighandler setup failed: SIGQUIT.\n");
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<ofp_sigactions_set>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    0x2eb5(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rsi
call   1040 <linux_sigaction@plt>
cmp    $0x0,%rax
je     1160 <ofp_sigactions_set+0x40>
lea    0xeb1(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11cf <ofp_sigactions_set+0xaf>
mov    0x2e71(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rsi
call   1040 <linux_sigaction@plt>
cmp    $0x0,%rax
je     1194 <ofp_sigactions_set+0x74>
lea    0xeaa(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11cf <ofp_sigactions_set+0xaf>
mov    0x2e45(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rsi
call   1040 <linux_sigaction@plt>
cmp    $0x0,%rax
je     11c8 <ofp_sigactions_set+0xa8>
lea    0xe76(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11cf <ofp_sigactions_set+0xaf>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ofp_sigactions_set>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x2eba(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
call   1040 <linux_sigaction@plt>
test   %rax,%rax
je     1146 <ofp_sigactions_set+0x26>
lea    0xee9(%rip),%r14
jmp    1179 <ofp_sigactions_set+0x59>
mov    0x2e8b(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
call   1040 <linux_sigaction@plt>
lea    0xea2(%rip),%r14
test   %rax,%rax
jne    1179 <ofp_sigactions_set+0x59>
mov    0x2e76(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
call   1040 <linux_sigaction@plt>
test   %rax,%rax
je     118e <ofp_sigactions_set+0x6e>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
xor    %eax,%eax
jmp    1186 <ofp_sigactions_set+0x66>

LLVM IR (-O0):
@SIGINT = global i32 0
@.str = [45 x i8] c"Error: ODP sighandler setup failed: SIGINT.\0A\00"
@SIGQUIT = global i32 0
@.str.1 = [46 x i8] c"Error: ODP sighandler setup failed: SIGQUIT.\0A\00"
@SIGTERM = global i32 0
define i32 @ofp_sigactions_set(void (i32)* %0) {
%2 = alloca i32
%3 = alloca void (i32)*
store void (i32)* %0, void (i32)** %3
%4 = load i32, i32* @SIGINT
%5 = load void (i32)*, void (i32)** %3
%6 = call i64 @linux_sigaction(i32 %4, void (i32)* %5)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %2
br label %25
10: ; preds = %1
%11 = load i32, i32* @SIGQUIT
%12 = load void (i32)*, void (i32)** %3
%13 = call i64 @linux_sigaction(i32 %11, void (i32)* %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %10
%16 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %2
br label %25
17: ; preds = %10
%18 = load i32, i32* @SIGTERM
%19 = load void (i32)*, void (i32)** %3
%20 = call i64 @linux_sigaction(i32 %18, void (i32)* %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %17
%23 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %2
br label %25
24: ; preds = %17
store i32 0, i32* %2
br label %25
25: ; preds = %24, %22, %15, %8
%26 = load i32, i32* %2
ret i32 %26
}

LLVM IR (-O2):
@SIGINT = global i32 0
@SIGQUIT = global i32 0
@SIGTERM = global i32 0
@str.2 = [45 x i8] c"Error: ODP sighandler setup failed: SIGQUIT.\00"
@str.3 = [44 x i8] c"Error: ODP sighandler setup failed: SIGINT.\00"
define i32 @ofp_sigactions_set(void (i32)* %0) {
%2 = load i32, i32* @SIGINT
%3 = tail call i64 @linux_sigaction(i32 %2, void (i32)* %0)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %13
5: ; preds = %1
%6 = load i32, i32* @SIGQUIT
%7 = tail call i64 @linux_sigaction(i32 %6, void (i32)* %0)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %5
%10 = load i32, i32* @SIGTERM
%11 = tail call i64 @linux_sigaction(i32 %10, void (i32)* %0)
%12 = icmp eq i64 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %9, %5, %1
%14 = phi i8* [ getelementptr inbounds ([44 x i8], [44 x i8]* @str.3, i64 0, i64 0), %1 ], [ getelementptr inbounds ([45 x i8], [45 x i8]* @str.2, i64 0, i64 0), %5 ], [ getelementptr inbounds ([45 x i8], [45 x i8]* @str.2, i64 0, i64 0), %9 ]
%15 = tail call i32 @puts(i8* dereferenceable(1) %14)
br label %16
16: ; preds = %13, %9
%17 = phi i32 [ 0, %9 ], [ -1, %13 ]
ret i32 %17
}