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

/* Variables and functions */
int adapt_enter_stacks(int /*<<< orphan*/, int /*<<< orphan*/, int,
                       int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int enter_stacks(int message, uint64_t bid, int rid) {
  int error;
  if (message == 1)
    printf("\nEnter region with stacks\n");
  error = adapt_enter_stacks(bid, 0, rid, 0);
  if (message == 1)
    printf("Returned error code: %d\n", error);
  return error;
}


x86 assembly (clang, -O0):
<enter_stacks>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
cmpl   $0x1,-0x4(%rbp)
jne    1149 <enter_stacks+0x29>
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%edx
xor    %ecx,%ecx
mov    %ecx,%esi
call   1030 <adapt_enter_stacks@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x1,-0x4(%rbp)
jne    1176 <enter_stacks+0x56>
mov    -0x10(%rbp),%esi
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<enter_stacks>:
push   %rbp
push   %rbx
push   %rax
mov    %edx,%ebx
mov    %esi,%ebp
cmp    $0x1,%edi
jne    1170 <enter_stacks+0x40>
lea    0xed6(%rip),%rdi
call   1040 <puts@plt>
mov    %ebp,%edi
xor    %esi,%esi
mov    %ebx,%edx
xor    %ecx,%ecx
call   1030 <adapt_enter_stacks@plt>
mov    %eax,%ebx
lea    0xea2(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    %ebp,%edi
xor    %esi,%esi
mov    %ebx,%edx
xor    %ecx,%ecx
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <adapt_enter_stacks@plt>

LLVM IR (-O0):
@.str = [27 x i8] c"\0AEnter region with stacks\0A\00"
@.str.1 = [25 x i8] c"Returned error code: %d\0A\00"
define i32 @enter_stacks(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %12
10: ; preds = %3
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %3
%13 = load i32, i32* %5
%14 = load i32, i32* %6
%15 = call i32 @adapt_enter_stacks(i32 %13, i32 0, i32 %14, i32 0)
store i32 %15, i32* %7
%16 = load i32, i32* %4
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %21
18: ; preds = %12
%19 = load i32, i32* %7
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %19)
br label %21
21: ; preds = %18, %12
%22 = load i32, i32* %7
ret i32 %22
}

LLVM IR (-O2):
@.str.1 = [25 x i8] c"Returned error code: %d\0A\00"
@str = [26 x i8] c"\0AEnter region with stacks\00"
define i32 @enter_stacks(i32 %0, i32 %1, i32 %2) {
%4 = icmp eq i32 %0, 1
br i1 %4, label %7, label %5
5: ; preds = %3
%6 = tail call i32 @adapt_enter_stacks(i32 %1, i32 0, i32 %2, i32 0)
br label %11
7: ; preds = %3
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%9 = tail call i32 @adapt_enter_stacks(i32 %1, i32 0, i32 %2, i32 0)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %9)
br label %11
11: ; preds = %5, %7
%12 = phi i32 [ %9, %7 ], [ %6, %5 ]
ret i32 %12
}