#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 /*<<< 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) {
    sigprocmask(SIG_SETMASK, (sigset_t *)&env[0].__saved_mask, 0);
  }
  if (val == 0)
    val = 1;
  __longjmp(env[0].__jmpbuf, val);
}


x86 assembly (clang, -O0):
<__libc_longjmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
cmpq   $0x0,0x8(%rax)
je     1156 <__libc_longjmp+0x36>
mov    0x2ea3(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rsi
add    $0x4,%rsi
xor    %edx,%edx
call   1030 <sigprocmask@plt>
cmpl   $0x0,-0xc(%rbp)
jne    1167 <__libc_longjmp+0x47>
movl   $0x1,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%esi
call   1040 <__longjmp@plt>
add    $0x10,%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>
test   %ebp,%ebp
mov    $0x1,%esi
cmovne %ebp,%esi
mov    (%rbx),%edi
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 0)
br label %16
16: ; preds = %10, %2
%17 = load i32, i32* %4
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %16
store i32 1, i32* %4
br label %20
20: ; preds = %19, %16
%21 = load %struct.TYPE_3__*, %struct.TYPE_3__** %3
%22 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %21, i64 0
%23 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %22, i32 0, i32 0
%24 = load i32, i32* %23
%25 = load i32, i32* %4
%26 = call i32 @__longjmp(i32 %24, i32 %25)
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 0)
br label %10
10: ; preds = %6, %2
%11 = icmp eq i32 %1, 0
%12 = select i1 %11, i32 1, i32 %1
%13 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 0
%14 = load i32, i32* %13
%15 = tail call i32 @__longjmp(i32 %14, i32 %12)
ret void
}