#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 */

/* Variables and functions */
int /*<<< orphan*/ A();
int /*<<< orphan*/ printf(char *, ...);
int save();
void part2_main(void) {
  int r, a, b, c;
  printf("enter main\n");
  a = 1;
  b = 2;
  c = 3;
  r = save();
  if (r == 0) {
    A();
    printf("normal return\n");
  } else {
    printf("back to main via long jump r=%d\n", r);
    printf("a=%d b=%d c=%d\n", a, b, c);
  }
  printf("exit main\n");
}


x86 assembly (clang, -O0):
<part2_main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x8(%rbp)
movl   $0x2,-0xc(%rbp)
movl   $0x3,-0x10(%rbp)
mov    $0x0,%al
call   1040 <save@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1189 <part2_main+0x59>
mov    $0x0,%al
call   1050 <A@plt>
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b1 <part2_main+0x81>
mov    -0x4(%rbp),%esi
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<part2_main>:
push   %rax
lea    0xee9(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <save@plt>
test   %eax,%eax
je     1187 <part2_main+0x47>
lea    0xea1(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb2(%rip),%rdi
mov    $0x1,%esi
mov    $0x2,%edx
mov    $0x3,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    119a <part2_main+0x5a>
xor    %eax,%eax
call   1060 <A@plt>
lea    0xeb1(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9b(%rip),%rdi
pop    %rax
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"enter main\0A\00"
@.str.1 = [15 x i8] c"normal return\0A\00"
@.str.2 = [33 x i8] c"back to main via long jump r=%d\0A\00"
@.str.3 = [16 x i8] c"a=%d b=%d c=%d\0A\00"
@.str.4 = [11 x i8] c"exit main\0A\00"
define void @part2_main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %2
store i32 2, i32* %3
store i32 3, i32* %4
%6 = call i32 (...) @save()
store i32 %6, i32* %1
%7 = load i32, i32* %1
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %0
%10 = call i32 (...) @A()
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %19
12: ; preds = %0
%13 = load i32, i32* %1
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 %13)
%15 = load i32, i32* %2
%16 = load i32, i32* %3
%17 = load i32, i32* %4
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %15, i32 %16, i32 %17)
br label %19
19: ; preds = %12, %9
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.2 = [33 x i8] c"back to main via long jump r=%d\0A\00"
@.str.3 = [16 x i8] c"a=%d b=%d c=%d\0A\00"
@str = [11 x i8] c"enter main\00"
@str.5 = [10 x i8] c"exit main\00"
@str.6 = [14 x i8] c"normal return\00"
define void @part2_main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 (...) @save()
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %7
4: ; preds = %0
%5 = tail call i32 (...) @A()
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.6, i64 0, i64 0))
br label %10
7: ; preds = %0
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 %2)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 1, i32 2, i32 3)
br label %10
10: ; preds = %7, %4
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.5, i64 0, i64 0))
ret void
}