#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 get_grid_point_single_mesh(int *, int const *);
int /*<<< orphan*/ mat_modulo_i3(int *, int const *);
int get_grid_point_double_mesh(const int address_double[3], const int mesh[3]) {
  int i, address[3];
  for (i = 0; i < 3; i++) {
    if (address_double[i] % 2 == 0) {
      address[i] = address_double[i] / 2;
    } else {
      address[i] = (address_double[i] - 1) / 2;
    }
  }
  mat_modulo_i3(address, mesh);
  return get_grid_point_single_mesh(address, mesh);
}


x86 assembly (clang, -O0):
<get_grid_point_double_mesh>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jge    11b2 <get_grid_point_double_mesh+0x92>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    117f <get_grid_point_double_mesh+0x5f>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
movslq -0x14(%rbp),%rax
mov    %ecx,-0x20(%rbp,%rax,4)
jmp    119f <get_grid_point_double_mesh+0x7f>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
sub    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
movslq -0x14(%rbp),%rax
mov    %ecx,-0x20(%rbp,%rax,4)
jmp    11a4 <get_grid_point_double_mesh+0x84>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1137 <get_grid_point_double_mesh+0x17>
lea    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <mat_modulo_i3@plt>
lea    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <get_grid_point_single_mesh@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_grid_point_double_mesh>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    (%rdi),%eax
sar    %eax
mov    %eax,0xc(%rsp)
mov    0x4(%rdi),%eax
sar    %eax
mov    %eax,0x10(%rsp)
mov    0x8(%rdi),%eax
sar    %eax
mov    %eax,0x14(%rsp)
lea    0xc(%rsp),%r14
mov    %r14,%rdi
call   1040 <mat_modulo_i3@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <get_grid_point_single_mesh@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @get_grid_point_double_mesh(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca [3 x i32]
store i32* %0, i32** %3
store i32* %1, i32** %4
store i32 0, i32* %5
br label %7
7: ; preds = %40, %2
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 3
br i1 %9, label %10, label %43
10: ; preds = %7
%11 = load i32*, i32** %3
%12 = load i32, i32* %5
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i32, i32* %11, i64 %13
%15 = load i32, i32* %14
%16 = srem i32 %15, 2
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %28
18: ; preds = %10
%19 = load i32*, i32** %3
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %19, i64 %21
%23 = load i32, i32* %22
%24 = sdiv i32 %23, 2
%25 = load i32, i32* %5
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 %26
store i32 %24, i32* %27
br label %39
28: ; preds = %10
%29 = load i32*, i32** %3
%30 = load i32, i32* %5
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %29, i64 %31
%33 = load i32, i32* %32
%34 = sub nsw i32 %33, 1
%35 = sdiv i32 %34, 2
%36 = load i32, i32* %5
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 %37
store i32 %35, i32* %38
br label %39
39: ; preds = %28, %18
br label %40
40: ; preds = %39
%41 = load i32, i32* %5
%42 = add nsw i32 %41, 1
store i32 %42, i32* %5
br label %7
43: ; preds = %7
%44 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 0
%45 = load i32*, i32** %4
%46 = call i32 @mat_modulo_i3(i32* %44, i32* %45)
%47 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 0
%48 = load i32*, i32** %4
%49 = call i32 @get_grid_point_single_mesh(i32* %47, i32* %48)
ret i32 %49
}

LLVM IR (-O2):
define i32 @get_grid_point_double_mesh(i32* nocapture %0, i32* %1) {
%3 = alloca [3 x i32]
%4 = bitcast [3 x i32]* %3 to i8*
%5 = load i32, i32* %0
%6 = and i32 %5, -2
%7 = sdiv i32 %6, 2
%8 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 0
store i32 %7, i32* %8
%9 = getelementptr inbounds i32, i32* %0, i64 1
%10 = load i32, i32* %9
%11 = and i32 %10, -2
%12 = sdiv i32 %11, 2
%13 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 1
store i32 %12, i32* %13
%14 = getelementptr inbounds i32, i32* %0, i64 2
%15 = load i32, i32* %14
%16 = and i32 %15, -2
%17 = sdiv i32 %16, 2
%18 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 2
store i32 %17, i32* %18
%19 = call i32 @mat_modulo_i3(i32* %8, i32* %1)
%20 = call i32 @get_grid_point_single_mesh(i32* %8, i32* %1)
ret i32 %20
}