#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*/ FILE;

/* Variables and functions */
double *checked_malloc(int);
int /*<<< orphan*/ consume_next_c_on_match_or_err(int /*<<< orphan*/ *, char,
                                                  char *);
double next_double(int /*<<< orphan*/ *);
int /*<<< orphan*/ skip_ws(int /*<<< orphan*/ *);
double *next_vector(FILE *scene_file) {
  ((void)0);
  skip_ws(scene_file);
  consume_next_c_on_match_or_err(
      scene_file, '[', "Expected the opening of a vector (missing '[')");
  double *v = checked_malloc(3 * sizeof(double));
  for (int i = 0; i < 3; i++) {
    skip_ws(scene_file);
    v[i] = next_double(scene_file);
    skip_ws(scene_file);
    if (i != 2) {
      consume_next_c_on_match_or_err(
          scene_file, ',',
          "Expected the continuation of a vector (missing ',')");
    }
  }
  consume_next_c_on_match_or_err(
      scene_file, ']', "Expected the closing of a vector (missing ']')");
  return v;
}


x86 assembly (clang, -O0):
<next_vector>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <skip_ws@plt>
mov    -0x8(%rbp),%rdi
mov    $0x5b,%esi
lea    0xe9b(%rip),%rdx
call   1060 <consume_next_c_on_match_or_err@plt>
mov    $0x18,%edi
call   1040 <checked_malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jge    11e3 <next_vector+0xa3>
mov    -0x8(%rbp),%rdi
call   1050 <skip_ws@plt>
mov    -0x8(%rbp),%rdi
call   1030 <next_double@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%rdi
call   1050 <skip_ws@plt>
cmpl   $0x2,-0x14(%rbp)
je     11d0 <next_vector+0x90>
mov    -0x8(%rbp),%rdi
mov    $0x2c,%esi
lea    0xe64(%rip),%rdx
call   1060 <consume_next_c_on_match_or_err@plt>
jmp    11d5 <next_vector+0x95>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117f <next_vector+0x3f>
mov    -0x8(%rbp),%rdi
mov    $0x5d,%esi
lea    0xe70(%rip),%rdx
call   1060 <consume_next_c_on_match_or_err@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<next_vector>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1050 <skip_ws@plt>
lea    0xeac(%rip),%rdx
mov    %rbx,%rdi
mov    $0x5b,%esi
call   1060 <consume_next_c_on_match_or_err@plt>
mov    $0x18,%edi
call   1040 <checked_malloc@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1050 <skip_ws@plt>
mov    %rbx,%rdi
call   1030 <next_double@plt>
movsd  %xmm0,(%r14)
mov    %rbx,%rdi
call   1050 <skip_ws@plt>
lea    0xe9d(%rip),%r15
mov    %rbx,%rdi
mov    $0x2c,%esi
mov    %r15,%rdx
call   1060 <consume_next_c_on_match_or_err@plt>
mov    %rbx,%rdi
call   1050 <skip_ws@plt>
mov    %rbx,%rdi
call   1030 <next_double@plt>
movsd  %xmm0,0x8(%r14)
mov    %rbx,%rdi
call   1050 <skip_ws@plt>
mov    %rbx,%rdi
mov    $0x2c,%esi
mov    %r15,%rdx
call   1060 <consume_next_c_on_match_or_err@plt>
mov    %rbx,%rdi
call   1050 <skip_ws@plt>
mov    %rbx,%rdi
call   1030 <next_double@plt>
movsd  %xmm0,0x10(%r14)
mov    %rbx,%rdi
call   1050 <skip_ws@plt>
lea    0xe6e(%rip),%rdx
mov    %rbx,%rdi
mov    $0x5d,%esi
call   1060 <consume_next_c_on_match_or_err@plt>
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [47 x i8] c"Expected the opening of a vector (missing '[')\00"
@.str.1 = [52 x i8] c"Expected the continuation of a vector (missing ',')\00"
@.str.2 = [47 x i8] c"Expected the closing of a vector (missing ']')\00"
define double* @next_vector(i32* %0) {
%2 = alloca i32*
%3 = alloca double*
%4 = alloca i32
store i32* %0, i32** %2
%5 = load i32*, i32** %2
%6 = call i32 @skip_ws(i32* %5)
%7 = load i32*, i32** %2
%8 = call i32 @consume_next_c_on_match_or_err(i32* %7, i8 signext 91, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%9 = call double* @checked_malloc(i32 24)
store double* %9, double** %3
store i32 0, i32* %4
br label %10
10: ; preds = %30, %1
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 3
br i1 %12, label %13, label %33
13: ; preds = %10
%14 = load i32*, i32** %2
%15 = call i32 @skip_ws(i32* %14)
%16 = load i32*, i32** %2
%17 = call double @next_double(i32* %16)
%18 = load double*, double** %3
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds double, double* %18, i64 %20
store double %17, double* %21
%22 = load i32*, i32** %2
%23 = call i32 @skip_ws(i32* %22)
%24 = load i32, i32* %4
%25 = icmp ne i32 %24, 2
br i1 %25, label %26, label %29
26: ; preds = %13
%27 = load i32*, i32** %2
%28 = call i32 @consume_next_c_on_match_or_err(i32* %27, i8 signext 44, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0))
br label %29
29: ; preds = %26, %13
br label %30
30: ; preds = %29
%31 = load i32, i32* %4
%32 = add nsw i32 %31, 1
store i32 %32, i32* %4
br label %10
33: ; preds = %10
%34 = load i32*, i32** %2
%35 = call i32 @consume_next_c_on_match_or_err(i32* %34, i8 signext 93, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0))
%36 = load double*, double** %3
ret double* %36
}

LLVM IR (-O2):
@.str = [47 x i8] c"Expected the opening of a vector (missing '[')\00"
@.str.1 = [52 x i8] c"Expected the continuation of a vector (missing ',')\00"
@.str.2 = [47 x i8] c"Expected the closing of a vector (missing ']')\00"
define double* @next_vector(i32* %0) {
%2 = tail call i32 @skip_ws(i32* %0)
%3 = tail call i32 @consume_next_c_on_match_or_err(i32* %0, i8 signext 91, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%4 = tail call double* @checked_malloc(i32 24)
%5 = tail call i32 @skip_ws(i32* %0)
%6 = tail call double @next_double(i32* %0)
store double %6, double* %4
%7 = tail call i32 @skip_ws(i32* %0)
%8 = tail call i32 @consume_next_c_on_match_or_err(i32* %0, i8 signext 44, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0))
%9 = tail call i32 @skip_ws(i32* %0)
%10 = tail call double @next_double(i32* %0)
%11 = getelementptr inbounds double, double* %4, i64 1
store double %10, double* %11
%12 = tail call i32 @skip_ws(i32* %0)
%13 = tail call i32 @consume_next_c_on_match_or_err(i32* %0, i8 signext 44, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0))
%14 = tail call i32 @skip_ws(i32* %0)
%15 = tail call double @next_double(i32* %0)
%16 = getelementptr inbounds double, double* %4, i64 2
store double %15, double* %16
%17 = tail call i32 @skip_ws(i32* %0)
%18 = tail call i32 @consume_next_c_on_match_or_err(i32* %0, i8 signext 93, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0))
ret double* %4
}