#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 */
long mat_modulo_l(long, int);
void reduce_double_grid_address(long address_double[3], const long D_diag[3]) {
  int i;
  for (i = 0; i < 3; i++) {
    address_double[i] = mat_modulo_l(address_double[i], 2 * D_diag[i]);
  }
}


x86 assembly (clang, -O0):
<reduce_double_grid_address>:
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    1171 <reduce_double_grid_address+0x61>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
shl    $0x1,%rax
mov    %eax,%esi
call   1030 <mat_modulo_l@plt>
mov    %rax,%rdx
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1127 <reduce_double_grid_address+0x17>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reduce_double_grid_address>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    (%rdi),%rdi
mov    (%rsi),%esi
add    %esi,%esi
call   1030 <mat_modulo_l@plt>
mov    %rax,(%rbx)
mov    0x8(%rbx),%rdi
mov    0x8(%r14),%esi
add    %esi,%esi
call   1030 <mat_modulo_l@plt>
mov    %rax,0x8(%rbx)
mov    0x10(%rbx),%rdi
mov    0x10(%r14),%esi
add    %esi,%esi
call   1030 <mat_modulo_l@plt>
mov    %rax,0x10(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define void @reduce_double_grid_address(i64* nocapture %0, i64* nocapture %1) {
%3 = load i64, i64* %0
%4 = load i64, i64* %1
%5 = trunc i64 %4 to i32
%6 = shl i32 %5, 1
%7 = tail call i64 @mat_modulo_l(i64 %3, i32 %6)
store i64 %7, i64* %0
%8 = getelementptr inbounds i64, i64* %0, i64 1
%9 = load i64, i64* %8
%10 = getelementptr inbounds i64, i64* %1, i64 1
%11 = load i64, i64* %10
%12 = trunc i64 %11 to i32
%13 = shl i32 %12, 1
%14 = tail call i64 @mat_modulo_l(i64 %9, i32 %13)
store i64 %14, i64* %8
%15 = getelementptr inbounds i64, i64* %0, i64 2
%16 = load i64, i64* %15
%17 = getelementptr inbounds i64, i64* %1, i64 2
%18 = load i64, i64* %17
%19 = trunc i64 %18 to i32
%20 = shl i32 %19, 1
%21 = tail call i64 @mat_modulo_l(i64 %16, i32 %20)
store i64 %21, i64* %15
ret void
}