#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*/ io_png_write_f32(char const *, float *, int, int, int);
int /*<<< orphan*/ linear_conversion(float const *, float *, int);
int /*<<< orphan*/ xfree(float *);
float *xmalloc(int);
void printImage_LinearConversion(const float *im, int w, int h,
                                 const char *name) {
  float *imtmp = xmalloc(w * h * sizeof(float));
  linear_conversion(im, imtmp, w * h);
  for (int i = 0; i < w * h; i++) {
    imtmp[i] = 255 * imtmp[i];
  }
  io_png_write_f32(name, imtmp, w, h, 1);
  xfree(imtmp);
}


x86 assembly (clang, -O0):
<printImage_LinearConversion>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <xmalloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0xc(%rbp),%edx
imul   -0x10(%rbp),%edx
call   1050 <linear_conversion@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0xc(%rbp),%ecx
imul   -0x10(%rbp),%ecx
cmp    %ecx,%eax
jge    11cb <printImage_LinearConversion+0x8b>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movss  0xe55(%rip),%xmm0
mulss  (%rax,%rcx,4),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1189 <printImage_LinearConversion+0x49>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    $0x1,%r8d
call   1060 <io_png_write_f32@plt>
mov    -0x20(%rbp),%rdi
call   1030 <xfree@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printImage_LinearConversion>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %edx,%r15d
mov    %esi,%r12d
mov    %rdi,%r13
mov    %edx,%ebp
imul   %esi,%ebp
lea    0x0(,%rbp,4),%edi
call   1040 <xmalloc@plt>
mov    %rax,%rbx
mov    %r13,%rdi
mov    %rax,%rsi
mov    %ebp,%edx
call   1050 <linear_conversion@plt>
test   %ebp,%ebp
jle    1247 <printImage_LinearConversion+0x107>
mov    %ebp,%eax
cmp    $0x8,%ebp
jae    118e <printImage_LinearConversion+0x4e>
xor    %ecx,%ecx
jmp    1226 <printImage_LinearConversion+0xe6>
mov    %eax,%ecx
and    $0xfffffff8,%ecx
lea    -0x8(%rcx),%rdx
mov    %rdx,%rsi
shr    $0x3,%rsi
add    $0x1,%rsi
test   %rdx,%rdx
je     1274 <printImage_LinearConversion+0x134>
mov    %rsi,%rdi
and    $0xfffffffffffffffe,%rdi
xor    %edx,%edx
movaps 0xe45(%rip),%xmm0
nopl   0x0(%rax,%rax,1)
movups (%rbx,%rdx,4),%xmm1
movups 0x10(%rbx,%rdx,4),%xmm2
movups 0x20(%rbx,%rdx,4),%xmm3
movups 0x30(%rbx,%rdx,4),%xmm4
mulps  %xmm0,%xmm1
mulps  %xmm0,%xmm2
movups %xmm1,(%rbx,%rdx,4)
movups %xmm2,0x10(%rbx,%rdx,4)
mulps  %xmm0,%xmm3
mulps  %xmm0,%xmm4
movups %xmm3,0x20(%rbx,%rdx,4)
movups %xmm4,0x30(%rbx,%rdx,4)
add    $0x10,%rdx
add    $0xfffffffffffffffe,%rdi
jne    11c0 <printImage_LinearConversion+0x80>
test   $0x1,%sil
je     1221 <printImage_LinearConversion+0xe1>
movups (%rbx,%rdx,4),%xmm0
movups 0x10(%rbx,%rdx,4),%xmm1
movaps 0xdee(%rip),%xmm2
mulps  %xmm2,%xmm0
mulps  %xmm2,%xmm1
movups %xmm0,(%rbx,%rdx,4)
movups %xmm1,0x10(%rbx,%rdx,4)
cmp    %rax,%rcx
je     1247 <printImage_LinearConversion+0x107>
movss  0xde2(%rip),%xmm0
xchg   %ax,%ax
movss  (%rbx,%rcx,4),%xmm1
mulss  %xmm0,%xmm1
movss  %xmm1,(%rbx,%rcx,4)
add    $0x1,%rcx
cmp    %rcx,%rax
jne    1230 <printImage_LinearConversion+0xf0>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r12d,%edx
mov    %r15d,%ecx
mov    $0x1,%r8d
call   1060 <io_png_write_f32@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <xfree@plt>
xor    %edx,%edx
test   $0x1,%sil
jne    1202 <printImage_LinearConversion+0xc2>
jmp    1221 <printImage_LinearConversion+0xe1>

LLVM IR (-O0):
define void @printImage_LinearConversion(float* %0, i32 %1, i32 %2, i8* %3) {
%5 = alloca float*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca float*
%10 = alloca i32
store float* %0, float** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i8* %3, i8** %8
%11 = load i32, i32* %6
%12 = load i32, i32* %7
%13 = mul nsw i32 %11, %12
%14 = sext i32 %13 to i64
%15 = mul i64 %14, 4
%16 = trunc i64 %15 to i32
%17 = call float* @xmalloc(i32 %16)
store float* %17, float** %9
%18 = load float*, float** %5
%19 = load float*, float** %9
%20 = load i32, i32* %6
%21 = load i32, i32* %7
%22 = mul nsw i32 %20, %21
%23 = call i32 @linear_conversion(float* %18, float* %19, i32 %22)
store i32 0, i32* %10
br label %24
24: ; preds = %41, %4
%25 = load i32, i32* %10
%26 = load i32, i32* %6
%27 = load i32, i32* %7
%28 = mul nsw i32 %26, %27
%29 = icmp slt i32 %25, %28
br i1 %29, label %30, label %44
30: ; preds = %24
%31 = load float*, float** %9
%32 = load i32, i32* %10
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds float, float* %31, i64 %33
%35 = load float, float* %34
%36 = fmul float 2.550000e+02, %35
%37 = load float*, float** %9
%38 = load i32, i32* %10
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds float, float* %37, i64 %39
store float %36, float* %40
br label %41
41: ; preds = %30
%42 = load i32, i32* %10
%43 = add nsw i32 %42, 1
store i32 %43, i32* %10
br label %24
44: ; preds = %24
%45 = load i8*, i8** %8
%46 = load float*, float** %9
%47 = load i32, i32* %6
%48 = load i32, i32* %7
%49 = call i32 @io_png_write_f32(i8* %45, float* %46, i32 %47, i32 %48, i32 1)
%50 = load float*, float** %9
%51 = call i32 @xfree(float* %50)
ret void
}

