#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 uint32_t;
typedef int /*<<< orphan*/ jmp_buf;

/* Variables and functions */
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ longjmp(int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdout;
void jumper(jmp_buf *env) {
  uint32_t i, j;
  for (i = 0; i < 10000; i++) {
    for (j = 0; j < 10000; j++) {
      if (j == i) {
        printf("+");
      }
    }
  }
  printf("\ncalling longjmp\n\n");
  fflush(stdout);
  longjmp(*env, 23);
}


x86 assembly (clang, -O0):
<jumper>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x2710,-0xc(%rbp)
jge    11a2 <jumper+0x72>
movl   $0x0,-0x10(%rbp)
cmpl   $0x2710,-0x10(%rbp)
jge    118f <jumper+0x5f>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    117c <jumper+0x4c>
lea    0xe89(%rip),%rdi
call   1030 <printf@plt>
jmp    1181 <jumper+0x51>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1157 <jumper+0x27>
jmp    1194 <jumper+0x64>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1143 <jumper+0x13>
lea    0xe59(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e2b(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
mov    $0x17,%esi
call   1050 <longjmp@plt>

x86 assembly (clang, -O2):
<jumper>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
xor    %ebp,%ebp
jmp    115b <jumper+0x1b>
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebp
cmp    $0x2710,%ebp
je     117b <jumper+0x3b>
xor    %ebx,%ebx
jmp    116b <jumper+0x2b>
nop
add    $0x1,%ebx
cmp    $0x2710,%ebx
je     1150 <jumper+0x10>
cmp    %ebx,%ebp
jne    1160 <jumper+0x20>
mov    $0x2b,%edi
call   1030 <putchar@plt>
jmp    1160 <jumper+0x20>
lea    0xe7e(%rip),%rdi
call   1040 <puts@plt>
mov    0x2e52(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    (%r14),%edi
mov    $0x17,%esi
call   1060 <longjmp@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"+\00"
@.str.1 = [19 x i8] c"\0Acalling longjmp\0A\0A\00"
@stdout = global i32 0
define void @jumper(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
store i32* %0, i32** %2
store i32 0, i32* %3
br label %5
5: ; preds = %23, %1
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 10000
br i1 %7, label %8, label %26
8: ; preds = %5
store i32 0, i32* %4
br label %9
9: ; preds = %19, %8
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 10000
br i1 %11, label %12, label %22
12: ; preds = %9
%13 = load i32, i32* %4
%14 = load i32, i32* %3
%15 = icmp eq i32 %13, %14
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %18
18: ; preds = %16, %12
br label %19
19: ; preds = %18
%20 = load i32, i32* %4
%21 = add nsw i32 %20, 1
store i32 %21, i32* %4
br label %9
22: ; preds = %9
br label %23
23: ; preds = %22
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
store i32 %25, i32* %3
br label %5
26: ; preds = %5
%27 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%28 = load i32, i32* @stdout
%29 = call i32 @fflush(i32 %28)
%30 = load i32*, i32** %2
%31 = load i32, i32* %30
%32 = call i32 @longjmp(i32 %31, i32 23)
unreachable
}

LLVM IR (-O2):
@stdout = global i32 0
@str = [18 x i8] c"\0Acalling longjmp\0A\00"
define void @jumper(i32* nocapture %0) {
br label %2
2: ; preds = %1, %12
%3 = phi i32 [ 0, %1 ], [ %13, %12 ]
br label %4
4: ; preds = %2, %9
%5 = phi i32 [ 0, %2 ], [ %10, %9 ]
%6 = icmp eq i32 %5, %3
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = tail call i32 @putchar(i32 43)
br label %9
9: ; preds = %4, %7
%10 = add nuw nsw i32 %5, 1
%11 = icmp eq i32 %10, 10000
br i1 %11, label %12, label %4
12: ; preds = %9
%13 = add nuw nsw i32 %3, 1
%14 = icmp eq i32 %13, 10000
br i1 %14, label %15, label %2
15: ; preds = %12
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%17 = load i32, i32* @stdout
%18 = tail call i32 @fflush(i32 %17)
%19 = load i32, i32* %0
%20 = tail call i32 @longjmp(i32 %19, i32 23)
unreachable
}