#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 EXIT_SUCCESS;
int /*<<< orphan*/ printf(char *, ...);
int setjmp(int /*<<< orphan*/);
int /*<<< orphan*/ test(int /*<<< orphan*/ *);
int main() {
  jmp_buf env;
  int ret = setjmp(env);
  if (ret == 0) {
    printf("setjmp succeed\n");
  } else {
    printf("2....(%d)\n", ret);
    return EXIT_SUCCESS;
  }
  test(&env);
  return EXIT_SUCCESS;
}


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,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    1167 <main+0x37>
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1189 <main+0x59>
mov    -0xc(%rbp),%esi
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e61(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    119e <main+0x6e>
lea    -0x8(%rbp),%rdi
call   1050 <test@plt>
mov    0x2e47(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
call   1050 <setjmp@plt>
test   %eax,%eax
je     115c <main+0x1c>
mov    %eax,%esi
lea    0xead(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1172 <main+0x32>
lea    0xea8(%rip),%rdi
call   1030 <puts@plt>
lea    0x4(%rsp),%rdi
call   1060 <test@plt>
mov    0x2e67(%rip),%rax
mov    (%rax),%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [16 x i8] c"setjmp succeed\0A\00"
@.str.1 = [11 x i8] c"2....(%d)\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = load i32, i32* %2
%5 = call i32 @setjmp(i32 %4)
store i32 %5, i32* %3
%6 = load i32, i32* %3
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %14
10: ; preds = %0
%11 = load i32, i32* %3
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = load i32, i32* @EXIT_SUCCESS
store i32 %13, i32* %1
br label %17
14: ; preds = %8
%15 = call i32 @test(i32* %2)
%16 = load i32, i32* @EXIT_SUCCESS
store i32 %16, i32* %1
br label %17
17: ; preds = %14, %10
%18 = load i32, i32* %1
ret i32 %18
}

LLVM IR (-O2):
@.str.1 = [11 x i8] c"2....(%d)\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [15 x i8] c"setjmp succeed\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @setjmp(i32 undef)
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %0
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%7 = call i32 @test(i32* %1)
br label %10
8: ; preds = %0
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %3)
br label %10
10: ; preds = %5, %8
%11 = load i32, i32* @EXIT_SUCCESS
ret i32 %11
}