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

/* Variables and functions */
int SIGALRM;
void SIG_ERR(int);
int sigaction(int, struct sigaction *, struct sigaction *);
int /*<<< orphan*/ sigemptyset(int /*<<< orphan*/ *);
void (*Signal(int signo, void (*func)(int)))(int) {
  struct sigaction act, oact;
  act.sa_handler = func;
  sigemptyset(&act.sa_mask);
  act.sa_flags = 0;
  if (signo == SIGALRM) {
  } else {
  }
  if (sigaction(signo, &act, &oact) == -1)
    return SIG_ERR;
  return (oact.sa_handler);
}


x86 assembly (clang, -O0):
<Signal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
lea    -0x30(%rbp),%rdi
add    $0x10,%rdi
call   1040 <sigemptyset@plt>
movq   $0x0,-0x28(%rbp)
mov    -0xc(%rbp),%eax
mov    0x2e92(%rip),%rcx
cmp    (%rcx),%eax
jne    1163 <Signal+0x43>
jmp    1168 <Signal+0x48>
jmp    1168 <Signal+0x48>
mov    -0xc(%rbp),%edi
lea    -0x30(%rbp),%rsi
lea    -0x48(%rbp),%rdx
call   1030 <sigaction@plt>
cmp    $0xffffffff,%eax
jne    1191 <Signal+0x71>
mov    0x2e50(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1199 <Signal+0x79>
mov    -0x48(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Signal>:
push   %rbx
sub    $0x30,%rsp
mov    %edi,%ebx
mov    %rsi,(%rsp)
lea    0x10(%rsp),%rdi
call   1040 <sigemptyset@plt>
movq   $0x0,0x8(%rsp)
mov    %rsp,%rsi
lea    0x18(%rsp),%rdx
mov    %ebx,%edi
call   1030 <sigaction@plt>
cmp    $0xffffffff,%eax
jne    115b <Signal+0x3b>
mov    0x2e87(%rip),%rax
jmp    1160 <Signal+0x40>
mov    0x18(%rsp),%rax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.sigaction = type { void (i32)*, i64, i32 }
@SIGALRM = global i32 0
define void (i32)* @Signal(i32 %0, void (i32)* %1) {
%3 = alloca void (i32)*
%4 = alloca i32
%5 = alloca void (i32)*
%6 = alloca %struct.sigaction
%7 = alloca %struct.sigaction
store i32 %0, i32* %4
store void (i32)* %1, void (i32)** %5
%8 = load void (i32)*, void (i32)** %5
%9 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %6, i32 0, i32 0
store void (i32)* %8, void (i32)** %9
%10 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %6, i32 0, i32 2
%11 = call i32 @sigemptyset(i32* %10)
%12 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %6, i32 0, i32 1
store i64 0, i64* %12
%13 = load i32, i32* %4
%14 = load i32, i32* @SIGALRM
%15 = icmp eq i32 %13, %14
br i1 %15, label %16, label %17
16: ; preds = %2
br label %18
17: ; preds = %2
br label %18
18: ; preds = %17, %16
%19 = load i32, i32* %4
%20 = call i32 @sigaction(i32 %19, %struct.sigaction* %6, %struct.sigaction* %7)
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %23
22: ; preds = %18
store void (i32)* @SIG_ERR, void (i32)** %3
br label %26
23: ; preds = %18
%24 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %7, i32 0, i32 0
%25 = load void (i32)*, void (i32)** %24
store void (i32)* %25, void (i32)** %3
br label %26
26: ; preds = %23, %22
%27 = load void (i32)*, void (i32)** %3
ret void (i32)* %27
}

LLVM IR (-O2):
%struct.sigaction = type { void (i32)*, i64, i32 }
@SIGALRM = global i32 0
define void (i32)* @Signal(i32 %0, void (i32)* %1) {
%3 = alloca %struct.sigaction
%4 = alloca %struct.sigaction
%5 = bitcast %struct.sigaction* %3 to i8*
%6 = bitcast %struct.sigaction* %4 to i8*
%7 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %3, i64 0, i32 0
store void (i32)* %1, void (i32)** %7
%8 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %3, i64 0, i32 2
%9 = call i32 @sigemptyset(i32* %8)
%10 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %3, i64 0, i32 1
store i64 0, i64* %10
%11 = call i32 @sigaction(i32 %0, %struct.sigaction* %3, %struct.sigaction* %4)
%12 = icmp eq i32 %11, -1
%13 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %4, i64 0, i32 0
%14 = load void (i32)*, void (i32)** %13
%15 = select i1 %12, void (i32)* @SIG_ERR, void (i32)* %14
ret void (i32)* %15
}