#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_mask;
};
typedef int /*<<< orphan*/ act;

/* Variables and functions */
int /*<<< orphan*/ e_f(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ memset(struct sigaction *, int /*<<< orphan*/, int);
scalar_t__ sigaction(int, struct sigaction *, int /*<<< orphan*/ *);
int /*<<< orphan*/ sigfillset(int /*<<< orphan*/ *);
void set_handler(int sig, void (*proc)(int), int block) {
  struct sigaction act;
  memset(&act, 0, sizeof(act));
  if (block)
    sigfillset(&act.sa_mask);
  act.sa_handler = proc;
  if (sigaction(sig, &act, NULL) != 0)
    e_f("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
        "2022-01-22/02-19-57/repos/ayyucedemirbas/Minix-Source-Code/refs/heads/"
        "master/minix-master/minix/tests/test79.c",
        174, (0));
}


x86 assembly (clang, -O0):
<set_handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
lea    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <memset@plt>
cmpl   $0x0,-0x14(%rbp)
je     1179 <set_handler+0x39>
lea    -0x28(%rbp),%rdi
add    $0x8,%rdi
call   1050 <sigfillset@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x28(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigaction@plt>
cmp    $0x0,%rax
je     11ae <set_handler+0x6e>
lea    0xe5e(%rip),%rdi
mov    $0xae,%esi
xor    %edx,%edx
call   1060 <e_f@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_handler>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edx,%ebp
mov    %rsi,%rbx
mov    %edi,%r14d
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <memset@plt>
test   %ebp,%ebp
je     116d <set_handler+0x2d>
lea    0x8(%rsp),%rdi
call   1050 <sigfillset@plt>
mov    %rbx,(%rsp)
mov    %rsp,%rsi
mov    %r14d,%edi
xor    %edx,%edx
call   1030 <sigaction@plt>
test   %rax,%rax
je     1196 <set_handler+0x56>
lea    0xe76(%rip),%rdi
mov    $0xae,%esi
xor    %edx,%edx
call   1060 <e_f@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.sigaction = type { void (i32)*, i32 }
@.str = [175 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ayyucedemirbas/Minix-Source-Code/refs/heads/master/minix-master/minix/tests/test79.c\00"
define void @set_handler(i32 %0, void (i32)* %1, i32 %2) {
%4 = alloca i32
%5 = alloca void (i32)*
%6 = alloca i32
%7 = alloca %struct.sigaction
store i32 %0, i32* %4
store void (i32)* %1, void (i32)** %5
store i32 %2, i32* %6
%8 = call i32 @memset(%struct.sigaction* %7, i32 0, i32 16)
%9 = load i32, i32* %6
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %3
%12 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %7, i32 0, i32 1
%13 = call i32 @sigfillset(i32* %12)
br label %14
14: ; preds = %11, %3
%15 = load void (i32)*, void (i32)** %5
%16 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %7, i32 0, i32 0
store void (i32)* %15, void (i32)** %16
%17 = load i32, i32* %4
%18 = call i64 @sigaction(i32 %17, %struct.sigaction* %7, i32* null)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %14
%21 = call i32 @e_f(i8* getelementptr inbounds ([175 x i8], [175 x i8]* @.str, i64 0, i64 0), i32 174, i32 0)
br label %22
22: ; preds = %20, %14
ret void
}

LLVM IR (-O2):
%struct.sigaction = type { void (i32)*, i32 }
@.str = [175 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ayyucedemirbas/Minix-Source-Code/refs/heads/master/minix-master/minix/tests/test79.c\00"
define void @set_handler(i32 %0, void (i32)* %1, i32 %2) {
%4 = alloca %struct.sigaction
%5 = bitcast %struct.sigaction* %4 to i8*
%6 = call i32 @memset(%struct.sigaction* %4, i32 0, i32 16)
%7 = icmp eq i32 %2, 0
br i1 %7, label %11, label %8
8: ; preds = %3
%9 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %4, i64 0, i32 1
%10 = call i32 @sigfillset(i32* %9)
br label %11
11: ; preds = %8, %3
%12 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %4, i64 0, i32 0
store void (i32)* %1, void (i32)** %12
%13 = call i64 @sigaction(i32 %0, %struct.sigaction* %4, i32* null)
%14 = icmp eq i64 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %11
%16 = call i32 @e_f(i8* getelementptr inbounds ([175 x i8], [175 x i8]* @.str, i64 0, i64 0), i32 174, i32 0)
br label %17
17: ; preds = %15, %11
ret void
}