#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 */
size_t i_to_I(int, unsigned int, unsigned int);
void create_index(unsigned int *D, unsigned int D_size, unsigned int *I,
                  unsigned int I_size) {
  int j;
  for (j = 0; j < I_size; j++)
    I[j] = D[i_to_I(j, I_size, D_size)];
}


x86 assembly (clang, -O0):
<create_index>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jae    1172 <create_index+0x62>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1030 <i_to_I@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
mov    (%rax,%rcx,4),%edx
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    112d <create_index+0x1d>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_index>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %ecx,%ecx
je     114d <create_index+0x3d>
mov    %rdx,%r14
mov    %esi,%r15d
mov    %rdi,%r12
mov    %ecx,%ebp
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %ebx,%edi
mov    %ebp,%esi
mov    %r15d,%edx
call   1030 <i_to_I@plt>
mov    (%r12,%rax,4),%eax
mov    %eax,(%r14,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1130 <create_index+0x20>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @create_index(i32* nocapture %0, i32 %1, i32* nocapture writeonly %2, i32 %3) {
%5 = icmp eq i32 %3, 0
br i1 %5, label %17, label %6
6: ; preds = %4
%7 = zext i32 %3 to i64
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ 0, %6 ], [ %15, %8 ]
%10 = trunc i64 %9 to i32
%11 = tail call i64 @i_to_I(i32 %10, i32 %3, i32 %1)
%12 = getelementptr inbounds i32, i32* %0, i64 %11
%13 = load i32, i32* %12
%14 = getelementptr inbounds i32, i32* %2, i64 %9
store i32 %13, i32* %14
%15 = add nuw nsw i64 %9, 1
%16 = icmp eq i64 %15, %7
br i1 %16, label %17, label %8
17: ; preds = %8, %4
ret void
}