#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ sigset_t;
typedef TYPE_1__ *sigjmp_buf;
struct TYPE_3__ {
  int __mask_was_saved;
  int /*<<< orphan*/ __saved_mask;
};

/* Variables and functions */
int /*<<< orphan*/ SIG_BLOCK;
scalar_t__ sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/ *,
                       int /*<<< orphan*/ *);
int __sigjmp_save(sigjmp_buf env, int savemask) {
  env[0].__mask_was_saved =
      (savemask &&
       sigprocmask(SIG_BLOCK, (sigset_t *)NULL, &env[0].__saved_mask) == 0);
  return 0;
}


x86 assembly (clang, -O0):
<__sigjmp_save>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0xc(%rbp)
mov    %al,-0xd(%rbp)
je     1152 <__sigjmp_save+0x42>
mov    0x2eab(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
add    $0x4,%rdx
xor    %eax,%eax
mov    %eax,%esi
call   1030 <sigprocmask@plt>
cmp    $0x0,%rax
sete   %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
and    $0x1,%al
movzbl %al,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__sigjmp_save>:
push   %rbx
mov    %rdi,%rbx
test   %esi,%esi
je     1136 <__sigjmp_save+0x26>
mov    0x2ec1(%rip),%rax
mov    (%rax),%edi
lea    0x4(%rbx),%rdx
xor    %esi,%esi
call   1030 <sigprocmask@plt>
xor    %ecx,%ecx
test   %rax,%rax
sete   %cl
jmp    1138 <__sigjmp_save+0x28>
xor    %ecx,%ecx
mov    %ecx,(%rbx)
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i32 }
@SIG_BLOCK = global i32 0
define i32 @__sigjmp_save(%struct.TYPE_3__* %0, i32 %1) {
%3 = alloca %struct.TYPE_3__*
%4 = alloca i32
store %struct.TYPE_3__* %0, %struct.TYPE_3__** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %14
7: ; preds = %2
%8 = load i32, i32* @SIG_BLOCK
%9 = load %struct.TYPE_3__*, %struct.TYPE_3__** %3
%10 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %9, i64 0
%11 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %10, i32 0, i32 1
%12 = call i64 @sigprocmask(i32 %8, i32* null, i32* %11)
%13 = icmp eq i64 %12, 0
br label %14
14: ; preds = %7, %2
%15 = phi i1 [ false, %2 ], [ %13, %7 ]
%16 = zext i1 %15 to i32
%17 = load %struct.TYPE_3__*, %struct.TYPE_3__** %3
%18 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %17, i64 0
%19 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %18, i32 0, i32 0
store i32 %16, i32* %19
ret i32 0
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i32 }
@SIG_BLOCK = global i32 0
define i32 @__sigjmp_save(%struct.TYPE_3__* %0, i32 %1) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %10, label %4
4: ; preds = %2
%5 = load i32, i32* @SIG_BLOCK
%6 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 1
%7 = tail call i64 @sigprocmask(i32 %5, i32* null, i32* %6)
%8 = icmp eq i64 %7, 0
%9 = zext i1 %8 to i32
br label %10
10: ; preds = %4, %2
%11 = phi i32 [ 0, %2 ], [ %9, %4 ]
%12 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 0
store i32 %11, i32* %12
ret i32 0
}