#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*/ dump(float *);
int /*<<< orphan*/ free(float *);
int /*<<< orphan*/ kernel(float *, int);
scalar_t__ malloc(int);
int main(int argc, char *argv[]) {
  float *g;
  size_t nelms = 32 * 32 * 32;
  g = (float *)malloc(sizeof(float) * nelms);
  int i;
  for (i = 0; i < (int)nelms; i++) {
    g[i] = i;
  }
  kernel(g, 0);
  kernel(g, 1);
  dump(g);
  free(g);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x8000,-0x20(%rbp)
mov    -0x20(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x20(%rbp),%rcx
cmp    %ecx,%eax
jge    11a7 <main+0x67>
cvtsi2ssl -0x24(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1178 <main+0x38>
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
call   1040 <kernel@plt>
mov    -0x18(%rbp),%rdi
mov    $0x1,%esi
call   1040 <kernel@plt>
mov    -0x18(%rbp),%rdi
call   1050 <dump@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x20000,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
movdqa 0xeaa(%rip),%xmm0
mov    $0xc,%eax
movdqa 0xead(%rip),%xmm1
movdqa 0xeb5(%rip),%xmm2
movdqa 0xebd(%rip),%xmm3
movdqa 0xec5(%rip),%xmm4
nopl   0x0(%rax,%rax,1)
movdqa %xmm0,%xmm5
paddd  %xmm1,%xmm5
cvtdq2ps %xmm0,%xmm6
cvtdq2ps %xmm5,%xmm5
movups %xmm6,-0x30(%rbx,%rax,4)
movups %xmm5,-0x20(%rbx,%rax,4)
movdqa %xmm0,%xmm5
paddd  %xmm2,%xmm5
movdqa %xmm0,%xmm6
paddd  %xmm3,%xmm6
cvtdq2ps %xmm5,%xmm5
cvtdq2ps %xmm6,%xmm6
movups %xmm5,-0x10(%rbx,%rax,4)
movups %xmm6,(%rbx,%rax,4)
paddd  %xmm4,%xmm0
add    $0x10,%rax
cmp    $0x800c,%rax
jne    1180 <main+0x40>
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <kernel@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1040 <kernel@plt>
mov    %rbx,%rdi
call   1050 <dump@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca float*
%7 = alloca i64
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 32768, i64* %7
%9 = load i64, i64* %7
%10 = mul i64 4, %9
%11 = trunc i64 %10 to i32
%12 = call i64 @malloc(i32 %11)
%13 = inttoptr i64 %12 to float*
store float* %13, float** %6
store i32 0, i32* %8
br label %14
14: ; preds = %26, %2
%15 = load i32, i32* %8
%16 = load i64, i64* %7
%17 = trunc i64 %16 to i32
%18 = icmp slt i32 %15, %17
br i1 %18, label %19, label %29
19: ; preds = %14
%20 = load i32, i32* %8
%21 = sitofp i32 %20 to float
%22 = load float*, float** %6
%23 = load i32, i32* %8
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds float, float* %22, i64 %24
store float %21, float* %25
br label %26
26: ; preds = %19
%27 = load i32, i32* %8
%28 = add nsw i32 %27, 1
store i32 %28, i32* %8
br label %14
29: ; preds = %14
%30 = load float*, float** %6
%31 = call i32 @kernel(float* %30, i32 0)
%32 = load float*, float** %6
%33 = call i32 @kernel(float* %32, i32 1)
%34 = load float*, float** %6
%35 = call i32 @dump(float* %34)
%36 = load float*, float** %6
%37 = call i32 @free(float* %36)
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i64 @malloc(i32 131072)
%4 = inttoptr i64 %3 to float*
br label %5
5: ; preds = %5, %2
%6 = phi i64 [ 0, %2 ], [ %24, %5 ]
%7 = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %2 ], [ %25, %5 ]
%8 = add <4 x i32> %7, <i32 4, i32 4, i32 4, i32 4>
%9 = sitofp <4 x i32> %7 to <4 x float>
%10 = sitofp <4 x i32> %8 to <4 x float>
%11 = getelementptr inbounds float, float* %4, i64 %6
%12 = bitcast float* %11 to <4 x float>*
store <4 x float> %9, <4 x float>* %12
%13 = getelementptr inbounds float, float* %11, i64 4
%14 = bitcast float* %13 to <4 x float>*
store <4 x float> %10, <4 x float>* %14
%15 = or i64 %6, 8
%16 = add <4 x i32> %7, <i32 8, i32 8, i32 8, i32 8>
%17 = add <4 x i32> %7, <i32 12, i32 12, i32 12, i32 12>
%18 = sitofp <4 x i32> %16 to <4 x float>
%19 = sitofp <4 x i32> %17 to <4 x float>
%20 = getelementptr inbounds float, float* %4, i64 %15
%21 = bitcast float* %20 to <4 x float>*
store <4 x float> %18, <4 x float>* %21
%22 = getelementptr inbounds float, float* %20, i64 4
%23 = bitcast float* %22 to <4 x float>*
store <4 x float> %19, <4 x float>* %23
%24 = add nuw nsw i64 %6, 16
%25 = add <4 x i32> %7, <i32 16, i32 16, i32 16, i32 16>
%26 = icmp eq i64 %24, 32768
br i1 %26, label %27, label %5
27: ; preds = %5
%28 = tail call i32 @kernel(float* %4, i32 0)
%29 = tail call i32 @kernel(float* %4, i32 1)
%30 = tail call i32 @dump(float* %4)
%31 = tail call i32 @free(float* %4)
ret i32 0
}