#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 box_map_local_entry(int const **, int const, int const, int const,
                        int const);
int box_map_local(const int box_local[][2], const int ghost,
                  const int box_local_map[], const int local_x,
                  const int local_y, const int local_z) {
  int result = box_map_local_entry(box_local, ghost, local_x, local_y, local_z);
  if (0 <= result) {
    result = box_local_map[result];
  }
  return result;
}


x86 assembly (clang, -O0):
<box_map_local>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
mov    -0x24(%rbp),%r8d
call   1030 <box_map_local_entry@plt>
mov    %eax,-0x28(%rbp)
xor    %eax,%eax
cmp    -0x28(%rbp),%eax
jg     1160 <box_map_local+0x50>
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<box_map_local>:
push   %rbx
mov    %rdx,%rbx
mov    %ecx,%edx
mov    %r8d,%ecx
mov    %r9d,%r8d
call   1030 <box_map_local_entry@plt>
test   %eax,%eax
js     112a <box_map_local+0x1a>
mov    %eax,%eax
mov    (%rbx,%rax,4),%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @box_map_local([2 x i32]* %0, i32 %1, i32* %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca [2 x i32]*
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store [2 x i32]* %0, [2 x i32]** %7
store i32 %1, i32* %8
store i32* %2, i32** %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i32 %5, i32* %12
%14 = load [2 x i32]*, [2 x i32]** %7
%15 = bitcast [2 x i32]* %14 to i32**
%16 = load i32, i32* %8
%17 = load i32, i32* %10
%18 = load i32, i32* %11
%19 = load i32, i32* %12
%20 = call i32 @box_map_local_entry(i32** %15, i32 %16, i32 %17, i32 %18, i32 %19)
store i32 %20, i32* %13
%21 = load i32, i32* %13
%22 = icmp sle i32 0, %21
br i1 %22, label %23, label %29
23: ; preds = %6
%24 = load i32*, i32** %9
%25 = load i32, i32* %13
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %24, i64 %26
%28 = load i32, i32* %27
store i32 %28, i32* %13
br label %29
29: ; preds = %23, %6
%30 = load i32, i32* %13
ret i32 %30
}

LLVM IR (-O2):
define i32 @box_map_local([2 x i32]* %0, i32 %1, i32* nocapture %2, i32 %3, i32 %4, i32 %5) {
%7 = bitcast [2 x i32]* %0 to i32**
%8 = tail call i32 @box_map_local_entry(i32** %7, i32 %1, i32 %3, i32 %4, i32 %5)
%9 = icmp sgt i32 %8, -1
br i1 %9, label %10, label %14
10: ; preds = %6
%11 = zext i32 %8 to i64
%12 = getelementptr inbounds i32, i32* %2, i64 %11
%13 = load i32, i32* %12
br label %14
14: ; preds = %10, %6
%15 = phi i32 [ %13, %10 ], [ %8, %6 ]
ret i32 %15
}