#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_4__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ sigset_t;
typedef TYPE_1__ *sigjmp_buf;
struct TYPE_4__ {
  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*/ _longjmp_unwind(TYPE_1__ *, int);
int /*<<< orphan*/ sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/ *,
                               int /*<<< orphan*/ *);
void __libc_siglongjmp(sigjmp_buf env, int val) {
  _longjmp_unwind(env, 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),%rdi
mov    -0xc(%rbp),%esi
call   1040 <_longjmp_unwind@plt>
mov    -0x8(%rbp),%rax
cmpq   $0x0,0x10(%rax)
je     1174 <__libc_siglongjmp+0x44>
mov    0x2e87(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rsi
add    $0x8,%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <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     1199 <__libc_siglongjmp+0x69>
mov    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    11a6 <__libc_siglongjmp+0x76>
mov    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a6 <__libc_siglongjmp+0x76>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1050 <__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
call   1040 <_longjmp_unwind@plt>
cmpq   $0x0,0x10(%rbx)
je     1158 <__libc_siglongjmp+0x28>
mov    0x2e9d(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rbx),%rsi
xor    %edx,%edx
call   1030 <sigprocmask@plt>
mov    (%rbx),%rdi
test   %ebp,%ebp
mov    $0x1,%esi
cmovne %ebp,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <__longjmp@plt>

LLVM IR (-O0):
%struct.TYPE_4__ = type { i64, i32, i64 }
@SIG_SETMASK = global i32 0
define void @__libc_siglongjmp(%struct.TYPE_4__* %0, i32 %1) {
%3 = alloca %struct.TYPE_4__*
%4 = alloca i32
store %struct.TYPE_4__* %0, %struct.TYPE_4__** %3
store i32 %1, i32* %4
%5 = load %struct.TYPE_4__*, %struct.TYPE_4__** %3
%6 = load i32, i32* %4
%7 = call i32 @_longjmp_unwind(%struct.TYPE_4__* %5, i32 %6)
%8 = load %struct.TYPE_4__*, %struct.TYPE_4__** %3
%9 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %8, i64 0
%10 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %9, i32 0, i32 2
%11 = load i64, i64* %10
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %19
13: ; preds = %2
%14 = load i32, i32* @SIG_SETMASK
%15 = load %struct.TYPE_4__*, %struct.TYPE_4__** %3
%16 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %15, i64 0
%17 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %16, i32 0, i32 1
%18 = call i32 @sigprocmask(i32 %14, i32* %17, i32* null)
br label %19
19: ; preds = %13, %2
%20 = load %struct.TYPE_4__*, %struct.TYPE_4__** %3
%21 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %20, i64 0
%22 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %21, i32 0, i32 0
%23 = load i64, i64* %22
%24 = inttoptr i64 %23 to i8*
%25 = load i32, i32* %4
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %19
br label %29
28: ; preds = %19
br label %29
29: ; preds = %28, %27
%30 = phi i32 [ %25, %27 ], [ 1, %28 ]
%31 = call i32 @__longjmp(i8* %24, i32 %30)
ret void
}

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