#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 /*<<< orphan*/ assert(int);
float *malloc(int);
unsigned int read_floats(char const *, float *, int);
int read_vt(const char *str, float **vt) {
  *vt = malloc(3 * sizeof(**vt));
  unsigned int size = read_floats(str, *vt, 3);
  assert(size >= 1);
  (*vt)[1] = size >= 2 ? (*vt)[1] : 0.0;
  (*vt)[2] = size >= 3 ? (*vt)[2] : 0.0;
  return 0;
}


x86 assembly (clang, -O0):
<read_vt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0xc,%edi
call   1050 <malloc@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    $0x3,%edx
call   1030 <read_floats@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
setae  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
cmpl   $0x2,-0x14(%rbp)
jb     11a1 <read_vt+0x71>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movss  0x4(%rax),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11ae <read_vt+0x7e>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11ae <read_vt+0x7e>
movsd  -0x20(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movss  %xmm0,0x4(%rax)
cmpl   $0x3,-0x14(%rbp)
jb     11e7 <read_vt+0xb7>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movss  0x8(%rax),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11f4 <read_vt+0xc4>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11f4 <read_vt+0xc4>
movsd  -0x28(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movss  %xmm0,0x8(%rax)
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_vt>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0xc,%edi
call   1050 <malloc@plt>
mov    %rax,(%r14)
mov    %rbx,%rdi
mov    %rax,%rsi
mov    $0x3,%edx
call   1030 <read_floats@plt>
mov    %eax,%ebx
xor    %edi,%edi
test   %eax,%eax
setne  %dil
call   1040 <assert@plt>
mov    (%r14),%rax
cmp    $0x1,%ebx
jbe    117d <read_vt+0x4d>
xorps  %xmm0,%xmm0
cmp    $0x2,%ebx
je     1187 <read_vt+0x57>
movss  0x8(%rax),%xmm0
jmp    1187 <read_vt+0x57>
movl   $0x0,0x4(%rax)
xorps  %xmm0,%xmm0
movss  %xmm0,0x8(%rax)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @read_vt(i8* %0, float** %1) {
%3 = alloca i8*
%4 = alloca float**
%5 = alloca i32
store i8* %0, i8** %3
store float** %1, float*** %4
%6 = call float* @malloc(i32 12)
%7 = load float**, float*** %4
store float* %6, float** %7
%8 = load i8*, i8** %3
%9 = load float**, float*** %4
%10 = load float*, float** %9
%11 = call i32 @read_floats(i8* %8, float* %10, i32 3)
store i32 %11, i32* %5
%12 = load i32, i32* %5
%13 = icmp uge i32 %12, 1
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = load i32, i32* %5
%17 = icmp uge i32 %16, 2
br i1 %17, label %18, label %24
18: ; preds = %2
%19 = load float**, float*** %4
%20 = load float*, float** %19
%21 = getelementptr inbounds float, float* %20, i64 1
%22 = load float, float* %21
%23 = fpext float %22 to double
br label %25
24: ; preds = %2
br label %25
25: ; preds = %24, %18
%26 = phi double [ %23, %18 ], [ 0.000000e+00, %24 ]
%27 = fptrunc double %26 to float
%28 = load float**, float*** %4
%29 = load float*, float** %28
%30 = getelementptr inbounds float, float* %29, i64 1
store float %27, float* %30
%31 = load i32, i32* %5
%32 = icmp uge i32 %31, 3
br i1 %32, label %33, label %39
33: ; preds = %25
%34 = load float**, float*** %4
%35 = load float*, float** %34
%36 = getelementptr inbounds float, float* %35, i64 2
%37 = load float, float* %36
%38 = fpext float %37 to double
br label %40
39: ; preds = %25
br label %40
40: ; preds = %39, %33
%41 = phi double [ %38, %33 ], [ 0.000000e+00, %39 ]
%42 = fptrunc double %41 to float
%43 = load float**, float*** %4
%44 = load float*, float** %43
%45 = getelementptr inbounds float, float* %44, i64 2
store float %42, float* %45
ret i32 0
}

LLVM IR (-O2):
define i32 @read_vt(i8* %0, float** nocapture %1) {
%3 = tail call float* @malloc(i32 12)
store float* %3, float** %1
%4 = tail call i32 @read_floats(i8* %0, float* %3, i32 3)
%5 = icmp ne i32 %4, 0
%6 = zext i1 %5 to i32
%7 = tail call i32 @assert(i32 %6)
%8 = icmp ugt i32 %4, 1
%9 = load float*, float** %1
br i1 %8, label %12, label %10
10: ; preds = %2
%11 = getelementptr inbounds float, float* %9, i64 1
store float 0.000000e+00, float* %11
br label %17
12: ; preds = %2
%13 = icmp eq i32 %4, 2
br i1 %13, label %17, label %14
14: ; preds = %12
%15 = getelementptr inbounds float, float* %9, i64 2
%16 = load float, float* %15
br label %17
17: ; preds = %10, %12, %14
%18 = phi float [ %16, %14 ], [ 0.000000e+00, %12 ], [ 0.000000e+00, %10 ]
%19 = getelementptr inbounds float, float* %9, i64 2
store float %18, float* %19
ret i32 0
}