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

/* Variables and functions */
int /*<<< orphan*/ sigaddset(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ sigemptyset(int /*<<< orphan*/ *);
sigset_t sysapi_init_siglock(int *signal_list, int signal_list_len) {
  int i;
  sigset_t sigmask;
  sigemptyset(&sigmask);
  for (i = 0; i < signal_list_len; i++) {
    sigaddset(&sigmask, signal_list[i]);
  }
  return sigmask;
}


x86 assembly (clang, -O0):
<sysapi_init_siglock>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    -0x14(%rbp),%rdi
call   1030 <sigemptyset@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    116d <sysapi_init_siglock+0x4d>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    -0x14(%rbp),%rdi
call   1040 <sigaddset@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113f <sysapi_init_siglock+0x1f>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sysapi_init_siglock>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%r15
lea    0x4(%rsp),%rdi
call   1030 <sigemptyset@plt>
test   %ebp,%ebp
jle    1165 <sysapi_init_siglock+0x45>
mov    %ebp,%ebp
xor    %ebx,%ebx
lea    0x4(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r15,%rbx,4),%esi
mov    %r14,%rdi
call   1040 <sigaddset@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1150 <sysapi_init_siglock+0x30>
mov    0x4(%rsp),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @sysapi_init_siglock(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%7 = call i32 @sigemptyset(i32* %6)
store i32 0, i32* %5
br label %8
8: ; preds = %19, %2
%9 = load i32, i32* %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %22
12: ; preds = %8
%13 = load i32*, i32** %3
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i32, i32* %13, i64 %15
%17 = load i32, i32* %16
%18 = call i32 @sigaddset(i32* %6, i32 %17)
br label %19
19: ; preds = %12
%20 = load i32, i32* %5
%21 = add nsw i32 %20, 1
store i32 %21, i32* %5
br label %8
22: ; preds = %8
%23 = load i32, i32* %6
ret i32 %23
}

LLVM IR (-O2):
define i32 @sysapi_init_siglock(i32* nocapture %0, i32 %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = call i32 @sigemptyset(i32* %3)
%6 = icmp sgt i32 %1, 0
br i1 %6, label %7, label %16
7: ; preds = %2
%8 = zext i32 %1 to i64
br label %9
9: ; preds = %7, %9
%10 = phi i64 [ 0, %7 ], [ %14, %9 ]
%11 = getelementptr inbounds i32, i32* %0, i64 %10
%12 = load i32, i32* %11
%13 = call i32 @sigaddset(i32* %3, i32 %12)
%14 = add nuw nsw i64 %10, 1
%15 = icmp eq i64 %14, %8
br i1 %15, label %16, label %9
16: ; preds = %9, %2
%17 = load i32, i32* %3
ret i32 %17
}