#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 */

/* Type definitions */
typedef int /*<<< orphan*/ jmp_buf;

/* Variables and functions */
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ longjmp(int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
scalar_t__ setjmp(int /*<<< orphan*/);
int main() {
  static jmp_buf stack[20];
  static int stackp = 0;
  ;
  if (setjmp(stack[stackp++]) == 0) {
    goto x1;
  };
  if (setjmp(stack[stackp++]) == 0) {
    goto x1;
  };
  exit(0);
x1:
  printf("here\n");
  if (setjmp(stack[stackp++]) == 0) {
    goto x2;
  };
  printf("back\n");
  longjmp(stack[--stackp], 47);
  ;
x2:
  printf("there\n");
  longjmp(stack[--stackp], 47);
  ;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2f4b(%rip),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,0x2f40(%rip)
movslq %eax,%rcx
lea    0x2ee6(%rip),%rax
mov    (%rax,%rcx,4),%edi
call   1040 <setjmp@plt>
cmp    $0x0,%rax
jne    1181 <main+0x41>
jmp    11ba <main+0x7a>
mov    0x2f19(%rip),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,0x2f0e(%rip)
movslq %eax,%rcx
lea    0x2eb4(%rip),%rax
mov    (%rax,%rcx,4),%edi
call   1040 <setjmp@plt>
cmp    $0x0,%rax
jne    11b3 <main+0x73>
jmp    11ba <main+0x7a>
xor    %edi,%edi
call   1060 <exit@plt>
lea    0xe46(%rip),%rdi
call   1030 <printf@plt>
mov    0x2ed4(%rip),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,0x2ec9(%rip)
movslq %eax,%rcx
lea    0x2e6f(%rip),%rax
mov    (%rax,%rcx,4),%edi
call   1040 <setjmp@plt>
cmp    $0x0,%rax
jne    11f8 <main+0xb8>
jmp    122a <main+0xea>
lea    0xe01(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e96(%rip),%eax
add    $0xffffffff,%eax
mov    %eax,0x2e8d(%rip)
movslq %eax,%rcx
lea    0x2e33(%rip),%rax
mov    (%rax,%rcx,4),%edi
mov    $0x2f,%esi
call   1050 <longjmp@plt>
lea    0xdd5(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e64(%rip),%eax
add    $0xffffffff,%eax
mov    %eax,0x2e5b(%rip)
movslq %eax,%rcx
lea    0x2e01(%rip),%rax
mov    (%rax,%rcx,4),%edi
mov    $0x2f,%esi
call   1050 <longjmp@plt>

x86 assembly (clang, -O2):
<main>:
push   %rax
addl   $0x1,0x2efc(%rip)
xor    %edi,%edi
call   1040 <setjmp@plt>
test   %rax,%rax
je     1167 <main+0x27>
addl   $0x1,0x2ee9(%rip)
xor    %edi,%edi
call   1040 <setjmp@plt>
test   %rax,%rax
jne    11ae <main+0x6e>
lea    0xe98(%rip),%rdi
call   1030 <puts@plt>
addl   $0x1,0x2eca(%rip)
xor    %edi,%edi
call   1040 <setjmp@plt>
test   %rax,%rax
jne    118f <main+0x4f>
lea    0xe78(%rip),%rdi
jmp    1196 <main+0x56>
lea    0xe6a(%rip),%rdi
call   1030 <puts@plt>
addl   $0xffffffff,0x2ea2(%rip)
xor    %edi,%edi
mov    $0x2f,%esi
call   1050 <longjmp@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@main.stack = internal global [20 x i32] zeroinitializer
@main.stackp = internal global i32 0
@.str = [6 x i8] c"here\0A\00"
@.str.1 = [6 x i8] c"back\0A\00"
@.str.2 = [7 x i8] c"there\0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = load i32, i32* @main.stackp
%3 = add nsw i32 %2, 1
store i32 %3, i32* @main.stackp
%4 = sext i32 %2 to i64
%5 = getelementptr inbounds [20 x i32], [20 x i32]* @main.stack, i64 0, i64 %4
%6 = load i32, i32* %5
%7 = call i64 @setjmp(i32 %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %0
br label %21
10: ; preds = %0
%11 = load i32, i32* @main.stackp
%12 = add nsw i32 %11, 1
store i32 %12, i32* @main.stackp
%13 = sext i32 %11 to i64
%14 = getelementptr inbounds [20 x i32], [20 x i32]* @main.stack, i64 0, i64 %13
%15 = load i32, i32* %14
%16 = call i64 @setjmp(i32 %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %10
br label %21
19: ; preds = %10
%20 = call i32 @exit(i32 0)
unreachable
21: ; preds = %18, %9
%22 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%23 = load i32, i32* @main.stackp
%24 = add nsw i32 %23, 1
store i32 %24, i32* @main.stackp
%25 = sext i32 %23 to i64
%26 = getelementptr inbounds [20 x i32], [20 x i32]* @main.stack, i64 0, i64 %25
%27 = load i32, i32* %26
%28 = call i64 @setjmp(i32 %27)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %21
br label %39
31: ; preds = %21
%32 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%33 = load i32, i32* @main.stackp
%34 = add nsw i32 %33, -1
store i32 %34, i32* @main.stackp
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [20 x i32], [20 x i32]* @main.stack, i64 0, i64 %35
%37 = load i32, i32* %36
%38 = call i32 @longjmp(i32 %37, i32 47)
unreachable
39: ; preds = %30
%40 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%41 = load i32, i32* @main.stackp
%42 = add nsw i32 %41, -1
store i32 %42, i32* @main.stackp
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [20 x i32], [20 x i32]* @main.stack, i64 0, i64 %43
%45 = load i32, i32* %44
%46 = call i32 @longjmp(i32 %45, i32 47)
unreachable
}

LLVM IR (-O2):
@main.stackp = internal unnamed_addr global i32 0
@str = [5 x i8] c"here\00"
@str.3 = [5 x i8] c"back\00"
@str.4 = [6 x i8] c"there\00"
define i32 @main() {
%1 = load i32, i32* @main.stackp
%2 = add nsw i32 %1, 1
store i32 %2, i32* @main.stackp
%3 = tail call i64 @setjmp(i32 0)
%4 = icmp eq i64 %3, 0
br i1 %4, label %12, label %5
5: ; preds = %0
%6 = load i32, i32* @main.stackp
%7 = add nsw i32 %6, 1
store i32 %7, i32* @main.stackp
%8 = tail call i64 @setjmp(i32 0)
%9 = icmp eq i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %5
%11 = tail call i32 @exit(i32 0)
unreachable
12: ; preds = %5, %0
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
%14 = load i32, i32* @main.stackp
%15 = add nsw i32 %14, 1
store i32 %15, i32* @main.stackp
%16 = tail call i64 @setjmp(i32 0)
%17 = icmp eq i64 %16, 0
br i1 %17, label %23, label %18
18: ; preds = %12
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.3, i64 0, i64 0))
%20 = load i32, i32* @main.stackp
%21 = add nsw i32 %20, -1
store i32 %21, i32* @main.stackp
%22 = tail call i32 @longjmp(i32 0, i32 47)
unreachable
23: ; preds = %12
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.4, i64 0, i64 0))
%25 = load i32, i32* @main.stackp
%26 = add nsw i32 %25, -1
store i32 %26, i32* @main.stackp
%27 = tail call i32 @longjmp(i32 0, i32 47)
unreachable
}