#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*/ amr_index_to_ijklmn(int, int, int, int, int, int, int,
                                       int *);
int /*<<< orphan*/ get_amr_index_xyz(int, int /*<<< orphan*/,
                                     int /*<<< orphan*/, int /*<<< orphan*/,
                                     int, int, int, int, int, double *,
                                     double *, double *, int *, double *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
double sqrt(int);
void main(void) {
  int i;
  int index = 301;
  int nf = 1;
  int pdegree = 1;
  int nX = 4;
  int nY = 2;
  int nZ = 4;
  int qstride = 5;
  int *ijklmn;
  double *qnodes;
  int *index1;
  double *xlo;
  double *dx;
  double *xyz;
  xlo = (double *)malloc(sizeof(double) * 3);
  dx = (double *)malloc(sizeof(double) * 3);
  index1 = (int *)malloc(sizeof(int) * 8);
  qnodes = (double *)malloc(sizeof(double) * 2);
  xyz = (double *)malloc(sizeof(double) * 8 * 3);
  for (i = 0; i < 3; i++) {
    xlo[i] = 0.0;
    dx[i] = 1.0;
  }
  qnodes[0] = -sqrt(1. / 3.0);
  qnodes[1] = -qnodes[0];
  ijklmn = (int *)malloc(sizeof(int) * 6);
  get_amr_index_xyz(qstride, 0, 0, 0, pdegree, nX, nY, nZ, nf, xlo, dx, qnodes,
                    index1, xyz);
  for (i = 0; i < 8; i++)
    printf("%d ", index1[i]);
  printf("\n");
  for (i = 0; i < 8; i++) {
    amr_index_to_ijklmn(pdegree, nX, nY, nZ, nf, qstride, index1[i], ijklmn);
    printf("%d %d %d %d %d %d\n", ijklmn[0], ijklmn[1], ijklmn[2], ijklmn[3],
           ijklmn[4], ijklmn[5]);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
movl   $0x12d,-0x30(%rbp)
movl   $0x1,-0x34(%rbp)
movl   $0x1,-0x38(%rbp)
movl   $0x4,-0x3c(%rbp)
movl   $0x2,-0x40(%rbp)
movl   $0x4,-0x44(%rbp)
movl   $0x5,-0x48(%rbp)
mov    $0x18,%edi
call   1050 <malloc@plt>
mov    %rax,-0x68(%rbp)
mov    $0x18,%edi
call   1050 <malloc@plt>
mov    %rax,-0x70(%rbp)
mov    $0x20,%edi
call   1050 <malloc@plt>
mov    %rax,-0x60(%rbp)
mov    $0x10,%edi
call   1050 <malloc@plt>
mov    %rax,-0x58(%rbp)
mov    $0xc0,%edi
call   1050 <malloc@plt>
mov    %rax,-0x78(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x3,-0x2c(%rbp)
jge    121f <main+0xcf>
mov    -0x68(%rbp),%rax
movslq -0x2c(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x70(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  0xdf4(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11e2 <main+0x92>
xor    %edi,%edi
call   1070 <sqrt@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x58(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x58(%rbp),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x58(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    $0x18,%edi
call   1050 <malloc@plt>
mov    %rax,-0x50(%rbp)
mov    -0x48(%rbp),%edi
mov    -0x38(%rbp),%r8d
mov    -0x3c(%rbp),%r9d
mov    -0x40(%rbp),%r13d
mov    -0x44(%rbp),%r12d
mov    -0x34(%rbp),%r15d
mov    -0x68(%rbp),%r14
mov    -0x70(%rbp),%rbx
mov    -0x58(%rbp),%r11
mov    -0x60(%rbp),%r10
mov    -0x78(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%esi
mov    %ecx,%edx
mov    %r13d,(%rsp)
mov    %r12d,0x8(%rsp)
mov    %r15d,0x10(%rsp)
mov    %r14,0x18(%rsp)
mov    %rbx,0x20(%rsp)
mov    %r11,0x28(%rsp)
mov    %r10,0x30(%rsp)
mov    %rax,0x38(%rsp)
call   1060 <get_amr_index_xyz@plt>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x8,-0x2c(%rbp)
jge    1310 <main+0x1c0>
mov    -0x60(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xd0d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    12df <main+0x18f>
lea    0xd06(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x8,-0x2c(%rbp)
jge    13ab <main+0x25b>
mov    -0x38(%rbp),%edi
mov    -0x3c(%rbp),%esi
mov    -0x40(%rbp),%edx
mov    -0x44(%rbp),%ecx
mov    -0x34(%rbp),%r8d
mov    -0x48(%rbp),%r9d
mov    -0x60(%rbp),%rax
movslq -0x2c(%rbp),%r10
mov    (%rax,%r10,4),%r10d
mov    -0x50(%rbp),%rax
mov    %r10d,(%rsp)
mov    %rax,0x8(%rsp)
call   1040 <amr_index_to_ijklmn@plt>
mov    -0x50(%rbp),%rax
mov    (%rax),%esi
mov    -0x50(%rbp),%rax
mov    0x4(%rax),%edx
mov    -0x50(%rbp),%rax
mov    0x8(%rax),%ecx
mov    -0x50(%rbp),%rax
mov    0xc(%rax),%r8d
mov    -0x50(%rbp),%rax
mov    0x10(%rax),%r9d
mov    -0x50(%rbp),%rax
mov    0x14(%rax),%eax
lea    0xc79(%rip),%rdi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1325 <main+0x1d5>
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x18,%edi
call   1060 <malloc@plt>
mov    %rax,%r15
mov    $0x18,%edi
call   1060 <malloc@plt>
mov    %rax,%r12
mov    $0x20,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
mov    $0x10,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    $0xc0,%edi
call   1060 <malloc@plt>
mov    %rax,%rbp
movq   $0x0,(%r15)
movabs $0x3ff0000000000000,%rax
mov    %rax,(%r12)
movq   $0x0,0x8(%r15)
mov    %rax,0x8(%r12)
movq   $0x0,0x10(%r15)
mov    %rax,0x10(%r12)
xor    %edi,%edi
call   1080 <sqrt@plt>
movaps 0xe17(%rip),%xmm1
xorps  %xmm0,%xmm1
movlps %xmm1,(%rbx)
movsd  %xmm0,0x8(%rbx)
mov    $0x18,%edi
call   1060 <malloc@plt>
mov    %rax,%r13
mov    $0x5,%edi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
mov    $0x1,%r8d
mov    $0x4,%r9d
push   %rbp
push   %r14
push   %rbx
push   %r12
push   %r15
push   $0x1
push   $0x4
push   $0x2
call   1070 <get_amr_index_xyz@plt>
add    $0x40,%rsp
mov    (%r14),%esi
lea    0xdd7(%rip),%r15
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%r14),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%r14),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%r14),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%r14),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x14(%r14),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%r14),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x1c(%r14),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xd5e(%rip),%r15
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    (%r14,%rbp,4),%eax
mov    $0x1,%edi
mov    $0x4,%esi
mov    $0x2,%edx
mov    $0x4,%ecx
mov    $0x1,%r8d
mov    $0x5,%r9d
push   %r13
push   %rax
call   1050 <amr_index_to_ijklmn@plt>
add    $0x10,%rsp
mov    0x0(%r13),%esi
mov    0x4(%r13),%edx
mov    0x8(%r13),%ecx
mov    0xc(%r13),%r8d
mov    0x10(%r13),%r9d
mov    0x14(%r13),%ebx
sub    $0x8,%rsp
mov    %r15,%rdi
xor    %eax,%eax
push   %rbx
call   1040 <printf@plt>
add    $0x10,%rsp
add    $0x1,%rbp
cmp    $0x8,%rbp
jne    12c0 <main+0x160>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d \00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [19 x i8] c"%d %d %d %d %d %d\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca double*
%11 = alloca i32*
%12 = alloca double*
%13 = alloca double*
%14 = alloca double*
store i32 301, i32* %2
store i32 1, i32* %3
store i32 1, i32* %4
store i32 4, i32* %5
store i32 2, i32* %6
store i32 4, i32* %7
store i32 5, i32* %8
%15 = call i64 @malloc(i32 24)
%16 = inttoptr i64 %15 to double*
store double* %16, double** %12
%17 = call i64 @malloc(i32 24)
%18 = inttoptr i64 %17 to double*
store double* %18, double** %13
%19 = call i64 @malloc(i32 32)
%20 = inttoptr i64 %19 to i32*
store i32* %20, i32** %11
%21 = call i64 @malloc(i32 16)
%22 = inttoptr i64 %21 to double*
store double* %22, double** %10
%23 = call i64 @malloc(i32 192)
%24 = inttoptr i64 %23 to double*
store double* %24, double** %14
store i32 0, i32* %1
br label %25
25: ; preds = %37, %0
%26 = load i32, i32* %1
%27 = icmp slt i32 %26, 3
br i1 %27, label %28, label %40
28: ; preds = %25
%29 = load double*, double** %12
%30 = load i32, i32* %1
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double, double* %29, i64 %31
store double 0.000000e+00, double* %32
%33 = load double*, double** %13
%34 = load i32, i32* %1
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds double, double* %33, i64 %35
store double 1.000000e+00, double* %36
br label %37
37: ; preds = %28
%38 = load i32, i32* %1
%39 = add nsw i32 %38, 1
store i32 %39, i32* %1
br label %25
40: ; preds = %25
%41 = call double @sqrt(i32 0)
%42 = fneg double %41
%43 = load double*, double** %10
%44 = getelementptr inbounds double, double* %43, i64 0
store double %42, double* %44
%45 = load double*, double** %10
%46 = getelementptr inbounds double, double* %45, i64 0
%47 = load double, double* %46
%48 = fneg double %47
%49 = load double*, double** %10
%50 = getelementptr inbounds double, double* %49, i64 1
store double %48, double* %50
%51 = call i64 @malloc(i32 24)
%52 = inttoptr i64 %51 to i32*
store i32* %52, i32** %9
%53 = load i32, i32* %8
%54 = load i32, i32* %4
%55 = load i32, i32* %5
%56 = load i32, i32* %6
%57 = load i32, i32* %7
%58 = load i32, i32* %3
%59 = load double*, double** %12
%60 = load double*, double** %13
%61 = load double*, double** %10
%62 = load i32*, i32** %11
%63 = load double*, double** %14
%64 = call i32 @get_amr_index_xyz(i32 %53, i32 0, i32 0, i32 0, i32 %54, i32 %55, i32 %56, i32 %57, i32 %58, double* %59, double* %60, double* %61, i32* %62, double* %63)
store i32 0, i32* %1
br label %65
65: ; preds = %75, %40
%66 = load i32, i32* %1
%67 = icmp slt i32 %66, 8
br i1 %67, label %68, label %78
68: ; preds = %65
%69 = load i32*, i32** %11
%70 = load i32, i32* %1
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds i32, i32* %69, i64 %71
%73 = load i32, i32* %72
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %73)
br label %75
75: ; preds = %68
%76 = load i32, i32* %1
%77 = add nsw i32 %76, 1
store i32 %77, i32* %1
br label %65
78: ; preds = %65
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
br label %80
80: ; preds = %116, %78
%81 = load i32, i32* %1
%82 = icmp slt i32 %81, 8
br i1 %82, label %83, label %119
83: ; preds = %80
%84 = load i32, i32* %4
%85 = load i32, i32* %5
%86 = load i32, i32* %6
%87 = load i32, i32* %7
%88 = load i32, i32* %3
%89 = load i32, i32* %8
%90 = load i32*, i32** %11
%91 = load i32, i32* %1
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds i32, i32* %90, i64 %92
%94 = load i32, i32* %93
%95 = load i32*, i32** %9
%96 = call i32 @amr_index_to_ijklmn(i32 %84, i32 %85, i32 %86, i32 %87, i32 %88, i32 %89, i32 %94, i32* %95)
%97 = load i32*, i32** %9
%98 = getelementptr inbounds i32, i32* %97, i64 0
%99 = load i32, i32* %98
%100 = load i32*, i32** %9
%101 = getelementptr inbounds i32, i32* %100, i64 1
%102 = load i32, i32* %101
%103 = load i32*, i32** %9
%104 = getelementptr inbounds i32, i32* %103, i64 2
%105 = load i32, i32* %104
%106 = load i32*, i32** %9
%107 = getelementptr inbounds i32, i32* %106, i64 3
%108 = load i32, i32* %107
%109 = load i32*, i32** %9
%110 = getelementptr inbounds i32, i32* %109, i64 4
%111 = load i32, i32* %110
%112 = load i32*, i32** %9
%113 = getelementptr inbounds i32, i32* %112, i64 5
%114 = load i32, i32* %113
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %99, i32 %102, i32 %105, i32 %108, i32 %111, i32 %114)
br label %116
116: ; preds = %83
%117 = load i32, i32* %1
%118 = add nsw i32 %117, 1
store i32 %118, i32* %1
br label %80
119: ; preds = %80
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
@.str.2 = [19 x i8] c"%d %d %d %d %d %d\0A\00"
define void @main() {
%1 = tail call i64 @malloc(i32 24)
%2 = inttoptr i64 %1 to double*
%3 = tail call i64 @malloc(i32 24)
%4 = inttoptr i64 %3 to double*
%5 = tail call i64 @malloc(i32 32)
%6 = tail call i64 @malloc(i32 16)
%7 = tail call i64 @malloc(i32 192)
store double 0.000000e+00, double* %2
store double 1.000000e+00, double* %4
%8 = getelementptr inbounds double, double* %2, i64 1
store double 0.000000e+00, double* %8
%9 = getelementptr inbounds double, double* %4, i64 1
store double 1.000000e+00, double* %9
%10 = getelementptr inbounds double, double* %2, i64 2
store double 0.000000e+00, double* %10
%11 = getelementptr inbounds double, double* %4, i64 2
store double 1.000000e+00, double* %11
%12 = inttoptr i64 %5 to i32*
%13 = inttoptr i64 %6 to double*
%14 = inttoptr i64 %7 to double*
%15 = tail call double @sqrt(i32 0)
%16 = fneg double %15
store double %16, double* %13
%17 = getelementptr inbounds double, double* %13, i64 1
store double %15, double* %17
%18 = tail call i64 @malloc(i32 24)
%19 = tail call i32 @get_amr_index_xyz(i32 5, i32 0, i32 0, i32 0, i32 1, i32 4, i32 2, i32 4, i32 1, double* %2, double* %4, double* %13, i32* %12, double* %14)
%20 = load i32, i32* %12
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %20)
%22 = getelementptr inbounds i32, i32* %12, i64 1
%23 = load i32, i32* %22
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %23)
%25 = getelementptr inbounds i32, i32* %12, i64 2
%26 = load i32, i32* %25
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %26)
%28 = getelementptr inbounds i32, i32* %12, i64 3
%29 = load i32, i32* %28
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %29)
%31 = getelementptr inbounds i32, i32* %12, i64 4
%32 = load i32, i32* %31
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %32)
%34 = getelementptr inbounds i32, i32* %12, i64 5
%35 = load i32, i32* %34
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %35)
%37 = getelementptr inbounds i32, i32* %12, i64 6
%38 = load i32, i32* %37
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %38)
%40 = getelementptr inbounds i32, i32* %12, i64 7
%41 = load i32, i32* %40
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %41)
%43 = inttoptr i64 %18 to i32*
%44 = tail call i32 @putchar(i32 10)
%45 = getelementptr inbounds i32, i32* %43, i64 1
%46 = getelementptr inbounds i32, i32* %43, i64 2
%47 = getelementptr inbounds i32, i32* %43, i64 3
%48 = getelementptr inbounds i32, i32* %43, i64 4
%49 = getelementptr inbounds i32, i32* %43, i64 5
br label %50
50: ; preds = %0, %50
%51 = phi i64 [ 0, %0 ], [ %62, %50 ]
%52 = getelementptr inbounds i32, i32* %12, i64 %51
%53 = load i32, i32* %52
%54 = tail call i32 @amr_index_to_ijklmn(i32 1, i32 4, i32 2, i32 4, i32 1, i32 5, i32 %53, i32* %43)
%55 = load i32, i32* %43
%56 = load i32, i32* %45
%57 = load i32, i32* %46
%58 = load i32, i32* %47
%59 = load i32, i32* %48
%60 = load i32, i32* %49
%61 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %55, i32 %56, i32 %57, i32 %58, i32 %59, i32 %60)
%62 = add nuw nsw i64 %51, 1
%63 = icmp eq i64 %62, 8
br i1 %63, label %64, label %50
64: ; preds = %50
ret void
}