LLVM IR (-O2):
define void @printImage_LinearConversion(float* %0, i32 %1, i32 %2, i8* %3) {
%5 = mul nsw i32 %2, %1
%6 = shl i32 %5, 2
%7 = tail call float* @xmalloc(i32 %6)
%8 = tail call i32 @linear_conversion(float* %0, float* %7, i32 %5)
%9 = icmp sgt i32 %5, 0
br i1 %9, label %10, label %67
10: ; preds = %4
%11 = zext i32 %5 to i64
%12 = icmp ult i32 %5, 8
br i1 %12, label %65, label %13
13: ; preds = %10
%14 = and i64 %11, 4294967288
%15 = add nsw i64 %14, -8
%16 = lshr exact i64 %15, 3
%17 = add nuw nsw i64 %16, 1
%18 = and i64 %17, 1
%19 = icmp eq i64 %15, 0
br i1 %19, label %49, label %20
20: ; preds = %13
%21 = and i64 %17, 4611686018427387902
br label %22
22: ; preds = %22, %20
%23 = phi i64 [ 0, %20 ], [ %46, %22 ]
%24 = phi i64 [ 0, %20 ], [ %47, %22 ]
%25 = getelementptr inbounds float, float* %7, i64 %23
%26 = bitcast float* %25 to <4 x float>*
%27 = load <4 x float>, <4 x float>* %26
%28 = getelementptr inbounds float, float* %25, i64 4
%29 = bitcast float* %28 to <4 x float>*
%30 = load <4 x float>, <4 x float>* %29
%31 = fmul <4 x float> %27, <float 2.550000e+02, float 2.550000e+02, float 2.550000e+02, float 2.550000e+02>
%32 = fmul <4 x float> %30, <float 2.550000e+02, float 2.550000e+02, float 2.550000e+02, float 2.550000e+02>
%33 = bitcast float* %25 to <4 x float>*
store <4 x float> %31, <4 x float>* %33
%34 = bitcast float* %28 to <4 x float>*
store <4 x float> %32, <4 x float>* %34
%35 = or i64 %23, 8
%36 = getelementptr inbounds float, float* %7, i64 %35
%37 = bitcast float* %36 to <4 x float>*
%38 = load <4 x float>, <4 x float>* %37
%39 = getelementptr inbounds float, float* %36, i64 4
%40 = bitcast float* %39 to <4 x float>*
%41 = load <4 x float>, <4 x float>* %40
%42 = fmul <4 x float> %38, <float 2.550000e+02, float 2.550000e+02, float 2.550000e+02, float 2.550000e+02>
%43 = fmul <4 x float> %41, <float 2.550000e+02, float 2.550000e+02, float 2.550000e+02, float 2.550000e+02>
%44 = bitcast float* %36 to <4 x float>*
store <4 x float> %42, <4 x float>* %44
%45 = bitcast float* %39 to <4 x float>*
store <4 x float> %43, <4 x float>* %45
%46 = add nuw i64 %23, 16
%47 = add i64 %24, 2
%48 = icmp eq i64 %47, %21
br i1 %48, label %49, label %22
49: ; preds = %22, %13
%50 = phi i64 [ 0, %13 ], [ %46, %22 ]
%51 = icmp eq i64 %18, 0
br i1 %51, label %63, label %52
52: ; preds = %49
%53 = getelementptr inbounds float, float* %7, i64 %50
%54 = bitcast float* %53 to <4 x float>*
%55 = load <4 x float>, <4 x float>* %54
%56 = getelementptr inbounds float, float* %53, i64 4
%57 = bitcast float* %56 to <4 x float>*
%58 = load <4 x float>, <4 x float>* %57
%59 = fmul <4 x float> %55, <float 2.550000e+02, float 2.550000e+02, float 2.550000e+02, float 2.550000e+02>
%60 = fmul <4 x float> %58, <float 2.550000e+02, float 2.550000e+02, float 2.550000e+02, float 2.550000e+02>
%61 = bitcast float* %53 to <4 x float>*
store <4 x float> %59, <4 x float>* %61
%62 = bitcast float* %56 to <4 x float>*
store <4 x float> %60, <4 x float>* %62
br label %63
63: ; preds = %49, %52
%64 = icmp eq i64 %14, %11
br i1 %64, label %67, label %65
65: ; preds = %10, %63
%66 = phi i64 [ 0, %10 ], [ %14, %63 ]
br label %70
67: ; preds = %70, %63, %4
%68 = tail call i32 @io_png_write_f32(i8* %3, float* %7, i32 %1, i32 %2, i32 1)
%69 = tail call i32 @xfree(float* %7)
ret void
70: ; preds = %65, %70
%71 = phi i64 [ %75, %70 ], [ %66, %65 ]
%72 = getelementptr inbounds float, float* %7, i64 %71
%73 = load float, float* %72
%74 = fmul float %73, 2.550000e+02
store float %74, float* %72
%75 = add nuw nsw i64 %71, 1
%76 = icmp eq i64 %75, %11
br i1 %76, label %67, label %70
}