#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 uint8_t;
typedef int /*<<< orphan*/ string_value;
typedef float int32_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_SET;
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fread(float *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, scalar_t__, int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ lower_case(char *);
int seek_definition(int /*<<< orphan*/ *, char *);
scalar_t__ strlen(char *);
scalar_t__ strncmp(char *, char *, int);
float strtof(char *, char **);
int /*<<< orphan*/ trim_leading(char *, int);
int read_float(FILE *f, char *config_path, float *result) {
  int success;
  uint8_t temp;
  success = seek_definition(f, config_path);
  if (success != 0)
    return success;
  temp = fgetc(f);
  if (temp != 1)
    return 1;
  temp = fgetc(f);
  while (fgetc(f) != 0)
    ;
  if (temp == 2) {
    int32_t int_value;
    fread(&int_value, 4, 1, f);
    *result = (float)int_value;
  } else if (temp == 0) {
    char string_value[512];
    char *endptr;
    long fp;
    fp = ftell(f);
    if (fgets(string_value, sizeof(string_value), f) == NULL)
      return 2;
    fseek(f, fp + strlen(string_value) + 1, SEEK_SET);
    trim_leading(string_value, sizeof(string_value));
    lower_case(string_value);
    if (strncmp(string_value, "rad ", 4) != 0)
      return 3;
    *result = strtof(string_value + 4, &endptr);
    if (strlen(endptr) > 0)
      return 4;
    *result *= 0.0174533;
  } else {
    fread(result, 4, 1, f);
  }
  return 0;
}


x86 assembly (clang, -O0):
<read_float>:
push   %rbp
mov    %rsp,%rbp
sub    $0x250,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   10a0 <seek_definition@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     11ec <read_float+0x3c>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    13c5 <read_float+0x215>
mov    -0x10(%rbp),%rdi
call   1080 <fgetc@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x1,-0x28(%rbp)
je     120e <read_float+0x5e>
movl   $0x1,-0x4(%rbp)
jmp    13c5 <read_float+0x215>
mov    -0x10(%rbp),%rdi
call   1080 <fgetc@plt>
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1080 <fgetc@plt>
cmp    $0x0,%eax
je     1231 <read_float+0x81>
jmp    121a <read_float+0x6a>
cmpl   $0x2,-0x28(%rbp)
jne    1264 <read_float+0xb4>
mov    -0x10(%rbp),%rcx
lea    -0x2c(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1050 <fread@plt>
movss  -0x2c(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movss  %xmm0,(%rax)
jmp    13be <read_float+0x20e>
cmpl   $0x0,-0x28(%rbp)
jne    13a2 <read_float+0x1f2>
mov    -0x10(%rbp),%rdi
call   10b0 <ftell@plt>
mov    %rax,-0x240(%rbp)
lea    -0x230(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x200,%esi
call   1090 <fgets@plt>
cmp    $0x0,%rax
jne    12a9 <read_float+0xf9>
movl   $0x2,-0x4(%rbp)
jmp    13c5 <read_float+0x215>
mov    -0x10(%rbp),%rax
mov    %rax,-0x248(%rbp)
mov    -0x240(%rbp),%rax
mov    %rax,-0x250(%rbp)
lea    -0x230(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x250(%rbp),%rsi
mov    -0x248(%rbp),%rdi
add    %rax,%rsi
add    $0x1,%rsi
mov    0x2cf6(%rip),%rax
mov    (%rax),%edx
call   10c0 <fseek@plt>
lea    -0x230(%rbp),%rdi
mov    $0x200,%esi
call   1040 <trim_leading@plt>
lea    -0x230(%rbp),%rdi
call   10d0 <lower_case@plt>
lea    -0x230(%rbp),%rdi
lea    0xcec(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     133c <read_float+0x18c>
movl   $0x3,-0x4(%rbp)
jmp    13c5 <read_float+0x215>
lea    -0x230(%rbp),%rdi
add    $0x4,%rdi
lea    -0x238(%rbp),%rsi
call   1070 <strtof@plt>
mov    -0x20(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x238(%rbp),%rdi
call   1060 <strlen@plt>
cmp    $0x0,%rax
jle    137d <read_float+0x1cd>
movl   $0x4,-0x4(%rbp)
jmp    13c5 <read_float+0x215>
mov    -0x20(%rbp),%rax
movss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xc6f(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%rax)
jmp    13b9 <read_float+0x209>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x4,%esi
mov    $0x1,%edx
call   1050 <fread@plt>
jmp    13be <read_float+0x20e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x250,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_float>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x218,%rsp
mov    %rdx,%r14
mov    %rdi,%rbx
call   10a0 <seek_definition@plt>
test   %eax,%eax
jne    1327 <read_float+0x177>
mov    %rbx,%rdi
call   1080 <fgetc@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    $0x1,%ecx
jne    1327 <read_float+0x177>
mov    %rbx,%rdi
call   1080 <fgetc@plt>
mov    %eax,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1080 <fgetc@plt>
test   %eax,%eax
jne    1200 <read_float+0x50>
test   %ebp,%ebp
je     1240 <read_float+0x90>
cmp    $0x2,%ebp
jne    1310 <read_float+0x160>
lea    0x10(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1050 <fread@plt>
movss  0x10(%rsp),%xmm0
movss  %xmm0,(%r14)
jmp    1325 <read_float+0x175>
mov    %rbx,%rdi
call   10b0 <ftell@plt>
mov    %rax,%r15
lea    0x10(%rsp),%rdi
mov    $0x200,%esi
mov    %rbx,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     1335 <read_float+0x185>
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
call   1060 <strlen@plt>
lea    (%r15,%rax,1),%rsi
add    $0x1,%rsi
mov    0x2d5e(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
call   10c0 <fseek@plt>
mov    %rbp,%rdi
mov    $0x200,%esi
call   1040 <trim_leading@plt>
mov    %rbp,%rdi
call   10d0 <lower_case@plt>
lea    0xd60(%rip),%rsi
mov    %rbp,%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
mov    %rax,%rcx
mov    $0x3,%eax
test   %rcx,%rcx
jne    1327 <read_float+0x177>
lea    0x14(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1070 <strtof@plt>
movss  %xmm0,0x4(%rsp)
movss  %xmm0,(%r14)
mov    0x8(%rsp),%rdi
call   1060 <strlen@plt>
mov    %rax,%rcx
mov    $0x4,%eax
test   %rcx,%rcx
jg     1327 <read_float+0x177>
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xcfb(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%r14)
jmp    1325 <read_float+0x175>
mov    %r14,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1050 <fread@plt>
xor    %eax,%eax
add    $0x218,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x2,%eax
jmp    1327 <read_float+0x177>

LLVM IR (-O0):
@SEEK_SET = global i32 0
@.str = [5 x i8] c"rad \00"
define i32 @read_float(i32* %0, i8* %1, float* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca float*
%8 = alloca i32
%9 = alloca i32
%10 = alloca float
%11 = alloca [512 x i8]
%12 = alloca i8*
%13 = alloca i64
store i32* %0, i32** %5
store i8* %1, i8** %6
store float* %2, float** %7
%14 = load i32*, i32** %5
%15 = load i8*, i8** %6
%16 = call i32 @seek_definition(i32* %14, i8* %15)
store i32 %16, i32* %8
%17 = load i32, i32* %8
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %3
%20 = load i32, i32* %8
store i32 %20, i32* %4
br label %92
21: ; preds = %3
%22 = load i32*, i32** %5
%23 = call i32 @fgetc(i32* %22)
store i32 %23, i32* %9
%24 = load i32, i32* %9
%25 = icmp ne i32 %24, 1
br i1 %25, label %26, label %27
26: ; preds = %21
store i32 1, i32* %4
br label %92
27: ; preds = %21
%28 = load i32*, i32** %5
%29 = call i32 @fgetc(i32* %28)
store i32 %29, i32* %9
br label %30
30: ; preds = %34, %27
%31 = load i32*, i32** %5
%32 = call i32 @fgetc(i32* %31)
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %30
br label %30
35: ; preds = %30
%36 = load i32, i32* %9
%37 = icmp eq i32 %36, 2
br i1 %37, label %38, label %43
38: ; preds = %35
%39 = load i32*, i32** %5
%40 = call i32 @fread(float* %10, i32 4, i32 1, i32* %39)
%41 = load float, float* %10
%42 = load float*, float** %7
store float %41, float* %42
br label %91
43: ; preds = %35
%44 = load i32, i32* %9
%45 = icmp eq i32 %44, 0
br i1 %45, label %46, label %86
46: ; preds = %43
%47 = load i32*, i32** %5
%48 = call i64 @ftell(i32* %47)
store i64 %48, i64* %13
%49 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%50 = load i32*, i32** %5
%51 = call i32* @fgets(i8* %49, i32 512, i32* %50)
%52 = icmp eq i32* %51, null
br i1 %52, label %53, label %54
53: ; preds = %46
store i32 2, i32* %4
br label %92
54: ; preds = %46
%55 = load i32*, i32** %5
%56 = load i64, i64* %13
%57 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%58 = call i64 @strlen(i8* %57)
%59 = add nsw i64 %56, %58
%60 = add nsw i64 %59, 1
%61 = load i32, i32* @SEEK_SET
%62 = call i32 @fseek(i32* %55, i64 %60, i32 %61)
%63 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%64 = call i32 @trim_leading(i8* %63, i32 512)
%65 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%66 = call i32 @lower_case(i8* %65)
%67 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%68 = call i64 @strncmp(i8* %67, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%69 = icmp ne i64 %68, 0
br i1 %69, label %70, label %71
70: ; preds = %54
store i32 3, i32* %4
br label %92
71: ; preds = %54
%72 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%73 = getelementptr inbounds i8, i8* %72, i64 4
%74 = call float @strtof(i8* %73, i8** %12)
%75 = load float*, float** %7
store float %74, float* %75
%76 = load i8*, i8** %12
%77 = call i64 @strlen(i8* %76)
%78 = icmp sgt i64 %77, 0
br i1 %78, label %79, label %80
79: ; preds = %71
store i32 4, i32* %4
br label %92
80: ; preds = %71
%81 = load float*, float** %7
%82 = load float, float* %81
%83 = fpext float %82 to double
%84 = fmul double %83, 1.745330e-02
%85 = fptrunc double %84 to float
store float %85, float* %81
br label %90
86: ; preds = %43
%87 = load float*, float** %7
%88 = load i32*, i32** %5
%89 = call i32 @fread(float* %87, i32 4, i32 1, i32* %88)
br label %90
90: ; preds = %86, %80
br label %91
91: ; preds = %90, %38
store i32 0, i32* %4
br label %92
92: ; preds = %91, %79, %70, %53, %26, %19
%93 = load i32, i32* %4
ret i32 %93
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
@.str = [5 x i8] c"rad \00"
define i32 @read_float(i32* %0, i8* %1, float* nocapture %2) {
%4 = alloca float
%5 = alloca [512 x i8]
%6 = alloca i8*
%7 = tail call i32 @seek_definition(i32* %0, i8* %1)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %52
9: ; preds = %3
%10 = tail call i32 @fgetc(i32* %0)
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %52
12: ; preds = %9
%13 = tail call i32 @fgetc(i32* %0)
br label %14
14: ; preds = %14, %12
%15 = tail call i32 @fgetc(i32* %0)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %14
17: ; preds = %14
switch i32 %13, label %50 [
i32 2, label %18
i32 0, label %22
]
18: ; preds = %17
%19 = bitcast float* %4 to i8*
%20 = call i32 @fread(float* %4, i32 4, i32 1, i32* %0)
%21 = load float, float* %4
store float %21, float* %2
br label %52
22: ; preds = %17
%23 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%24 = bitcast i8** %6 to i8*
%25 = tail call i64 @ftell(i32* %0)
%26 = call i32* @fgets(i8* %23, i32 512, i32* %0)
%27 = icmp eq i32* %26, null
br i1 %27, label %44, label %28
28: ; preds = %22
%29 = call i64 @strlen(i8* %23)
%30 = add i64 %25, 1
%31 = add i64 %30, %29
%32 = load i32, i32* @SEEK_SET
%33 = call i32 @fseek(i32* %0, i64 %31, i32 %32)
%34 = call i32 @trim_leading(i8* %23, i32 512)
%35 = call i32 @lower_case(i8* %23)
%36 = call i64 @strncmp(i8* %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %44
38: ; preds = %28
%39 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 4
%40 = call float @strtof(i8* %39, i8** %6)
store float %40, float* %2
%41 = load i8*, i8** %6
%42 = call i64 @strlen(i8* dereferenceable(1) %41)
%43 = icmp sgt i64 %42, 0
br i1 %43, label %44, label %46
44: ; preds = %22, %28, %38
%45 = phi i32 [ 4, %38 ], [ 3, %28 ], [ 2, %22 ]
br label %52
46: ; preds = %38
%47 = fpext float %40 to double
%48 = fmul double %47, 1.745330e-02
%49 = fptrunc double %48 to float
store float %49, float* %2
br label %52
50: ; preds = %17
%51 = tail call i32 @fread(float* %2, i32 4, i32 1, i32* %0)
br label %52
52: ; preds = %18, %50, %46, %44, %9, %3
%53 = phi i32 [ %7, %3 ], [ 1, %9 ], [ %45, %44 ], [ 0, %46 ], [ 0, %50 ], [ 0, %18 ]
ret i32 %53
}