#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*/ vector_positions(int const *, int, int, size_t *);
void igetvectors(const int dims[3], int i, int j, const int *field,
                 const int *v[]) {
  size_t p, start[4];
  vector_positions(dims, i, j, start);
  for (p = 0; p < 4; p++) {
    v[p] = field + start[p];
  }
}


x86 assembly (clang, -O0):
<igetvectors>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    -0x50(%rbp),%rcx
call   1030 <vector_positions@plt>
movq   $0x0,-0x28(%rbp)
cmpq   $0x4,-0x28(%rbp)
jae    1181 <igetvectors+0x71>
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rax
shl    $0x2,%rax
add    %rax,%rdx
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1145 <igetvectors+0x35>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<igetvectors>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %r8,%r14
mov    %rcx,%rbx
mov    %rsp,%rcx
call   1030 <vector_positions@plt>
mov    (%rsp),%rax
lea    (%rbx,%rax,4),%rax
mov    %rax,(%r14)
mov    0x8(%rsp),%rax
lea    (%rbx,%rax,4),%rax
mov    %rax,0x8(%r14)
mov    0x10(%rsp),%rax
lea    (%rbx,%rax,4),%rax
mov    %rax,0x10(%r14)
mov    0x18(%rsp),%rax
lea    (%rbx,%rax,4),%rax
mov    %rax,0x18(%r14)
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define void @igetvectors(i32* %0, i32 %1, i32 %2, i32* %3, i32** nocapture writeonly %4) {
%6 = alloca [4 x i64]
%7 = bitcast [4 x i64]* %6 to i8*
%8 = getelementptr inbounds [4 x i64], [4 x i64]* %6, i64 0, i64 0
%9 = call i32 @vector_positions(i32* %0, i32 %1, i32 %2, i64* %8)
%10 = load i64, i64* %8
%11 = getelementptr inbounds i32, i32* %3, i64 %10
store i32* %11, i32** %4
%12 = getelementptr inbounds [4 x i64], [4 x i64]* %6, i64 0, i64 1
%13 = load i64, i64* %12
%14 = getelementptr inbounds i32, i32* %3, i64 %13
%15 = getelementptr inbounds i32*, i32** %4, i64 1
store i32* %14, i32** %15
%16 = getelementptr inbounds [4 x i64], [4 x i64]* %6, i64 0, i64 2
%17 = load i64, i64* %16
%18 = getelementptr inbounds i32, i32* %3, i64 %17
%19 = getelementptr inbounds i32*, i32** %4, i64 2
store i32* %18, i32** %19
%20 = getelementptr inbounds [4 x i64], [4 x i64]* %6, i64 0, i64 3
%21 = load i64, i64* %20
%22 = getelementptr inbounds i32, i32* %3, i64 %21
%23 = getelementptr inbounds i32*, i32** %4, i64 3
store i32* %22, i32** %23
ret void
}