#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__ {
  scalar_t__ __jmpbuf;
  int /*<<< orphan*/ __saved_mask;
  scalar_t__ __mask_was_saved;
};

/* Variables and functions */
int /*<<< orphan*/ SIG_SETMASK;
int /*<<< orphan*/ __longjmp(char *, int);
int /*<<< orphan*/ __sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/ *,
                                 int /*<<< orphan*/ *);
void __libc_siglongjmp(sigjmp_buf env, int val) {
  if (env[0].__mask_was_saved)
    (void)__sigprocmask(SIG_SETMASK, &env[0].__saved_mask, (sigset_t *)NULL);
  __longjmp((char *)env[0].__jmpbuf, val ?: 1);
}


x86 assembly (clang, -O0):
<__libc_siglongjmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
cmpq   $0x0,0x10(%rax)
je     1158 <__libc_siglongjmp+0x38>
mov    0x2ea3(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rsi
add    $0x8,%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1040 <__sigprocmask@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
je     117d <__libc_siglongjmp+0x5d>
mov    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    118a <__libc_siglongjmp+0x6a>
mov    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    118a <__libc_siglongjmp+0x6a>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1030 <__longjmp@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__libc_siglongjmp>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
cmpq   $0x0,0x10(%rdi)
je     1143 <__libc_siglongjmp+0x23>
mov    0x2eb2(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rbx),%rsi
xor    %edx,%edx
call   1040 <__sigprocmask@plt>
mov    (%rbx),%rdi
test   %ebp,%ebp
mov    $0x1,%esi
cmovne %ebp,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <__longjmp@plt>

LLVM IR (-O0):
%struct.TYPE_3__ = type { i64, i32, i64 }
@SIG_SETMASK = global i32 0
define void @__libc_siglongjmp(%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 %struct.TYPE_3__*, %struct.TYPE_3__** %3
%6 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %5, i64 0
%7 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %6, i32 0, i32 2
%8 = load i64, i64* %7
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = load i32, i32* @SIG_SETMASK
%12 = load %struct.TYPE_3__*, %struct.TYPE_3__** %3
%13 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %12, i64 0
%14 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %13, i32 0, i32 1
%15 = call i32 @__sigprocmask(i32 %11, i32* %14, i32* null)
br label %16
16: ; preds = %10, %2
%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
%20 = load i64, i64* %19
%21 = inttoptr i64 %20 to i8*
%22 = load i32, i32* %4
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %16
br label %26
25: ; preds = %16
br label %26
26: ; preds = %25, %24
%27 = phi i32 [ %22, %24 ], [ 1, %25 ]
%28 = call i32 @__longjmp(i8* %21, i32 %27)
ret void
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i64, i32, i64 }
@SIG_SETMASK = global i32 0
define void @__libc_siglongjmp(%struct.TYPE_3__* %0, i32 %1) {
%3 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 2
%4 = load i64, i64* %3
%5 = icmp eq i64 %4, 0
br i1 %5, label %10, label %6
6: ; preds = %2
%7 = load i32, i32* @SIG_SETMASK
%8 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 1
%9 = tail call i32 @__sigprocmask(i32 %7, i32* %8, i32* null)
br label %10
10: ; preds = %6, %2
%11 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 0
%12 = load i64, i64* %11
%13 = inttoptr i64 %12 to i8*
%14 = icmp eq i32 %1, 0
%15 = select i1 %14, i32 1, i32 %1
%16 = tail call i32 @__longjmp(i8* %13, i32 %15)
ret void
}