#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 */
struct img_pixmap {
  int dummy;
};

/* Variables and functions */
scalar_t__ img_is_float(struct img_pixmap *);
int /*<<< orphan*/ img_setpixel(struct img_pixmap *, int, int, float *);
int /*<<< orphan*/ img_setpixel4i(struct img_pixmap *, int, int, int, int, int,
                                  int);
void img_setpixel4f(struct img_pixmap *img, int x, int y, float r, float g,
                    float b, float a) {
  if (img_is_float(img)) {
    float pixel[4];
    pixel[0] = r;
    pixel[1] = g;
    pixel[2] = b;
    pixel[3] = a;
    img_setpixel(img, x, y, pixel);
  } else {
    img_setpixel4i(img, x, y, (int)(r * 255.0), (int)(g * 255.0),
                   (int)(b * 255.0), (int)(a * 255.0));
  }
}


x86 assembly (clang, -O0):
<img_setpixel4f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movss  %xmm0,-0x14(%rbp)
movss  %xmm1,-0x18(%rbp)
movss  %xmm2,-0x1c(%rbp)
movss  %xmm3,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <img_is_float@plt>
cmp    $0x0,%rax
je     11a9 <img_setpixel4f+0x79>
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    -0x30(%rbp),%rcx
call   1050 <img_setpixel@plt>
jmp    1221 <img_setpixel4f+0xf1>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe3c(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ecx
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe23(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%r8d
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe09(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%r9d
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdef(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,(%rsp)
call   1030 <img_setpixel4i@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<img_setpixel4f>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
movss  %xmm3,0x1c(%rsp)
movss  %xmm2,0x18(%rsp)
movss  %xmm1,0x14(%rsp)
movss  %xmm0,0x10(%rsp)
mov    %edx,%r14d
mov    %esi,%ebp
mov    %rdi,%rbx
call   1040 <img_is_float@plt>
test   %rax,%rax
je     11a6 <img_setpixel4f+0x76>
movss  0x10(%rsp),%xmm0
movss  %xmm0,0x20(%rsp)
movss  0x14(%rsp),%xmm0
movss  %xmm0,0x24(%rsp)
movss  0x18(%rsp),%xmm0
movss  %xmm0,0x28(%rsp)
movss  0x1c(%rsp),%xmm0
movss  %xmm0,0x2c(%rsp)
lea    0x20(%rsp),%rcx
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14d,%edx
call   1050 <img_setpixel@plt>
jmp    1208 <img_setpixel4f+0xd8>
movss  0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe48(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ecx
movss  0x14(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%r8d
movss  0x18(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%r9d
movss  0x1c(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,(%rsp)
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14d,%edx
call   1030 <img_setpixel4i@plt>
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.img_pixmap = type { i32 }
define void @img_setpixel4f(%struct.img_pixmap* %0, i32 %1, i32 %2, float %3, float %4, float %5, float %6) {
%8 = alloca %struct.img_pixmap*
%9 = alloca i32
%10 = alloca i32
%11 = alloca float
%12 = alloca float
%13 = alloca float
%14 = alloca float
%15 = alloca [4 x float]
store %struct.img_pixmap* %0, %struct.img_pixmap** %8
store i32 %1, i32* %9
store i32 %2, i32* %10
store float %3, float* %11
store float %4, float* %12
store float %5, float* %13
store float %6, float* %14
%16 = load %struct.img_pixmap*, %struct.img_pixmap** %8
%17 = call i64 @img_is_float(%struct.img_pixmap* %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %33
19: ; preds = %7
%20 = load float, float* %11
%21 = getelementptr inbounds [4 x float], [4 x float]* %15, i64 0, i64 0
store float %20, float* %21
%22 = load float, float* %12
%23 = getelementptr inbounds [4 x float], [4 x float]* %15, i64 0, i64 1
store float %22, float* %23
%24 = load float, float* %13
%25 = getelementptr inbounds [4 x float], [4 x float]* %15, i64 0, i64 2
store float %24, float* %25
%26 = load float, float* %14
%27 = getelementptr inbounds [4 x float], [4 x float]* %15, i64 0, i64 3
store float %26, float* %27
%28 = load %struct.img_pixmap*, %struct.img_pixmap** %8
%29 = load i32, i32* %9
%30 = load i32, i32* %10
%31 = getelementptr inbounds [4 x float], [4 x float]* %15, i64 0, i64 0
%32 = call i32 @img_setpixel(%struct.img_pixmap* %28, i32 %29, i32 %30, float* %31)
br label %54
33: ; preds = %7
%34 = load %struct.img_pixmap*, %struct.img_pixmap** %8
%35 = load i32, i32* %9
%36 = load i32, i32* %10
%37 = load float, float* %11
%38 = fpext float %37 to double
%39 = fmul double %38, 2.550000e+02
%40 = fptosi double %39 to i32
%41 = load float, float* %12
%42 = fpext float %41 to double
%43 = fmul double %42, 2.550000e+02
%44 = fptosi double %43 to i32
%45 = load float, float* %13
%46 = fpext float %45 to double
%47 = fmul double %46, 2.550000e+02
%48 = fptosi double %47 to i32
%49 = load float, float* %14
%50 = fpext float %49 to double
%51 = fmul double %50, 2.550000e+02
%52 = fptosi double %51 to i32
%53 = call i32 @img_setpixel4i(%struct.img_pixmap* %34, i32 %35, i32 %36, i32 %40, i32 %44, i32 %48, i32 %52)
br label %54
54: ; preds = %33, %19
ret void
}

LLVM IR (-O2):
%struct.img_pixmap = type { i32 }
define void @img_setpixel4f(%struct.img_pixmap* %0, i32 %1, i32 %2, float %3, float %4, float %5, float %6) {
%8 = alloca [4 x float]
%9 = tail call i64 @img_is_float(%struct.img_pixmap* %0)
%10 = icmp eq i64 %9, 0
br i1 %10, label %18, label %11
11: ; preds = %7
%12 = bitcast [4 x float]* %8 to i8*
%13 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 0
store float %3, float* %13
%14 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 1
store float %4, float* %14
%15 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 2
store float %5, float* %15
%16 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 3
store float %6, float* %16
%17 = call i32 @img_setpixel(%struct.img_pixmap* %0, i32 %1, i32 %2, float* %13)
br label %32
18: ; preds = %7
%19 = fpext float %3 to double
%20 = fmul double %19, 2.550000e+02
%21 = fptosi double %20 to i32
%22 = fpext float %4 to double
%23 = fmul double %22, 2.550000e+02
%24 = fptosi double %23 to i32
%25 = fpext float %5 to double
%26 = fmul double %25, 2.550000e+02
%27 = fptosi double %26 to i32
%28 = fpext float %6 to double
%29 = fmul double %28, 2.550000e+02
%30 = fptosi double %29 to i32
%31 = tail call i32 @img_setpixel4i(%struct.img_pixmap* %0, i32 %1, i32 %2, i32 %21, i32 %24, i32 %27, i32 %30)
br label %32
32: ; preds = %18, %11
ret void
}