#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 int /*<<< orphan*/ vec;
struct mtl_buffer {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ wf_parse_vector(double *, int, int /*<<< orphan*/ *);
int parse_color(void *field, struct mtl_buffer *buffer, FILE *fp) {
  double vec[3];
  size_t i;
  float(*p)[3];
  (void)buffer;
  if (wf_parse_vector(vec, 3, fp)) {
    return -1;
  }
  for (i = 0, p = field; i < (sizeof(vec) / sizeof 0 [vec]); i++) {
    if (vec[i] < 0.0 || vec[i] > 1.0) {
      return -1;
    }
    (*p)[i] = vec[i];
  }
  return 0;
}


x86 assembly (clang, -O0):
<parse_color>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x3,%esi
call   1030 <wf_parse_vector@plt>
cmp    $0x0,%rax
je     114c <parse_color+0x3c>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d5 <parse_color+0xc5>
movq   $0x0,-0x48(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x50(%rbp)
cmpq   $0x3,-0x48(%rbp)
jae    11ce <parse_color+0xbe>
mov    -0x48(%rbp),%rax
xorps  %xmm0,%xmm0
ucomisd -0x40(%rbp,%rax,8),%xmm0
ja     1196 <parse_color+0x86>
mov    -0x48(%rbp),%rax
movsd  -0x40(%rbp,%rax,8),%xmm0
movsd  0xe74(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11a2 <parse_color+0x92>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d5 <parse_color+0xc5>
mov    -0x48(%rbp),%rax
movsd  -0x40(%rbp,%rax,8),%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x50(%rbp),%rax
mov    -0x48(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
jmp    115c <parse_color+0x4c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_color>:
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%rbx
mov    %rsp,%rdi
mov    $0x3,%esi
call   1030 <wf_parse_vector@plt>
mov    %rax,%rcx
mov    $0xffffffff,%eax
test   %rcx,%rcx
je     1138 <parse_color+0x28>
add    $0x20,%rsp
pop    %rbx
ret
movsd  (%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
ja     1132 <parse_color+0x22>
ucomisd 0xeb1(%rip),%xmm0
ja     1132 <parse_color+0x22>
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%rbx)
movsd  0x8(%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
ja     1132 <parse_color+0x22>
ucomisd 0xe8f(%rip),%xmm0
ja     1132 <parse_color+0x22>
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x4(%rbx)
movsd  0x10(%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
ja     1132 <parse_color+0x22>
ucomisd 0xe6c(%rip),%xmm0
ja     1132 <parse_color+0x22>
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x8(%rbx)
xor    %eax,%eax
jmp    1132 <parse_color+0x22>

LLVM IR (-O0):
%struct.mtl_buffer = type { i32 }
define i32 @parse_color(i8* %0, %struct.mtl_buffer* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca %struct.mtl_buffer*
%7 = alloca i32*
%8 = alloca [3 x double]
%9 = alloca i64
%10 = alloca [3 x float]*
store i8* %0, i8** %5
store %struct.mtl_buffer* %1, %struct.mtl_buffer** %6
store i32* %2, i32** %7
%11 = load %struct.mtl_buffer*, %struct.mtl_buffer** %6
%12 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 0
%13 = load i32*, i32** %7
%14 = call i64 @wf_parse_vector(double* %12, i32 3, i32* %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %3
store i32 -1, i32* %4
br label %46
17: ; preds = %3
store i64 0, i64* %9
%18 = load i8*, i8** %5
%19 = bitcast i8* %18 to [3 x float]*
store [3 x float]* %19, [3 x float]** %10
br label %20
20: ; preds = %42, %17
%21 = load i64, i64* %9
%22 = icmp ult i64 %21, 3
br i1 %22, label %23, label %45
23: ; preds = %20
%24 = load i64, i64* %9
%25 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 %24
%26 = load double, double* %25
%27 = fcmp olt double %26, 0.000000e+00
br i1 %27, label %33, label %28
28: ; preds = %23
%29 = load i64, i64* %9
%30 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 %29
%31 = load double, double* %30
%32 = fcmp ogt double %31, 1.000000e+00
br i1 %32, label %33, label %34
33: ; preds = %28, %23
store i32 -1, i32* %4
br label %46
34: ; preds = %28
%35 = load i64, i64* %9
%36 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 %35
%37 = load double, double* %36
%38 = fptrunc double %37 to float
%39 = load [3 x float]*, [3 x float]** %10
%40 = load i64, i64* %9
%41 = getelementptr inbounds [3 x float], [3 x float]* %39, i64 0, i64 %40
store float %38, float* %41
br label %42
42: ; preds = %34
%43 = load i64, i64* %9
%44 = add i64 %43, 1
store i64 %44, i64* %9
br label %20
45: ; preds = %20
store i32 0, i32* %4
br label %46
46: ; preds = %45, %33, %16
%47 = load i32, i32* %4
ret i32 %47
}

LLVM IR (-O2):
%struct.mtl_buffer = type { i32 }
define i32 @parse_color(i8* nocapture writeonly %0, %struct.mtl_buffer* nocapture readnone %1, i32* %2) {
%4 = alloca [3 x double]
%5 = bitcast [3 x double]* %4 to i8*
%6 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 0
%7 = call i64 @wf_parse_vector(double* %6, i32 3, i32* %2)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %35
9: ; preds = %3
%10 = load double, double* %6
%11 = fcmp olt double %10, 0.000000e+00
%12 = fcmp ogt double %10, 1.000000e+00
%13 = or i1 %11, %12
br i1 %13, label %35, label %14
14: ; preds = %9
%15 = fptrunc double %10 to float
%16 = bitcast i8* %0 to float*
store float %15, float* %16
%17 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 1
%18 = load double, double* %17
%19 = fcmp olt double %18, 0.000000e+00
%20 = fcmp ogt double %18, 1.000000e+00
%21 = or i1 %19, %20
br i1 %21, label %35, label %22
22: ; preds = %14
%23 = fptrunc double %18 to float
%24 = getelementptr inbounds i8, i8* %0, i64 4
%25 = bitcast i8* %24 to float*
store float %23, float* %25
%26 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 2
%27 = load double, double* %26
%28 = fcmp olt double %27, 0.000000e+00
%29 = fcmp ogt double %27, 1.000000e+00
%30 = or i1 %28, %29
br i1 %30, label %35, label %31
31: ; preds = %22
%32 = fptrunc double %27 to float
%33 = getelementptr inbounds i8, i8* %0, i64 8
%34 = bitcast i8* %33 to float*
store float %32, float* %34
br label %35
35: ; preds = %9, %14, %22, %31, %3
%36 = phi i32 [ -1, %3 ], [ -1, %9 ], [ -1, %14 ], [ -1, %22 ], [ 0, %31 ]
ret i32 %36
}