#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_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ longjmp(int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
int setjmp(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  do {
    jmp_buf env;
    switch (setjmp(env)) {
    case 0: {
      printf("In TRY statement\n");
      longjmp(env, (3));
      printf("not reachable\n");
    } break;
    case (1): {
      printf("FOO exception caught\n");
    } break;
    case (2): {
      printf("BAR exception caught\n");
    } break;
    case (3): {
      printf("GOO exception caught\n");
    }
    }
  } while (0);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <setjmp@plt>
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x3,%eax
ja     11c8 <main+0x88>
mov    -0x20(%rbp),%rax
lea    0xe88(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe88(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
mov    $0x3,%esi
call   1050 <longjmp@plt>
lea    0xe81(%rip),%rdi
call   1030 <printf@plt>
jmp    11c8 <main+0x88>
lea    0xe86(%rip),%rdi
call   1030 <printf@plt>
jmp    11c8 <main+0x88>
lea    0xe8b(%rip),%rdi
call   1030 <printf@plt>
jmp    11cd <main+0x8d>
mov    0x2e0c(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rax
call   1040 <setjmp@plt>
cmp    $0x3,%eax
ja     118f <main+0x4f>
lea    0xee8(%rip),%rdi
mov    %eax,%eax
lea    0xea5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xee4(%rip),%rdi
call   1030 <puts@plt>
mov    $0x3,%esi
call   1050 <longjmp@plt>
lea    0xea4(%rip),%rdi
jmp    118a <main+0x4a>
lea    0xe86(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e4a(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"In TRY statement\0A\00"
@.str.1 = [22 x i8] c"FOO exception caught\0A\00"
@.str.2 = [22 x i8] c"BAR exception caught\0A\00"
@.str.3 = [22 x i8] c"GOO exception caught\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %7
7: ; preds = %2
%8 = load i32, i32* %6
%9 = call i32 @setjmp(i32 %8)
switch i32 %9, label %20 [
i32 0, label %10
i32 1, label %14
i32 2, label %16
i32 3, label %18
]
10: ; preds = %7
%11 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* %6
%13 = call i32 @longjmp(i32 %12, i32 3)
unreachable
14: ; preds = %7
%15 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %20
16: ; preds = %7
%17 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
br label %20
18: ; preds = %7
%19 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
br label %20
20: ; preds = %18, %7, %16, %14
br label %21
21: ; preds = %20
%22 = load i32, i32* @EXIT_SUCCESS
%23 = call i32 @exit(i32 %22)
unreachable
}

LLVM IR (-O2):
@EXIT_SUCCESS = global i32 0
@str = [21 x i8] c"GOO exception caught\00"
@str.4 = [21 x i8] c"BAR exception caught\00"
@str.5 = [21 x i8] c"FOO exception caught\00"
@str.6 = [17 x i8] c"In TRY statement\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = call i32 @setjmp(i32 undef)
switch i32 %3, label %12 [
i32 0, label %4
i32 1, label %9
i32 2, label %7
i32 3, label %8
]
4: ; preds = %2
%5 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.6, i64 0, i64 0))
%6 = call i32 @longjmp(i32 undef, i32 3)
unreachable
7: ; preds = %2
br label %9
8: ; preds = %2
br label %9
9: ; preds = %2, %7, %8
%10 = phi i8* [ getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0), %8 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @str.4, i64 0, i64 0), %7 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @str.5, i64 0, i64 0), %2 ]
%11 = call i32 @puts(i8* dereferenceable(1) %10)
br label %12
12: ; preds = %9, %2
%13 = load i32, i32* @EXIT_SUCCESS
%14 = call i32 @exit(i32 %13)
unreachable
}