#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*/ i2xyz(int, int, int, int *);
int pow(int, int);
int /*<<< orphan*/ printf(char *, ...);
int xyz2i(int, int, int *);
void Testindex2xyz() {
  int d = 3, L = 3;
  int coord[d];
  int N = pow(L, d);
  int j, i;
  printf("Provant funcio i2xyz i reciproca\n");
  for (i = 0; i < N; ++i) {
    i2xyz(d, L, i, coord);
    j = xyz2i(d, L, coord);
    printf("%d: (%d, %d, %d) %d\n", i, coord[0], coord[1], coord[2], j);
  }
  return;
}


x86 assembly (clang, -O0):
<Testindex2xyz>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x3,-0x4(%rbp)
movl   $0x3,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x4(%rbp),%esi
call   1050 <pow@plt>
mov    %eax,-0x1c(%rbp)
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1202 <Testindex2xyz+0xc2>
mov    -0x30(%rbp),%rcx
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x24(%rbp),%edx
call   1030 <i2xyz@plt>
mov    -0x30(%rbp),%rdx
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1060 <xyz2i@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,-0x20(%rbp)
mov    -0x24(%rbp),%esi
mov    (%rax),%edx
mov    0x4(%rax),%ecx
mov    0x8(%rax),%r8d
mov    -0x20(%rbp),%r9d
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11a0 <Testindex2xyz+0x60>
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Testindex2xyz>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    $0x3,%edi
mov    $0x3,%esi
call   1060 <pow@plt>
mov    %eax,%r15d
lea    0xea2(%rip),%rdi
call   1030 <puts@plt>
test   %r15d,%r15d
jle    11d9 <Testindex2xyz+0x89>
mov    %rsp,%rbx
lea    0xe79(%rip),%r14
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    $0x3,%edi
mov    $0x3,%esi
mov    %ebp,%edx
mov    %rbx,%rcx
call   1040 <i2xyz@plt>
mov    $0x3,%edi
mov    $0x3,%esi
mov    %rbx,%rdx
call   1070 <xyz2i@plt>
mov    (%rsp),%edx
mov    0x4(%rsp),%ecx
mov    0x8(%rsp),%r8d
mov    %r14,%rdi
mov    %ebp,%esi
mov    %eax,%r9d
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebp
cmp    %ebp,%r15d
jne    1190 <Testindex2xyz+0x40>
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [34 x i8] c"Provant funcio i2xyz i reciproca\0A\00"
@.str.1 = [21 x i8] c"%d: (%d, %d, %d) %d\0A\00"
define void @Testindex2xyz() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 3, i32* %1
store i32 3, i32* %2
%8 = load i32, i32* %1
%9 = zext i32 %8 to i64
%10 = call i8* @llvm.stacksave()
store i8* %10, i8** %3
%11 = alloca i32, i64 %9
store i64 %9, i64* %4
%12 = load i32, i32* %2
%13 = load i32, i32* %1
%14 = call i32 @pow(i32 %12, i32 %13)
store i32 %14, i32* %5
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %7
br label %16
16: ; preds = %37, %0
%17 = load i32, i32* %7
%18 = load i32, i32* %5
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %40
20: ; preds = %16
%21 = load i32, i32* %1
%22 = load i32, i32* %2
%23 = load i32, i32* %7
%24 = call i32 @i2xyz(i32 %21, i32 %22, i32 %23, i32* %11)
%25 = load i32, i32* %1
%26 = load i32, i32* %2
%27 = call i32 @xyz2i(i32 %25, i32 %26, i32* %11)
store i32 %27, i32* %6
%28 = load i32, i32* %7
%29 = getelementptr inbounds i32, i32* %11, i64 0
%30 = load i32, i32* %29
%31 = getelementptr inbounds i32, i32* %11, i64 1
%32 = load i32, i32* %31
%33 = getelementptr inbounds i32, i32* %11, i64 2
%34 = load i32, i32* %33
%35 = load i32, i32* %6
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %28, i32 %30, i32 %32, i32 %34, i32 %35)
br label %37
37: ; preds = %20
%38 = load i32, i32* %7
%39 = add nsw i32 %38, 1
store i32 %39, i32* %7
br label %16
40: ; preds = %16
%41 = load i8*, i8** %3
ret void
}

LLVM IR (-O2):
@.str.1 = [21 x i8] c"%d: (%d, %d, %d) %d\0A\00"
@str = [33 x i8] c"Provant funcio i2xyz i reciproca\00"
define void @Testindex2xyz() {
%1 = alloca [3 x i32]
%2 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 0
%3 = tail call i32 @pow(i32 3, i32 3)
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%5 = icmp sgt i32 %3, 0
br i1 %5, label %6, label %19
6: ; preds = %0
%7 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 1
%8 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 2
br label %9
9: ; preds = %6, %9
%10 = phi i32 [ 0, %6 ], [ %17, %9 ]
%11 = call i32 @i2xyz(i32 3, i32 3, i32 %10, i32* %2)
%12 = call i32 @xyz2i(i32 3, i32 3, i32* %2)
%13 = load i32, i32* %2
%14 = load i32, i32* %7
%15 = load i32, i32* %8
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %10, i32 %13, i32 %14, i32 %15, i32 %12)
%17 = add nuw nsw i32 %10, 1
%18 = icmp eq i32 %17, %3
br i1 %18, label %19, label %9
19: ; preds = %9, %0
ret void
}