#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*/ FloatComputeBound(float *, int const, float, float, float,
                                     float, float, int /*<<< orphan*/);
int /*<<< orphan*/ free(float *);
scalar_t__ malloc(size_t);
void run(const int M) {
  float *A_cpu;
  const int N = 576;
  const int K = M * N;
  size_t bytes = sizeof(float) * K;
  A_cpu = (float *)malloc(bytes);
  int i;
  for (i = 0; i < K; i++) {
    A_cpu[i] = (float)i / (float)(K - 1);
  }
  FloatComputeBound(A_cpu, M * N, 1.125f, 0.125f, 0.5f, 1.25f, 1.25f, 0);
  free(A_cpu);
}


x86 assembly (clang, -O0):
<run>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x240,-0x14(%rbp)
imul   $0x240,-0x4(%rbp),%eax
mov    %eax,-0x18(%rbp)
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11a6 <run+0x76>
cvtsi2ssl -0x24(%rbp),%xmm0
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
cvtsi2ss %eax,%xmm1
divss  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    116c <run+0x3c>
mov    -0x10(%rbp),%rdi
imul   $0x240,-0x4(%rbp),%esi
movss  0xe47(%rip),%xmm0
movss  0xe43(%rip),%xmm1
movss  0xe3f(%rip),%xmm2
movss  0xe3b(%rip),%xmm4
xor    %edx,%edx
movaps %xmm4,%xmm3
call   1050 <FloatComputeBound@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebp
mov    %edi,%eax
shl    $0x6,%eax
lea    (%rax,%rax,8),%r14d
movslq %r14d,%rdi
shl    $0x2,%rdi
call   1040 <malloc@plt>
mov    %rax,%rbx
test   %ebp,%ebp
jle    11f9 <run+0xc9>
lea    -0x1(%r14),%eax
cvtsi2ss %eax,%xmm0
cmp    $0x2,%r14d
mov    $0x1,%eax
cmovge %r14d,%eax
cmp    $0x4,%eax
jae    1174 <run+0x44>
xor    %ecx,%ecx
jmp    11e0 <run+0xb0>
mov    %eax,%ecx
and    $0x7fffffc0,%ecx
movaps %xmm0,%xmm1
shufps $0x0,%xmm0,%xmm1
lea    -0x4(%rcx),%rdx
shr    $0x2,%rdx
mov    %rbx,%rsi
add    $0x10,%rsi
add    $0x1,%rdx
movaps 0xe63(%rip),%xmm2
movdqa 0xe6b(%rip),%xmm3
movdqa 0xe73(%rip),%xmm4
nopl   (%rax)
cvtdq2ps %xmm2,%xmm5
divps  %xmm1,%xmm5
movups %xmm5,-0x10(%rsi)
movaps %xmm2,%xmm5
paddd  %xmm3,%xmm5
cvtdq2ps %xmm5,%xmm5
divps  %xmm1,%xmm5
movups %xmm5,(%rsi)
paddd  %xmm4,%xmm2
add    $0x20,%rsi
add    $0xfffffffffffffffe,%rdx
jne    11b0 <run+0x80>
cmp    %rax,%rcx
je     11f9 <run+0xc9>
nopl   (%rax)
xorps  %xmm1,%xmm1
cvtsi2ss %ecx,%xmm1
divss  %xmm0,%xmm1
movss  %xmm1,(%rbx,%rcx,4)
add    $0x1,%rcx
cmp    %rcx,%rax
jne    11e0 <run+0xb0>
movss  0xe2f(%rip),%xmm0
movss  0xe2b(%rip),%xmm1
movss  0xe27(%rip),%xmm2
movss  0xe23(%rip),%xmm3
mov    %rbx,%rdi
mov    %r14d,%esi
movaps %xmm3,%xmm4
xor    %edx,%edx
call   1050 <FloatComputeBound@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
define void @run(i32 %0) {
%2 = alloca i32
%3 = alloca float*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i64
%7 = alloca i32
store i32 %0, i32* %2
store i32 576, i32* %4
%8 = load i32, i32* %2
%9 = mul nsw i32 %8, 576
store i32 %9, i32* %5
%10 = load i32, i32* %5
%11 = sext i32 %10 to i64
%12 = mul i64 4, %11
store i64 %12, i64* %6
%13 = load i64, i64* %6
%14 = call i64 @malloc(i64 %13)
%15 = inttoptr i64 %14 to float*
store float* %15, float** %3
store i32 0, i32* %7
br label %16
16: ; preds = %31, %1
%17 = load i32, i32* %7
%18 = load i32, i32* %5
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %34
20: ; preds = %16
%21 = load i32, i32* %7
%22 = sitofp i32 %21 to float
%23 = load i32, i32* %5
%24 = sub nsw i32 %23, 1
%25 = sitofp i32 %24 to float
%26 = fdiv float %22, %25
%27 = load float*, float** %3
%28 = load i32, i32* %7
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds float, float* %27, i64 %29
store float %26, float* %30
br label %31
31: ; preds = %20
%32 = load i32, i32* %7
%33 = add nsw i32 %32, 1
store i32 %33, i32* %7
br label %16
34: ; preds = %16
%35 = load float*, float** %3
%36 = load i32, i32* %2
%37 = mul nsw i32 %36, 576
%38 = call i32 @FloatComputeBound(float* %35, i32 %37, float 1.125000e+00, float 1.250000e-01, float 5.000000e-01, float 1.250000e+00, float 1.250000e+00, i32 0)
%39 = load float*, float** %3
%40 = call i32 @free(float* %39)
ret void
}

