#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 dgetvectors(const int dims[3], int i, int j, const double *field,
                 const double *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):
<dgetvectors>:
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 <dgetvectors+0x71>
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rax
shl    $0x3,%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 <dgetvectors+0x35>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dgetvectors>:
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,8),%rax
mov    %rax,(%r14)
mov    0x8(%rsp),%rax
lea    (%rbx,%rax,8),%rax
mov    %rax,0x8(%r14)
mov    0x10(%rsp),%rax
lea    (%rbx,%rax,8),%rax
mov    %rax,0x10(%r14)
mov    0x18(%rsp),%rax
lea    (%rbx,%rax,8),%rax
mov    %rax,0x18(%r14)
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @dgetvectors(i32* %0, i32 %1, i32 %2, double* %3, double** %4) {
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca double*
%10 = alloca double**
%11 = alloca i64
%12 = alloca [4 x i64]
store i32* %0, i32** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store double* %3, double** %9
store double** %4, double*** %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 double*, double** %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 double, double* %22, i64 %25
%27 = load double**, double*** %10
%28 = load i64, i64* %11
%29 = getelementptr inbounds double*, double** %27, i64 %28
store double* %26, double** %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 @dgetvectors(i32* %0, i32 %1, i32 %2, double* %3, double** 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 double, double* %3, i64 %10
store double* %11, double** %4
%12 = getelementptr inbounds [4 x i64], [4 x i64]* %6, i64 0, i64 1
%13 = load i64, i64* %12
%14 = getelementptr inbounds double, double* %3, i64 %13
%15 = getelementptr inbounds double*, double** %4, i64 1
store double* %14, double** %15
%16 = getelementptr inbounds [4 x i64], [4 x i64]* %6, i64 0, i64 2
%17 = load i64, i64* %16
%18 = getelementptr inbounds double, double* %3, i64 %17
%19 = getelementptr inbounds double*, double** %4, i64 2
store double* %18, double** %19
%20 = getelementptr inbounds [4 x i64], [4 x i64]* %6, i64 0, i64 3
%21 = load i64, i64* %20
%22 = getelementptr inbounds double, double* %3, i64 %21
%23 = getelementptr inbounds double*, double** %4, i64 3
store double* %22, double** %23
ret void
}