#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 */
unsigned char func(int, int, int);
scalar_t__ malloc(int);
unsigned char *create_data() {
  unsigned char *data =
      (unsigned char *)malloc(sizeof(unsigned char) * 512 * 512 * 512);
  for (int i = 0; i < 512; i++) {
    for (int j = 0; j < 512; j++) {
      for (int k = 0; k < 512; k++) {
        data[i * 512 * 512 + j * 512 + k] = func(k, j, i);
      }
    }
  }
  return data;
}


x86 assembly (clang, -O0):
<create_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x8000000,%edi
call   1040 <malloc@plt>
mov    %rax,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x200,-0xc(%rbp)
jge    11d4 <create_data+0xb4>
movl   $0x0,-0x10(%rbp)
cmpl   $0x200,-0x10(%rbp)
jge    11c1 <create_data+0xa1>
movl   $0x0,-0x14(%rbp)
cmpl   $0x200,-0x14(%rbp)
jge    11ae <create_data+0x8e>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1030 <func@plt>
mov    %al,%dl
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
shl    $0x9,%ecx
shl    $0x9,%ecx
mov    -0x10(%rbp),%esi
shl    $0x9,%esi
add    %esi,%ecx
add    -0x14(%rbp),%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1165 <create_data+0x45>
jmp    11b3 <create_data+0x93>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1151 <create_data+0x31>
jmp    11c6 <create_data+0xa6>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    113d <create_data+0x1d>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_data>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x8000000,%edi
call   1040 <malloc@plt>
mov    %rax,%r14
xor    %r15d,%r15d
mov    %rax,%r13
xchg   %ax,%ax
mov    %r13,%rbp
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebx,%edi
mov    %r12d,%esi
mov    %r15d,%edx
call   1030 <func@plt>
mov    %al,0x0(%rbp,%rbx,1)
add    $0x1,%rbx
cmp    $0x200,%rbx
jne    1160 <create_data+0x40>
add    $0x1,%r12
add    $0x200,%rbp
cmp    $0x200,%r12
jne    1150 <create_data+0x30>
add    $0x1,%r15
add    $0x40000,%r13
cmp    $0x200,%r15
jne    1140 <create_data+0x20>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @create_data() {
%1 = alloca i8*
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = call i64 @malloc(i32 134217728)
%6 = inttoptr i64 %5 to i8*
store i8* %6, i8** %1
store i32 0, i32* %2
br label %7
7: ; preds = %42, %0
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 512
br i1 %9, label %10, label %45
10: ; preds = %7
store i32 0, i32* %3
br label %11
11: ; preds = %38, %10
%12 = load i32, i32* %3
%13 = icmp slt i32 %12, 512
br i1 %13, label %14, label %41
14: ; preds = %11
store i32 0, i32* %4
br label %15
15: ; preds = %34, %14
%16 = load i32, i32* %4
%17 = icmp slt i32 %16, 512
br i1 %17, label %18, label %37
18: ; preds = %15
%19 = load i32, i32* %4
%20 = load i32, i32* %3
%21 = load i32, i32* %2
%22 = call zeroext i8 @func(i32 %19, i32 %20, i32 %21)
%23 = load i8*, i8** %1
%24 = load i32, i32* %2
%25 = mul nsw i32 %24, 512
%26 = mul nsw i32 %25, 512
%27 = load i32, i32* %3
%28 = mul nsw i32 %27, 512
%29 = add nsw i32 %26, %28
%30 = load i32, i32* %4
%31 = add nsw i32 %29, %30
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %23, i64 %32
store i8 %22, i8* %33
br label %34
34: ; preds = %18
%35 = load i32, i32* %4
%36 = add nsw i32 %35, 1
store i32 %36, i32* %4
br label %15
37: ; preds = %15
br label %38
38: ; preds = %37
%39 = load i32, i32* %3
%40 = add nsw i32 %39, 1
store i32 %40, i32* %3
br label %11
41: ; preds = %11
br label %42
42: ; preds = %41
%43 = load i32, i32* %2
%44 = add nsw i32 %43, 1
store i32 %44, i32* %2
br label %7
45: ; preds = %7
%46 = load i8*, i8** %1
ret i8* %46
}

LLVM IR (-O2):
define i8* @create_data() {
%1 = tail call i64 @malloc(i32 134217728)
%2 = inttoptr i64 %1 to i8*
br label %3
3: ; preds = %0, %13
%4 = phi i64 [ 0, %0 ], [ %14, %13 ]
%5 = shl nsw i64 %4, 18
%6 = trunc i64 %4 to i32
br label %8
7: ; preds = %13
ret i8* %2
8: ; preds = %3, %16
%9 = phi i64 [ 0, %3 ], [ %17, %16 ]
%10 = shl nsw i64 %9, 9
%11 = add nuw nsw i64 %10, %5
%12 = trunc i64 %9 to i32
br label %19
13: ; preds = %16
%14 = add nuw nsw i64 %4, 1
%15 = icmp eq i64 %14, 512
br i1 %15, label %7, label %3
16: ; preds = %19
%17 = add nuw nsw i64 %9, 1
%18 = icmp eq i64 %17, 512
br i1 %18, label %13, label %8
19: ; preds = %8, %19
%20 = phi i64 [ 0, %8 ], [ %25, %19 ]
%21 = trunc i64 %20 to i32
%22 = tail call zeroext i8 @func(i32 %21, i32 %12, i32 %6)
%23 = add nuw nsw i64 %11, %20
%24 = getelementptr inbounds i8, i8* %2, i64 %23
store i8 %22, i8* %24
%25 = add nuw nsw i64 %20, 1
%26 = icmp eq i64 %25, 512
br i1 %26, label %16, label %19
}