#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*/ clean_spaces(char *);
int parse_error(char *, char *, int, char *);
int sscanf(char *, char *, float *);
int /*<<< orphan*/ strcpy(char *, char *);
char *strtok_r(int /*<<< orphan*/ *, char *, char **);
int parse_float_field(char *filename, char *line, int ln, float *value,
                      char **saveptr) {
  char *c;
  char word[100];
  int rc;
  c = strtok_r(NULL, ",", saveptr);
  if (!c)
    return parse_error(filename, line, ln, NULL);
  strcpy(word, c);
  clean_spaces(word);
  rc = sscanf(word, "%f", value);
  if (rc != 1)
    return parse_error(filename, line, ln, word);
  return 0;
}


x86 assembly (clang, -O0):
<parse_float_field>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    -0x30(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%edi
lea    0xe83(%rip),%rsi
call   1050 <strtok_r@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    11ad <parse_float_field+0x5d>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
xor    %eax,%eax
mov    %eax,%ecx
call   1070 <parse_error@plt>
mov    %eax,-0x4(%rbp)
jmp    1219 <parse_float_field+0xc9>
lea    -0xa0(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0xa0(%rbp),%rdi
call   1040 <clean_spaces@plt>
lea    -0xa0(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xe27(%rip),%rsi
call   1060 <sscanf@plt>
mov    %eax,-0xa4(%rbp)
cmpl   $0x1,-0xa4(%rbp)
je     1212 <parse_float_field+0xc2>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
lea    -0xa0(%rbp),%rcx
call   1070 <parse_error@plt>
mov    %eax,-0x4(%rbp)
jmp    1219 <parse_float_field+0xc9>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_float_field>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %rcx,%r13
mov    %edx,%r14d
mov    %rsi,%r15
mov    %rdi,%r12
lea    0xe8f(%rip),%rsi
xor    %ebx,%ebx
xor    %edi,%edi
mov    %r8,%rdx
call   1050 <strtok_r@plt>
test   %rax,%rax
je     11d3 <parse_float_field+0x83>
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
mov    %rbp,%rdi
call   1040 <clean_spaces@plt>
lea    0xe63(%rip),%rsi
mov    %rbp,%rdi
mov    %r13,%rdx
call   1060 <sscanf@plt>
cmp    $0x1,%eax
je     11c2 <parse_float_field+0x72>
mov    %rsp,%rcx
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r14d,%edx
call   1070 <parse_error@plt>
mov    %eax,%ebx
mov    %ebx,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r14d,%edx
xor    %ecx,%ecx
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <parse_error@plt>

LLVM IR (-O0):
@.str = [2 x i8] c",\00"
@.str.1 = [3 x i8] c"%f\00"
define i32 @parse_float_field(i8* %0, i8* %1, i32 %2, float* %3, i8** %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca float*
%11 = alloca i8**
%12 = alloca i8*
%13 = alloca [100 x i8]
%14 = alloca i32
store i8* %0, i8** %7
store i8* %1, i8** %8
store i32 %2, i32* %9
store float* %3, float** %10
store i8** %4, i8*** %11
%15 = load i8**, i8*** %11
%16 = call i8* @strtok_r(i32* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %15)
store i8* %16, i8** %12
%17 = load i8*, i8** %12
%18 = icmp ne i8* %17, null
br i1 %18, label %24, label %19
19: ; preds = %5
%20 = load i8*, i8** %7
%21 = load i8*, i8** %8
%22 = load i32, i32* %9
%23 = call i32 @parse_error(i8* %20, i8* %21, i32 %22, i8* null)
store i32 %23, i32* %6
br label %42
24: ; preds = %5
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%26 = load i8*, i8** %12
%27 = call i32 @strcpy(i8* %25, i8* %26)
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%29 = call i32 @clean_spaces(i8* %28)
%30 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%31 = load float*, float** %10
%32 = call i32 @sscanf(i8* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %31)
store i32 %32, i32* %14
%33 = load i32, i32* %14
%34 = icmp ne i32 %33, 1
br i1 %34, label %35, label %41
35: ; preds = %24
%36 = load i8*, i8** %7
%37 = load i8*, i8** %8
%38 = load i32, i32* %9
%39 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%40 = call i32 @parse_error(i8* %36, i8* %37, i32 %38, i8* %39)
store i32 %40, i32* %6
br label %42
41: ; preds = %24
store i32 0, i32* %6
br label %42
42: ; preds = %41, %35, %19
%43 = load i32, i32* %6
ret i32 %43
}

LLVM IR (-O2):
@.str = [2 x i8] c",\00"
@.str.1 = [3 x i8] c"%f\00"
define i32 @parse_float_field(i8* %0, i8* %1, i32 %2, float* %3, i8** %4) {
%6 = alloca [100 x i8]
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%8 = tail call i8* @strtok_r(i32* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %4)
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %12
10: ; preds = %5
%11 = tail call i32 @parse_error(i8* %0, i8* %1, i32 %2, i8* null)
br label %19
12: ; preds = %5
%13 = call i32 @strcpy(i8* %7, i8* %8)
%14 = call i32 @clean_spaces(i8* %7)
%15 = call i32 @sscanf(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %3)
%16 = icmp eq i32 %15, 1
br i1 %16, label %19, label %17
17: ; preds = %12
%18 = call i32 @parse_error(i8* %0, i8* %1, i32 %2, i8* %7)
br label %19
19: ; preds = %12, %17, %10
%20 = phi i32 [ %18, %17 ], [ %11, %10 ], [ 0, %12 ]
ret i32 %20
}