#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 */
struct gff3File {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ gff3FileErr(struct gff3File *, char *, char *);
double strtod(char *, char **);
float gff3FileStrToFloat(struct gff3File *g3f, char *str) {
  char *end;
  double val = strtod(str, &end);
  if ((end == str) || (*end != '\0'))
    gff3FileErr(g3f, "invalid float: %s", str);
  return (float)val;
}


x86 assembly (clang, -O0):
<gff3FileStrToFloat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <strtod@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
je     1160 <gff3FileStrToFloat+0x40>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1174 <gff3FileStrToFloat+0x54>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe91(%rip),%rsi
call   1040 <gff3FileErr@plt>
movsd  -0x20(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gff3FileStrToFloat>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1030 <strtod@plt>
mov    0x10(%rsp),%rax
cmp    %rbx,%rax
je     1149 <gff3FileStrToFloat+0x29>
cmpb   $0x0,(%rax)
je     1167 <gff3FileStrToFloat+0x47>
lea    0xeb0(%rip),%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
movsd  %xmm0,0x8(%rsp)
call   1040 <gff3FileErr@plt>
movsd  0x8(%rsp),%xmm0
cvtsd2ss %xmm0,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.gff3File = type { i32 }
@.str = [18 x i8] c"invalid float: %s\00"
define float @gff3FileStrToFloat(%struct.gff3File* %0, i8* %1) {
%3 = alloca %struct.gff3File*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca double
store %struct.gff3File* %0, %struct.gff3File** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %4
%8 = call double @strtod(i8* %7, i8** %5)
store double %8, double* %6
%9 = load i8*, i8** %5
%10 = load i8*, i8** %4
%11 = icmp eq i8* %9, %10
br i1 %11, label %17, label %12
12: ; preds = %2
%13 = load i8*, i8** %5
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %12, %2
%18 = load %struct.gff3File*, %struct.gff3File** %3
%19 = load i8*, i8** %4
%20 = call i32 @gff3FileErr(%struct.gff3File* %18, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %19)
br label %21
21: ; preds = %17, %12
%22 = load double, double* %6
%23 = fptrunc double %22 to float
ret float %23
}

LLVM IR (-O2):
%struct.gff3File = type { i32 }
@.str = [18 x i8] c"invalid float: %s\00"
define float @gff3FileStrToFloat(%struct.gff3File* %0, i8* %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = call double @strtod(i8* %1, i8** %3)
%6 = load i8*, i8** %3
%7 = icmp eq i8* %6, %1
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = load i8, i8* %6
%10 = icmp eq i8 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %8, %2
%12 = tail call i32 @gff3FileErr(%struct.gff3File* %0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %1)
br label %13
13: ; preds = %11, %8
%14 = fptrunc double %5 to float
ret float %14
}