#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 fabs(float);
int /*<<< orphan*/ fail(char *);
int vector_colorsign(float *r, float *a, int n) {
  if (n != 1)
    fail("vcolorsign needs a scalar");
  r[0] = fabs(*a) * (*a < 0);
  r[1] = fabs(*a) * (*a > 0);
  r[2] = 0;
  return 3;
}


x86 assembly (clang, -O0):
<vector_colorsign>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
je     1149 <vector_colorsign+0x29>
lea    0xebc(%rip),%rdi
call   1030 <fail@plt>
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
call   1040 <fabs@plt>
mov    -0x10(%rbp),%rcx
xorps  %xmm0,%xmm0
ucomiss (%rcx),%xmm0
seta   %cl
and    $0x1,%cl
movzbl %cl,%ecx
imul   %ecx,%eax
cvtsi2ss %eax,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
call   1040 <fabs@plt>
mov    -0x10(%rbp),%rcx
movss  (%rcx),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
seta   %cl
and    $0x1,%cl
movzbl %cl,%ecx
imul   %ecx,%eax
cvtsi2ss %eax,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x4(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x8(%rax)
mov    $0x3,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vector_colorsign>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
cmp    $0x1,%edx
je     113b <vector_colorsign+0x1b>
lea    0xeca(%rip),%rdi
call   1030 <fail@plt>
movss  (%rbx),%xmm0
call   1040 <fabs@plt>
movss  (%rbx),%xmm0
cvtsi2ss %eax,%xmm1
xorps  %xmm2,%xmm2
cmpltss %xmm2,%xmm0
andps  %xmm1,%xmm0
movss  %xmm0,(%r14)
movss  (%rbx),%xmm0
call   1040 <fabs@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
xorps  %xmm1,%xmm1
cmpltss (%rbx),%xmm1
andps  %xmm0,%xmm1
movss  %xmm1,0x4(%r14)
movl   $0x0,0x8(%r14)
mov    $0x3,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [26 x i8] c"vcolorsign needs a scalar\00"
define i32 @vector_colorsign(float* %0, float* %1, i32 %2) {
%4 = alloca float*
%5 = alloca float*
%6 = alloca i32
store float* %0, float** %4
store float* %1, float** %5
store i32 %2, i32* %6
%7 = load i32, i32* %6
%8 = icmp ne i32 %7, 1
br i1 %8, label %9, label %11
9: ; preds = %3
%10 = call i32 @fail(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %3
%12 = load float*, float** %5
%13 = load float, float* %12
%14 = call i32 @fabs(float %13)
%15 = load float*, float** %5
%16 = load float, float* %15
%17 = fcmp olt float %16, 0.000000e+00
%18 = zext i1 %17 to i32
%19 = mul nsw i32 %14, %18
%20 = sitofp i32 %19 to float
%21 = load float*, float** %4
%22 = getelementptr inbounds float, float* %21, i64 0
store float %20, float* %22
%23 = load float*, float** %5
%24 = load float, float* %23
%25 = call i32 @fabs(float %24)
%26 = load float*, float** %5
%27 = load float, float* %26
%28 = fcmp ogt float %27, 0.000000e+00
%29 = zext i1 %28 to i32
%30 = mul nsw i32 %25, %29
%31 = sitofp i32 %30 to float
%32 = load float*, float** %4
%33 = getelementptr inbounds float, float* %32, i64 1
store float %31, float* %33
%34 = load float*, float** %4
%35 = getelementptr inbounds float, float* %34, i64 2
store float 0.000000e+00, float* %35
ret i32 3
}

LLVM IR (-O2):
@.str = [26 x i8] c"vcolorsign needs a scalar\00"
define i32 @vector_colorsign(float* nocapture writeonly %0, float* nocapture %1, i32 %2) {
%4 = icmp eq i32 %2, 1
br i1 %4, label %7, label %5
5: ; preds = %3
%6 = tail call i32 @fail(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %5, %3
%8 = load float, float* %1
%9 = tail call i32 @fabs(float %8)
%10 = load float, float* %1
%11 = fcmp olt float %10, 0.000000e+00
%12 = sitofp i32 %9 to float
%13 = select i1 %11, float %12, float 0.000000e+00
store float %13, float* %0
%14 = load float, float* %1
%15 = tail call i32 @fabs(float %14)
%16 = load float, float* %1
%17 = fcmp ogt float %16, 0.000000e+00
%18 = sitofp i32 %15 to float
%19 = select i1 %17, float %18, float 0.000000e+00
%20 = getelementptr inbounds float, float* %0, i64 1
store float %19, float* %20
%21 = getelementptr inbounds float, float* %0, i64 2
store float 0.000000e+00, float* %21
ret i32 3
}