#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 */
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
double atof(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(char *, int, long, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int ftell(int /*<<< orphan*/ *);
char *malloc(long);
char *strstr(char *, char *);
int read_temp(float *temp, char *fileName) {
  char *buffer = NULL;
  long length;
  int result = 1;
  FILE *fileHandle = fopen(fileName, "rb");
  if (fileHandle != NULL) {
    fseek(fileHandle, 0, SEEK_END);
    length = ftell(fileHandle) + 1;
    fseek(fileHandle, 0, SEEK_SET);
    buffer = malloc(length);
    if (buffer) {
      fread(buffer, 1, length - 1, fileHandle);
      buffer[length - 1] = '\0';
      char *valueStr = strstr(buffer, "t=");
      if (valueStr != NULL) {
        valueStr += 2;
        *temp = atof(valueStr) / 1000.0;
        result = 0;
      }
      free(buffer);
    }
    fclose(fileHandle);
  }
  if (*temp >= 85.0)
    result = 1;
  return result;
}


x86 assembly (clang, -O0):
<read_temp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe56(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     12af <read_temp+0x11f>
mov    -0x30(%rbp),%rdi
mov    0x2e0f(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1090 <fseek@plt>
mov    -0x30(%rbp),%rdi
call   1070 <ftell@plt>
add    $0x1,%eax
cltq
mov    %rax,-0x20(%rbp)
mov    -0x30(%rbp),%rdi
mov    0x2dd9(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1090 <fseek@plt>
mov    -0x20(%rbp),%rdi
call   1080 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     12a6 <read_temp+0x116>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rdx
sub    $0x1,%rdx
mov    -0x30(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    $0x1,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rdi
lea    0xdbe(%rip),%rsi
call   10b0 <strstr@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     129d <read_temp+0x10d>
mov    -0x38(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
call   1050 <atof@plt>
movsd  0xd7a(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
movl   $0x0,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd45(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     12d4 <read_temp+0x144>
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_temp>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rax
mov    %rdi,%r14
lea    0xe64(%rip),%rsi
mov    %rax,%rdi
call   10a0 <fopen@plt>
mov    $0x1,%r15d
mov    $0x1,%r13d
test   %rax,%rax
je     1279 <read_temp+0xe9>
mov    %rax,%rbx
mov    0x2e19(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    %rbx,%rdi
call   1070 <ftell@plt>
movslq %eax,%rbp
add    $0x1,%rbp
mov    0x2de7(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    %rbp,%rdi
call   1080 <malloc@plt>
test   %rax,%rax
je     126b <read_temp+0xdb>
mov    %rax,%r12
lea    -0x1(%rbp),%rdx
mov    $0x1,%r13d
mov    %rax,%rdi
mov    $0x1,%esi
mov    %rbx,%rcx
call   1040 <fread@plt>
movb   $0x0,-0x1(%r12,%rbp,1)
lea    0xddb(%rip),%rsi
mov    %r12,%rdi
call   10b0 <strstr@plt>
test   %rax,%rax
je     1261 <read_temp+0xd1>
add    $0x2,%rax
mov    %rax,%rdi
call   1050 <atof@plt>
divsd  0xdab(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%r14)
xor    %r13d,%r13d
mov    %r12,%rdi
call   1030 <free@plt>
jmp    1271 <read_temp+0xe1>
mov    $0x1,%r13d
mov    %rbx,%rdi
call   1060 <fclose@plt>
movss  (%r14),%xmm0
ucomiss 0xd83(%rip),%xmm0
cmovb  %r13d,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.1 = [3 x i8] c"t=\00"
define i32 @read_temp(float* %0, i8* %1) {
%3 = alloca float*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i8*
store float* %0, float** %3
store i8* %1, i8** %4
store i8* null, i8** %5
store i32 1, i32* %7
%10 = load i8*, i8** %4
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %11, i32** %8
%12 = load i32*, i32** %8
%13 = icmp ne i32* %12, null
br i1 %13, label %14, label %57
14: ; preds = %2
%15 = load i32*, i32** %8
%16 = load i32, i32* @SEEK_END
%17 = call i32 @fseek(i32* %15, i32 0, i32 %16)
%18 = load i32*, i32** %8
%19 = call i32 @ftell(i32* %18)
%20 = add nsw i32 %19, 1
%21 = sext i32 %20 to i64
store i64 %21, i64* %6
%22 = load i32*, i32** %8
%23 = load i32, i32* @SEEK_SET
%24 = call i32 @fseek(i32* %22, i32 0, i32 %23)
%25 = load i64, i64* %6
%26 = call i8* @malloc(i64 %25)
store i8* %26, i8** %5
%27 = load i8*, i8** %5
%28 = icmp ne i8* %27, null
br i1 %28, label %29, label %54
29: ; preds = %14
%30 = load i8*, i8** %5
%31 = load i64, i64* %6
%32 = sub nsw i64 %31, 1
%33 = load i32*, i32** %8
%34 = call i32 @fread(i8* %30, i32 1, i64 %32, i32* %33)
%35 = load i8*, i8** %5
%36 = load i64, i64* %6
%37 = sub nsw i64 %36, 1
%38 = getelementptr inbounds i8, i8* %35, i64 %37
store i8 0, i8* %38
%39 = load i8*, i8** %5
%40 = call i8* @strstr(i8* %39, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i8* %40, i8** %9
%41 = load i8*, i8** %9
%42 = icmp ne i8* %41, null
br i1 %42, label %43, label %51
43: ; preds = %29
%44 = load i8*, i8** %9
%45 = getelementptr inbounds i8, i8* %44, i64 2
store i8* %45, i8** %9
%46 = load i8*, i8** %9
%47 = call double @atof(i8* %46)
%48 = fdiv double %47, 1.000000e+03
%49 = fptrunc double %48 to float
%50 = load float*, float** %3
store float %49, float* %50
store i32 0, i32* %7
br label %51
51: ; preds = %43, %29
%52 = load i8*, i8** %5
%53 = call i32 @free(i8* %52)
br label %54
54: ; preds = %51, %14
%55 = load i32*, i32** %8
%56 = call i32 @fclose(i32* %55)
br label %57
57: ; preds = %54, %2
%58 = load float*, float** %3
%59 = load float, float* %58
%60 = fpext float %59 to double
%61 = fcmp oge double %60, 8.500000e+01
br i1 %61, label %62, label %63
62: ; preds = %57
store i32 1, i32* %7
br label %63
63: ; preds = %62, %57
%64 = load i32, i32* %7
ret i32 %64
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.1 = [3 x i8] c"t=\00"
define i32 @read_temp(float* nocapture %0, i8* nocapture %1) {
%3 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %32, label %5
5: ; preds = %2
%6 = load i32, i32* @SEEK_END
%7 = tail call i32 @fseek(i32* %3, i32 0, i32 %6)
%8 = tail call i32 @ftell(i32* %3)
%9 = add nsw i32 %8, 1
%10 = sext i32 %9 to i64
%11 = load i32, i32* @SEEK_SET
%12 = tail call i32 @fseek(i32* %3, i32 0, i32 %11)
%13 = tail call i8* @malloc(i64 %10)
%14 = icmp eq i8* %13, null
br i1 %14, label %29, label %15
15: ; preds = %5
%16 = add nsw i64 %10, -1
%17 = tail call i32 @fread(i8* %13, i32 1, i64 %16, i32* %3)
%18 = getelementptr inbounds i8, i8* %13, i64 %16
store i8 0, i8* %18
%19 = tail call i8* @strstr(i8* %13, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp eq i8* %19, null
br i1 %20, label %26, label %21
21: ; preds = %15
%22 = getelementptr inbounds i8, i8* %19, i64 2
%23 = tail call double @atof(i8* %22)
%24 = fdiv double %23, 1.000000e+03
%25 = fptrunc double %24 to float
store float %25, float* %0
br label %26
26: ; preds = %21, %15
%27 = phi i32 [ 0, %21 ], [ 1, %15 ]
%28 = tail call i32 @free(i8* %13)
br label %29
29: ; preds = %26, %5
%30 = phi i32 [ %27, %26 ], [ 1, %5 ]
%31 = tail call i32 @fclose(i32* %3)
br label %32
32: ; preds = %29, %2
%33 = phi i32 [ %30, %29 ], [ 1, %2 ]
%34 = load float, float* %0
%35 = fcmp ult float %34, 8.500000e+01
%36 = select i1 %35, i32 %33, i32 1
ret i32 %36
}