#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*/ alloc_err(int /*<<< orphan*/ *);
int /*<<< orphan*/ alloc_err_handler(int /*<<< orphan*/ *);
int /*<<< orphan*/ first(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ setjmp(int /*<<< orphan*/);
int main() {
  static jmp_buf buf;
  if (!setjmp(buf)) {
    first(&buf);
  } else {
    printf("main\n");
  }
  alloc_err_handler(&buf);
  alloc_err(&buf);
  printf("finishing\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2ee7(%rip),%edi
call   1040 <setjmp@plt>
cmp    $0x0,%eax
jne    1184 <main+0x34>
lea    0x2ed2(%rip),%rdi
call   1070 <first@plt>
jmp    1190 <main+0x40>
lea    0xe75(%rip),%rdi
call   1030 <printf@plt>
lea    0x2eb5(%rip),%rdi
call   1050 <alloc_err_handler@plt>
lea    0x2ea9(%rip),%rdi
call   1060 <alloc_err@plt>
lea    0xe57(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    0x2ef5(%rip),%edi
call   1040 <setjmp@plt>
test   %eax,%eax
je     116e <main+0x1e>
lea    0xea3(%rip),%rdi
call   1030 <puts@plt>
jmp    117a <main+0x2a>
lea    0x2ed7(%rip),%rdi
call   1070 <first@plt>
lea    0x2ecb(%rip),%rbx
mov    %rbx,%rdi
call   1050 <alloc_err_handler@plt>
mov    %rbx,%rdi
call   1060 <alloc_err@plt>
lea    0xe68(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@main.buf = internal global i32 0
@.str = [6 x i8] c"main\0A\00"
@.str.1 = [11 x i8] c"finishing\0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = load i32, i32* @main.buf
%3 = call i32 @setjmp(i32 %2)
%4 = icmp ne i32 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %0
%6 = call i32 @first(i32* @main.buf)
br label %9
7: ; preds = %0
%8 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %7, %5
%10 = call i32 @alloc_err_handler(i32* @main.buf)
%11 = call i32 @alloc_err(i32* @main.buf)
%12 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@main.buf = internal global i32 0
@str = [10 x i8] c"finishing\00"
@str.2 = [5 x i8] c"main\00"
define i32 @main() {
%1 = load i32, i32* @main.buf
%2 = call i32 @setjmp(i32 %1)
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = call i32 @first(i32* @main.buf)
br label %8
6: ; preds = %0
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.2, i64 0, i64 0))
br label %8
8: ; preds = %6, %4
%9 = call i32 @alloc_err_handler(i32* @main.buf)
%10 = call i32 @alloc_err(i32* @main.buf)
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
ret i32 0
}