#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 */
typedef scalar_t__ uint8_t;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
void clip_and_convert_channels(uint8_t channel[4], const float bins[4]) {
  int i;
  uint8_t tmp;
  float out;
  for (i = 0; i < 4; i++) {
    out = bins[i];
    if (out > 1.0)
      out = 1.0;
    channel[i] = (uint8_t)(255 * out);
    ;
  }
  fprintf(stderr, "\n");
  tmp = channel[0];
  channel[0] = channel[2];
  channel[2] = tmp;
}


x86 assembly (clang, -O0):
<clip_and_convert_channels>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jge    1197 <clip_and_convert_channels+0x87>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xeac(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    116b <clip_and_convert_channels+0x5b>
movss  0xea2(%rip),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  0xe99(%rip),%xmm0
mulss  -0x24(%rbp),%xmm0
cvttss2si %xmm0,%rdx
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1127 <clip_and_convert_channels+0x17>
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
lea    0xe69(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x10(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clip_and_convert_channels>:
push   %rbx
movss  0xee7(%rip),%xmm0
movaps %xmm0,%xmm1
minss  (%rsi),%xmm1
movss  0xedc(%rip),%xmm2
mulss  %xmm2,%xmm1
cvttss2si %xmm1,%rax
mov    %rdi,%rbx
mov    %rax,(%rdi)
movaps %xmm0,%xmm1
minss  0x4(%rsi),%xmm1
mulss  %xmm2,%xmm1
cvttss2si %xmm1,%rax
mov    %rax,0x8(%rdi)
movaps %xmm0,%xmm1
minss  0x8(%rsi),%xmm1
mulss  %xmm2,%xmm1
cvttss2si %xmm1,%rax
mov    %rax,0x10(%rdi)
minss  0xc(%rsi),%xmm0
mulss  %xmm2,%xmm0
cvttss2si %xmm0,%rax
mov    %rax,0x18(%rdi)
mov    0x2e66(%rip),%rax
mov    (%rax),%edi
lea    0xe85(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%rax
mov    0x10(%rbx),%rcx
mov    %rcx,(%rbx)
mov    %rax,0x10(%rbx)
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [2 x i8] c"\0A\00"
define void @clip_and_convert_channels(i64* %0, float* %1) {
%3 = alloca i64*
%4 = alloca float*
%5 = alloca i32
%6 = alloca i64
%7 = alloca float
store i64* %0, i64** %3
store float* %1, float** %4
store i32 0, i32* %5
br label %8
8: ; preds = %29, %2
%9 = load i32, i32* %5
%10 = icmp slt i32 %9, 4
br i1 %10, label %11, label %32
11: ; preds = %8
%12 = load float*, float** %4
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds float, float* %12, i64 %14
%16 = load float, float* %15
store float %16, float* %7
%17 = load float, float* %7
%18 = fpext float %17 to double
%19 = fcmp ogt double %18, 1.000000e+00
br i1 %19, label %20, label %21
20: ; preds = %11
store float 1.000000e+00, float* %7
br label %21
21: ; preds = %20, %11
%22 = load float, float* %7
%23 = fmul float 2.550000e+02, %22
%24 = fptosi float %23 to i64
%25 = load i64*, i64** %3
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i64, i64* %25, i64 %27
store i64 %24, i64* %28
br label %29
29: ; preds = %21
%30 = load i32, i32* %5
%31 = add nsw i32 %30, 1
store i32 %31, i32* %5
br label %8
32: ; preds = %8
%33 = load i32, i32* @stderr
%34 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%35 = load i64*, i64** %3
%36 = getelementptr inbounds i64, i64* %35, i64 0
%37 = load i64, i64* %36
store i64 %37, i64* %6
%38 = load i64*, i64** %3
%39 = getelementptr inbounds i64, i64* %38, i64 2
%40 = load i64, i64* %39
%41 = load i64*, i64** %3
%42 = getelementptr inbounds i64, i64* %41, i64 0
store i64 %40, i64* %42
%43 = load i64, i64* %6
%44 = load i64*, i64** %3
%45 = getelementptr inbounds i64, i64* %44, i64 2
store i64 %43, i64* %45
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [2 x i8] c"\0A\00"
define void @clip_and_convert_channels(i64* nocapture %0, float* nocapture %1) {
%3 = load float, float* %1
%4 = fcmp ogt float %3, 1.000000e+00
%5 = select i1 %4, float 1.000000e+00, float %3
%6 = fmul float %5, 2.550000e+02
%7 = fptosi float %6 to i64
store i64 %7, i64* %0
%8 = getelementptr inbounds float, float* %1, i64 1
%9 = load float, float* %8
%10 = fcmp ogt float %9, 1.000000e+00
%11 = select i1 %10, float 1.000000e+00, float %9
%12 = fmul float %11, 2.550000e+02
%13 = fptosi float %12 to i64
%14 = getelementptr inbounds i64, i64* %0, i64 1
store i64 %13, i64* %14
%15 = getelementptr inbounds float, float* %1, i64 2
%16 = load float, float* %15
%17 = fcmp ogt float %16, 1.000000e+00
%18 = select i1 %17, float 1.000000e+00, float %16
%19 = fmul float %18, 2.550000e+02
%20 = fptosi float %19 to i64
%21 = getelementptr inbounds i64, i64* %0, i64 2
store i64 %20, i64* %21
%22 = getelementptr inbounds float, float* %1, i64 3
%23 = load float, float* %22
%24 = fcmp ogt float %23, 1.000000e+00
%25 = select i1 %24, float 1.000000e+00, float %23
%26 = fmul float %25, 2.550000e+02
%27 = fptosi float %26 to i64
%28 = getelementptr inbounds i64, i64* %0, i64 3
store i64 %27, i64* %28
%29 = load i32, i32* @stderr
%30 = tail call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%31 = load i64, i64* %0
%32 = load i64, i64* %21
store i64 %32, i64* %0
store i64 %31, i64* %21
ret void
}