#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*/ longjmp(int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
int setjmp(int /*<<< orphan*/);
int main(int argc, char **argv) {
  jmp_buf ex_buf__;
  switch (setjmp(ex_buf__)) {
  case 0: {
    printf("In Try Statement\n");
    longjmp(ex_buf__, 2);
    printf("I do not appear\n");
  } break;
  case 1: {
    printf("Got Foo!\n");
  }
  case 2: {
    printf("Got Bar!\n");
    longjmp(ex_buf__, 1);
    printf("I do not appear 2\n");
  } break;
  case 3: {
    printf("Got Baz!\n");
  } break;
  }
  return 0;
}


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     11bb <main+0x8b>
mov    -0x20(%rbp),%rax
lea    0xe98(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe98(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
mov    $0x2,%esi
call   1050 <longjmp@plt>
lea    0xe91(%rip),%rdi
call   1030 <printf@plt>
lea    0xe8f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
mov    $0x1,%esi
call   1050 <longjmp@plt>
lea    0xe80(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
call   1040 <setjmp@plt>
cmp    $0x3,%eax
ja     1159 <main+0x29>
mov    %eax,%eax
lea    0xebc(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xebc(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret
lea    0xec7(%rip),%rdi
call   1030 <puts@plt>
mov    $0x2,%esi
call   1050 <longjmp@plt>
lea    0xea8(%rip),%rdi
call   1030 <puts@plt>
lea    0xe93(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%esi
call   1050 <longjmp@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"In Try Statement\0A\00"
@.str.1 = [10 x i8] c"Got Foo!\0A\00"
@.str.2 = [10 x i8] c"Got Bar!\0A\00"
@.str.3 = [10 x i8] c"Got Baz!\0A\00"
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
%7 = load i32, i32* %6
%8 = call i32 @setjmp(i32 %7)
switch i32 %8, label %21 [
i32 0, label %9
i32 1, label %13
i32 2, label %15
i32 3, label %19
]
9: ; preds = %2
%10 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* %6
%12 = call i32 @longjmp(i32 %11, i32 2)
unreachable
13: ; preds = %2
%14 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %15
15: ; preds = %2, %13
%16 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%17 = load i32, i32* %6
%18 = call i32 @longjmp(i32 %17, i32 1)
unreachable
19: ; preds = %2
%20 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %21
21: ; preds = %2, %19
ret i32 0
}

LLVM IR (-O2):
@str = [9 x i8] c"Got Baz!\00"
@str.4 = [9 x i8] c"Got Bar!\00"
@str.5 = [9 x i8] c"Got Foo!\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 %14 [
i32 0, label %4
i32 1, label %7
i32 2, label %9
i32 3, label %12
]
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 2)
unreachable
7: ; preds = %2
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.5, i64 0, i64 0))
br label %9
9: ; preds = %2, %7
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.4, i64 0, i64 0))
%11 = call i32 @longjmp(i32 undef, i32 1)
unreachable
12: ; preds = %2
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
br label %14
14: ; preds = %2, %12
ret i32 0
}