LLVM IR (-O2):
define void @run(i32 %0) {
%2 = mul nsw i32 %0, 576
%3 = sext i32 %2 to i64
%4 = shl nsw i64 %3, 2
%5 = tail call i64 @malloc(i64 %4)
%6 = inttoptr i64 %5 to float*
%7 = icmp sgt i32 %0, 0
br i1 %7, label %8, label %51
8: ; preds = %1
%9 = add nsw i32 %2, -1
%10 = sitofp i32 %9 to float
%11 = call i32 @llvm.smax.i32(i32 %2, i32 1)
%12 = zext i32 %11 to i64
%13 = icmp ult i32 %11, 4
br i1 %13, label %41, label %14
14: ; preds = %8
%15 = and i64 %12, 2147483584
%16 = insertelement <4 x float> poison, float %10, i64 0
%17 = shufflevector <4 x float> %16, <4 x float> poison, <4 x i32> zeroinitializer
%18 = add nsw i64 %15, -4
%19 = lshr exact i64 %18, 2
br label %20
20: ; preds = %20, %14
%21 = phi i64 [ 0, %14 ], [ %34, %20 ]
%22 = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %14 ], [ %35, %20 ]
%23 = phi i64 [ 0, %14 ], [ %36, %20 ]
%24 = sitofp <4 x i32> %22 to <4 x float>
%25 = fdiv <4 x float> %24, %17
%26 = getelementptr inbounds float, float* %6, i64 %21
%27 = bitcast float* %26 to <4 x float>*
store <4 x float> %25, <4 x float>* %27
%28 = or i64 %21, 4
%29 = add <4 x i32> %22, <i32 4, i32 4, i32 4, i32 4>
%30 = sitofp <4 x i32> %29 to <4 x float>
%31 = fdiv <4 x float> %30, %17
%32 = getelementptr inbounds float, float* %6, i64 %28
%33 = bitcast float* %32 to <4 x float>*
store <4 x float> %31, <4 x float>* %33
%34 = add nuw i64 %21, 8
%35 = add <4 x i32> %22, <i32 8, i32 8, i32 8, i32 8>
%36 = add i64 %23, 2
%37 = or i64 %23, 1
%38 = icmp eq i64 %37, %19
br i1 %38, label %39, label %20
39: ; preds = %20
%40 = icmp eq i64 %15, %12
br i1 %40, label %51, label %41
41: ; preds = %8, %39
%42 = phi i64 [ 0, %8 ], [ %15, %39 ]
br label %43
43: ; preds = %41, %43
%44 = phi i64 [ %49, %43 ], [ %42, %41 ]
%45 = trunc i64 %44 to i32
%46 = sitofp i32 %45 to float
%47 = fdiv float %46, %10
%48 = getelementptr inbounds float, float* %6, i64 %44
store float %47, float* %48
%49 = add nuw nsw i64 %44, 1
%50 = icmp eq i64 %49, %12
br i1 %50, label %51, label %43
51: ; preds = %43, %39, %1
%52 = tail call i32 @FloatComputeBound(float* %6, i32 %2, float 1.125000e+00, float 1.250000e-01, float 5.000000e-01, float 1.250000e+00, float 1.250000e+00, i32 0)
%53 = tail call i32 @free(float* %6)
ret void
}