#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*/ bar(int **, int **);
void __attribute__((always_)) foo(int x[][3][3]) {
  int i;
  for (i = 0; i < 8; i++) {
    int k = i + 8;
    bar(x[k], x[k - 8]);
  }
}


x86 assembly (clang, -O0):
<foo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x8,-0xc(%rbp)
jge    116b <foo+0x5b>
mov    -0xc(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0x10(%rbp),%rax
imul   $0x24,%rax,%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%eax
sub    $0x8,%eax
cltq
imul   $0x24,%rax,%rax
add    %rax,%rsi
call   1030 <bar@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <foo+0x13>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo>:
push   %rbx
mov    %rdi,%rbx
add    $0x120,%rdi
mov    %rbx,%rsi
call   1030 <bar@plt>
lea    0x144(%rbx),%rdi
lea    0x24(%rbx),%rsi
call   1030 <bar@plt>
lea    0x168(%rbx),%rdi
lea    0x48(%rbx),%rsi
call   1030 <bar@plt>
lea    0x18c(%rbx),%rdi
lea    0x6c(%rbx),%rsi
call   1030 <bar@plt>
lea    0x1b0(%rbx),%rdi
lea    0x90(%rbx),%rsi
call   1030 <bar@plt>
lea    0x1d4(%rbx),%rdi
lea    0xb4(%rbx),%rsi
call   1030 <bar@plt>
lea    0x1f8(%rbx),%rdi
lea    0xd8(%rbx),%rsi
call   1030 <bar@plt>
lea    0x21c(%rbx),%rdi
add    $0xfc,%rbx
mov    %rbx,%rsi
pop    %rbx
jmp    1030 <bar@plt>

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

LLVM IR (-O2):
define void @foo([3 x [3 x i32]]* %0) {
%2 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %0, i64 8, i64 0
%3 = bitcast [3 x i32]* %2 to i32**
%4 = bitcast [3 x [3 x i32]]* %0 to i32**
%5 = tail call i32 @bar(i32** %3, i32** %4)
%6 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %0, i64 9, i64 0
%7 = bitcast [3 x i32]* %6 to i32**
%8 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %0, i64 1, i64 0
%9 = bitcast [3 x i32]* %8 to i32**
%10 = tail call i32 @bar(i32** %7, i32** %9)
%11 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %0, i64 10, i64 0
%12 = bitcast [3 x i32]* %11 to i32**
%13 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %0, i64 2, i64 0
%14 = bitcast [3 x i32]* %13 to i32**
%15 = tail call i32 @bar(i32** %12, i32** %14)
%16 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %0, i64 11, i64 0
%17 = bitcast [3 x i32]* %16 to i32**
%18 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %0, i64 3, i64 0
%19 = bitcast [3 x i32]* %18 to i32**
%20 = tail call i32 @bar(i32** %17, i32** %19)
%21 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %0, i64 12, i64 0
%22 = bitcast [3 x i32]* %21 to i32**
%23 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %0, i64 4, i64 0
%24 = bitcast [3 x i32]* %23 to i32**
%25 = tail call i32 @bar(i32** %22, i32** %24)
%26 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %0, i64 13, i64 0
%27 = bitcast [3 x i32]* %26 to i32**
%28 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %0, i64 5, i64 0
%29 = bitcast [3 x i32]* %28 to i32**
%30 = tail call i32 @bar(i32** %27, i32** %29)
%31 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %0, i64 14, i64 0
%32 = bitcast [3 x i32]* %31 to i32**
%33 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %0, i64 6, i64 0
%34 = bitcast [3 x i32]* %33 to i32**
%35 = tail call i32 @bar(i32** %32, i32** %34)
%36 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %0, i64 15, i64 0
%37 = bitcast [3 x i32]* %36 to i32**
%38 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %0, i64 7, i64 0
%39 = bitcast [3 x i32]* %38 to i32**
%40 = tail call i32 @bar(i32** %37, i32** %39)
ret void
}