#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 */
scalar_t__ EOF;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, double *);
int /*<<< orphan*/ report_error(char *);
int /*<<< orphan*/ skip_ws(int /*<<< orphan*/ *);
double next_double(FILE *scene_file) {
  ((void)0);
  skip_ws(scene_file);
  double value;
  if (EOF == fscanf(scene_file, "%lf", &value)) {
    report_error("Parsing ended unexpectedly when a double was expected");
    exit(EXIT_FAILURE);
  }
  return value;
}


x86 assembly (clang, -O0):
<next_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <skip_ws@plt>
mov    0x2e8c(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe92(%rip),%rsi
lea    -0x10(%rbp),%rdx
call   1030 <fscanf@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
cmp    %rcx,%rax
jne    11a1 <next_double+0x61>
lea    0xe76(%rip),%rdi
call   1050 <report_error@plt>
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
movsd  -0x10(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<next_double>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1040 <skip_ws@plt>
mov    0x2e95(%rip),%rax
mov    (%rax),%r14
lea    0xea3(%rip),%rsi
mov    %rsp,%rdx
mov    %rbx,%rdi
call   1030 <fscanf@plt>
cmp    %rax,%r14
je     117a <next_double+0x3a>
movsd  (%rsp),%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe83(%rip),%rdi
call   1050 <report_error@plt>
mov    0x2e4b(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@EOF = global i64 0
@.str = [4 x i8] c"%lf\00"
@.str.1 = [54 x i8] c"Parsing ended unexpectedly when a double was expected\00"
@EXIT_FAILURE = global i32 0
define double @next_double(i32* %0) {
%2 = alloca i32*
%3 = alloca double
store i32* %0, i32** %2
%4 = load i32*, i32** %2
%5 = call i32 @skip_ws(i32* %4)
%6 = load i64, i64* @EOF
%7 = load i32*, i32** %2
%8 = call i64 @fscanf(i32* %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %3)
%9 = icmp eq i64 %6, %8
br i1 %9, label %10, label %14
10: ; preds = %1
%11 = call i32 @report_error(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%12 = load i32, i32* @EXIT_FAILURE
%13 = call i32 @exit(i32 %12)
unreachable
14: ; preds = %1
%15 = load double, double* %3
ret double %15
}

LLVM IR (-O2):
@EOF = global i64 0
@.str = [4 x i8] c"%lf\00"
@.str.1 = [54 x i8] c"Parsing ended unexpectedly when a double was expected\00"
@EXIT_FAILURE = global i32 0
define double @next_double(i32* %0) {
%2 = alloca double
%3 = tail call i32 @skip_ws(i32* %0)
%4 = bitcast double* %2 to i8*
%5 = load i64, i64* @EOF
%6 = call i64 @fscanf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %2)
%7 = icmp eq i64 %5, %6
br i1 %7, label %8, label %12
8: ; preds = %1
%9 = call i32 @report_error(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
%11 = call i32 @exit(i32 %10)
unreachable
12: ; preds = %1
%13 = load double, double* %2
ret double %13
}