#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 */
float atof(char *);
char *strchr(char *, char);
int parse_gamma_string(char *str, float gamma[3]) {
  char *s = strchr(str, ':');
  if (s == NULL) {
    float g = atof(str);
    gamma[0] = gamma[1] = gamma[2] = g;
  } else {
    *(s++) = '\0';
    char *g_s = s;
    s = strchr(s, ':');
    if (s == NULL)
      return -1;
    *(s++) = '\0';
    gamma[0] = atof(str);
    gamma[1] = atof(g_s);
    gamma[2] = atof(s);
  }
  return 0;
}


x86 assembly (clang, -O0):
<parse_gamma_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    117f <parse_gamma_string+0x5f>
mov    -0x10(%rbp),%rdi
call   1030 <atof@plt>
movss  %xmm0,-0x24(%rbp)
movss  -0x24(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,0x8(%rax)
mov    -0x18(%rbp),%rax
movss  %xmm0,0x4(%rax)
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
jmp    1209 <parse_gamma_string+0xe9>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11c2 <parse_gamma_string+0xa2>
movl   $0xffffffff,-0x4(%rbp)
jmp    1210 <parse_gamma_string+0xf0>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
call   1030 <atof@plt>
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x30(%rbp),%rdi
call   1030 <atof@plt>
mov    -0x18(%rbp),%rax
movss  %xmm0,0x4(%rax)
mov    -0x20(%rbp),%rdi
call   1030 <atof@plt>
mov    -0x18(%rbp),%rax
movss  %xmm0,0x8(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_gamma_string>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
mov    $0x3a,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     118e <parse_gamma_string+0x6e>
mov    %rax,%rbx
add    $0x1,%rbx
movb   $0x0,(%rax)
mov    %rbx,%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     11ab <parse_gamma_string+0x8b>
mov    %rax,%r12
add    $0x1,%r12
movb   $0x0,(%rax)
mov    %r15,%rdi
call   1030 <atof@plt>
movss  %xmm0,(%r14)
mov    %rbx,%rdi
call   1030 <atof@plt>
movss  %xmm0,0x4(%r14)
mov    %r12,%rdi
call   1030 <atof@plt>
movss  %xmm0,0x8(%r14)
jmp    11a7 <parse_gamma_string+0x87>
mov    %r15,%rdi
call   1030 <atof@plt>
movss  %xmm0,0x8(%r14)
movss  %xmm0,0x4(%r14)
movss  %xmm0,(%r14)
xor    %eax,%eax
jmp    11b0 <parse_gamma_string+0x90>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @parse_gamma_string(i8* %0, float* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca float*
%6 = alloca i8*
%7 = alloca float
%8 = alloca i8*
store i8* %0, i8** %4
store float* %1, float** %5
%9 = load i8*, i8** %4
%10 = call i8* @strchr(i8* %9, i8 signext 58)
store i8* %10, i8** %6
%11 = load i8*, i8** %6
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %23
13: ; preds = %2
%14 = load i8*, i8** %4
%15 = call float @atof(i8* %14)
store float %15, float* %7
%16 = load float, float* %7
%17 = load float*, float** %5
%18 = getelementptr inbounds float, float* %17, i64 2
store float %16, float* %18
%19 = load float*, float** %5
%20 = getelementptr inbounds float, float* %19, i64 1
store float %16, float* %20
%21 = load float*, float** %5
%22 = getelementptr inbounds float, float* %21, i64 0
store float %16, float* %22
br label %47
23: ; preds = %2
%24 = load i8*, i8** %6
%25 = getelementptr inbounds i8, i8* %24, i32 1
store i8* %25, i8** %6
store i8 0, i8* %24
%26 = load i8*, i8** %6
store i8* %26, i8** %8
%27 = load i8*, i8** %6
%28 = call i8* @strchr(i8* %27, i8 signext 58)
store i8* %28, i8** %6
%29 = load i8*, i8** %6
%30 = icmp eq i8* %29, null
br i1 %30, label %31, label %32
31: ; preds = %23
store i32 -1, i32* %3
br label %48
32: ; preds = %23
%33 = load i8*, i8** %6
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %6
store i8 0, i8* %33
%35 = load i8*, i8** %4
%36 = call float @atof(i8* %35)
%37 = load float*, float** %5
%38 = getelementptr inbounds float, float* %37, i64 0
store float %36, float* %38
%39 = load i8*, i8** %8
%40 = call float @atof(i8* %39)
%41 = load float*, float** %5
%42 = getelementptr inbounds float, float* %41, i64 1
store float %40, float* %42
%43 = load i8*, i8** %6
%44 = call float @atof(i8* %43)
%45 = load float*, float** %5
%46 = getelementptr inbounds float, float* %45, i64 2
store float %44, float* %46
br label %47
47: ; preds = %32, %13
store i32 0, i32* %3
br label %48
48: ; preds = %47, %31
%49 = load i32, i32* %3
ret i32 %49
}

LLVM IR (-O2):
define i32 @parse_gamma_string(i8* %0, float* nocapture writeonly %1) {
%3 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 58)
%4 = icmp eq i8* %3, null
br i1 %4, label %5, label %9
5: ; preds = %2
%6 = tail call float @atof(i8* %0)
%7 = getelementptr inbounds float, float* %1, i64 2
store float %6, float* %7
%8 = getelementptr inbounds float, float* %1, i64 1
store float %6, float* %8
store float %6, float* %1
br label %20
9: ; preds = %2
%10 = getelementptr inbounds i8, i8* %3, i64 1
store i8 0, i8* %3
%11 = tail call i8* @strchr(i8* %10, i8 signext 58)
%12 = icmp eq i8* %11, null
br i1 %12, label %20, label %13
13: ; preds = %9
%14 = getelementptr inbounds i8, i8* %11, i64 1
store i8 0, i8* %11
%15 = tail call float @atof(i8* %0)
store float %15, float* %1
%16 = tail call float @atof(i8* %10)
%17 = getelementptr inbounds float, float* %1, i64 1
store float %16, float* %17
%18 = tail call float @atof(i8* %14)
%19 = getelementptr inbounds float, float* %1, i64 2
store float %18, float* %19
br label %20
20: ; preds = %5, %13, %9
%21 = phi i32 [ -1, %9 ], [ 0, %13 ], [ 0, %5 ]
ret i32 %21
}