#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*/ SIG_BLOCK;
int /*<<< orphan*/ print_sigset(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char const *);
int sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int print_sigmask(const char *msg) {
  sigset_t curr_mask;
  if (msg != NULL) {
    printf("%s", msg);
  }
  if (sigprocmask(SIG_BLOCK, NULL, &curr_mask) == -1) {
    return -1;
  }
  print_sigset("\t\t", &curr_mask);
  return 0;
}


x86 assembly (clang, -O0):
<print_sigmask>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1157 <print_sigmask+0x27>
mov    -0x10(%rbp),%rsi
lea    0xeae(%rip),%rdi
call   1050 <printf@plt>
mov    0x2e82(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
lea    -0x14(%rbp),%rdx
call   1030 <sigprocmask@plt>
cmp    $0xffffffff,%eax
jne    1182 <print_sigmask+0x52>
movl   $0xffffffff,-0x4(%rbp)
jmp    1199 <print_sigmask+0x69>
lea    0xe7a(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <print_sigset@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_sigmask>:
push   %rbx
sub    $0x10,%rsp
test   %rdi,%rdi
je     1149 <print_sigmask+0x19>
mov    %rdi,%rsi
lea    0xebc(%rip),%rdi
call   1050 <printf@plt>
mov    0x2e90(%rip),%rax
mov    (%rax),%edi
xor    %ebx,%ebx
lea    0xc(%rsp),%rdx
xor    %esi,%esi
call   1030 <sigprocmask@plt>
cmp    $0xffffffff,%eax
je     1178 <print_sigmask+0x48>
lea    0xe97(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <print_sigset@plt>
jmp    117d <print_sigmask+0x4d>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@SIG_BLOCK = global i32 0
@.str.1 = [3 x i8] c"\09\09\00"
define i32 @print_sigmask(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %8)
br label %10
10: ; preds = %7, %1
%11 = load i32, i32* @SIG_BLOCK
%12 = call i32 @sigprocmask(i32 %11, i32* null, i32* %4)
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %15
14: ; preds = %10
store i32 -1, i32* %2
br label %17
15: ; preds = %10
%16 = call i32 @print_sigset(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
store i32 0, i32* %2
br label %17
17: ; preds = %15, %14
%18 = load i32, i32* %2
ret i32 %18
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@SIG_BLOCK = global i32 0
@.str.1 = [3 x i8] c"\09\09\00"
define i32 @print_sigmask(i8* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = icmp eq i8* %0, null
br i1 %4, label %7, label %5
5: ; preds = %1
%6 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %7
7: ; preds = %5, %1
%8 = load i32, i32* @SIG_BLOCK
%9 = call i32 @sigprocmask(i32 %8, i32* null, i32* %2)
%10 = icmp eq i32 %9, -1
br i1 %10, label %13, label %11
11: ; preds = %7
%12 = call i32 @print_sigset(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %13
13: ; preds = %7, %11
%14 = phi i32 [ 0, %11 ], [ -1, %7 ]
ret i32 %14
}