#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(void) {
  do {
    jmp_buf exce_buf;
    switch (setjmp(exce_buf)) {
    case 0:
      do {
        {
          printf("In TRY statment.\n");
          longjmp(exce_buf, ((2)));
          printf("Here will not be printed.\n");
        }
        break;
      case ((1)): {
        printf("Exception handling A.\n");
      } break;
      case ((2)): {
        printf("Exception handling B.\n");
      } break;
      case ((3)): {
        printf("Exception handling C.\n");
      } break;
      } while (0);
    default:
      do {
        { printf("In FINALLY statment.\n"); }
      } while (0);
    }
  } while (0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <setjmp@plt>
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x3,%eax
ja     11bb <main+0x8b>
mov    -0x10(%rbp),%rax
lea    0xe9f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
jmp    116f <main+0x3f>
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
mov    $0x2,%esi
call   1050 <longjmp@plt>
lea    0xe93(%rip),%rdi
call   1030 <printf@plt>
jmp    11b6 <main+0x86>
lea    0xe99(%rip),%rdi
call   1030 <printf@plt>
jmp    11b6 <main+0x86>
lea    0xe9f(%rip),%rdi
call   1030 <printf@plt>
jmp    11bb <main+0x8b>
jmp    11c0 <main+0x90>
lea    0xea0(%rip),%rdi
call   1030 <printf@plt>
jmp    11d1 <main+0xa1>
jmp    11d6 <main+0xa6>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
call   1040 <setjmp@plt>
cmp    $0x3,%eax
ja     1169 <main+0x39>
lea    0xf0f(%rip),%rdi
mov    %eax,%eax
lea    0xeb5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xee0(%rip),%rdi
jmp    1164 <main+0x34>
lea    0xeac(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb6(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret
lea    0xee7(%rip),%rdi
call   1030 <puts@plt>
mov    $0x2,%esi
call   1050 <longjmp@plt>

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

LLVM IR (-O2):
@str = [22 x i8] c"Exception handling C.\00"
@str.5 = [21 x i8] c"In FINALLY statment.\00"
@str.6 = [22 x i8] c"Exception handling B.\00"
@str.7 = [22 x i8] c"Exception handling A.\00"
@str.8 = [17 x i8] c"In TRY statment.\00"
define i32 @main() {
%1 = call i32 @setjmp(i32 undef)
switch i32 %1, label %10 [
i32 0, label %2
i32 1, label %7
i32 2, label %5
i32 3, label %6
]
2: ; preds = %0
%3 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.8, i64 0, i64 0))
%4 = call i32 @longjmp(i32 undef, i32 2)
unreachable
5: ; preds = %0
br label %7
6: ; preds = %0
br label %7
7: ; preds = %0, %5, %6
%8 = phi i8* [ getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0), %6 ], [ getelementptr inbounds ([22 x i8], [22 x i8]* @str.6, i64 0, i64 0), %5 ], [ getelementptr inbounds ([22 x i8], [22 x i8]* @str.7, i64 0, i64 0), %0 ]
%9 = call i32 @puts(i8* dereferenceable(1) %8)
br label %10
10: ; preds = %7, %0
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.5, i64 0, i64 0))
ret i32 0
}