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

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


x86 assembly (clang, -O0):
<__libc_longjmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
cmpq   $0x0,0x8(%rax)
je     1158 <__libc_longjmp+0x38>
mov    0x2ea3(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rsi
add    $0x4,%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigprocmask@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
je     117b <__libc_longjmp+0x5b>
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    1188 <__libc_longjmp+0x68>
mov    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1188 <__libc_longjmp+0x68>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1040 <__longjmp@plt>
add    $0x20,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i32, i64 }
@SIG_SETMASK = global i32 0
define void @__libc_longjmp(%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 i32, i32* %19
%21 = load i32, i32* %4
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %16
br label %25
24: ; preds = %16
br label %25
25: ; preds = %24, %23
%26 = phi i32 [ %21, %23 ], [ 1, %24 ]
%27 = call i32 @__longjmp(i32 %20, i32 %26)
ret void
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i32, i64 }
@SIG_SETMASK = global i32 0
define void @__libc_longjmp(%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 i32, i32* %11
%13 = icmp eq i32 %1, 0
%14 = select i1 %13, i32 1, i32 %1
%15 = tail call i32 @__longjmp(i32 %12, i32 %14)
ret void
}