#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*/ fclose(int /*<<< orphan*/ *);
scalar_t__ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ free(char *);
scalar_t__ getline(char **, size_t *, int /*<<< orphan*/ *);
int sscanf(char *, char *, float *, float *, float *, float *, unsigned long *);
int _parse_header(const char *filepath, float *lat, float *latrad, float *lon,
                  float *lonrad, unsigned long *timestamp) {
  FILE *file;
  char *line;
  size_t line_len;
  file = fopen(filepath, "r");
  if (!file) {
    return 0;
  }
  line = NULL;
  while ((getline(&line, &line_len, file) >= 0) && (line[0] == '#')) {
  }
  if (feof(file)) {
    free(line);
    fclose(file);
    return 0;
  }
  if (5 !=
      sscanf(line, "%f,%f,%f,%f,%ld", lat, latrad, lon, lonrad, timestamp)) {
    free(line);
    fclose(file);
    return 0;
  }
  free(line);
  fclose(file);
  return 1;
}


x86 assembly (clang, -O0):
<_parse_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe75(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    11ab <_parse_header+0x4b>
movl   $0x0,-0x4(%rbp)
jmp    129a <_parse_header+0x13a>
movq   $0x0,-0x48(%rbp)
mov    -0x40(%rbp),%rdx
lea    -0x48(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1080 <getline@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x51(%rbp)
jl     11e6 <_parse_header+0x86>
mov    -0x48(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x23,%eax
sete   %al
mov    %al,-0x51(%rbp)
mov    -0x51(%rbp),%al
test   $0x1,%al
jne    11f6 <_parse_header+0x96>
jmp    11fb <_parse_header+0x9b>
jmp    11b3 <_parse_header+0x53>
mov    -0x40(%rbp),%rdi
call   1050 <feof@plt>
cmp    $0x0,%rax
je     122c <_parse_header+0xcc>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
jmp    129a <_parse_header+0x13a>
mov    -0x48(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    -0x30(%rbp),%r9
mov    -0x38(%rbp),%rax
lea    0xdb7(%rip),%rsi
mov    %rax,(%rsp)
call   1060 <sscanf@plt>
mov    %eax,%ecx
mov    $0x5,%eax
cmp    %ecx,%eax
je     1281 <_parse_header+0x121>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
jmp    129a <_parse_header+0x13a>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_parse_header>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r9,0x28(%rsp)
mov    %r8,%r15
mov    %rcx,%r12
mov    %rdx,%rbp
mov    %rsi,%r13
lea    0xe7a(%rip),%rsi
call   1070 <fopen@plt>
xor    %r14d,%r14d
test   %rax,%rax
je     1232 <_parse_header+0xd2>
mov    %rax,%rbx
mov    %rbp,0x10(%rsp)
mov    %r12,0x18(%rsp)
mov    %r15,0x20(%rsp)
movq   $0x0,0x8(%rsp)
lea    0x8(%rsp),%r15
lea    0x30(%rsp),%r12
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1080 <getline@plt>
test   %rax,%rax
js     11dd <_parse_header+0x7d>
mov    0x8(%rsp),%rax
cmpb   $0x23,(%rax)
je     11c0 <_parse_header+0x60>
mov    %rbx,%rdi
call   1050 <feof@plt>
mov    0x8(%rsp),%rdi
test   %rax,%rax
jne    1225 <_parse_header+0xc5>
mov    0x28(%rsp),%rax
mov    %rax,(%rsp)
lea    0xe03(%rip),%rsi
mov    %r13,%rdx
mov    0x10(%rsp),%rcx
mov    0x18(%rsp),%r8
mov    0x20(%rsp),%r9
call   1060 <sscanf@plt>
xor    %r14d,%r14d
cmp    $0x5,%eax
sete   %r14b
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r14d,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [16 x i8] c"%f,%f,%f,%f,%ld\00"
define i32 @_parse_header(i8* %0, float* %1, float* %2, float* %3, float* %4, i64* %5) {
%7 = alloca i32
%8 = alloca i8*
%9 = alloca float*
%10 = alloca float*
%11 = alloca float*
%12 = alloca float*
%13 = alloca i64*
%14 = alloca i32*
%15 = alloca i8*
%16 = alloca i64
store i8* %0, i8** %8
store float* %1, float** %9
store float* %2, float** %10
store float* %3, float** %11
store float* %4, float** %12
store i64* %5, i64** %13
%17 = load i8*, i8** %8
%18 = call i32* @fopen(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %18, i32** %14
%19 = load i32*, i32** %14
%20 = icmp ne i32* %19, null
br i1 %20, label %22, label %21
21: ; preds = %6
store i32 0, i32* %7
br label %64
22: ; preds = %6
store i8* null, i8** %15
br label %23
23: ; preds = %35, %22
%24 = load i32*, i32** %14
%25 = call i64 @getline(i8** %15, i64* %16, i32* %24)
%26 = icmp sge i64 %25, 0
br i1 %26, label %27, label %33
27: ; preds = %23
%28 = load i8*, i8** %15
%29 = getelementptr inbounds i8, i8* %28, i64 0
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 35
br label %33
33: ; preds = %27, %23
%34 = phi i1 [ false, %23 ], [ %32, %27 ]
br i1 %34, label %35, label %36
35: ; preds = %33
br label %23
36: ; preds = %33
%37 = load i32*, i32** %14
%38 = call i64 @feof(i32* %37)
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %45
40: ; preds = %36
%41 = load i8*, i8** %15
%42 = call i32 @free(i8* %41)
%43 = load i32*, i32** %14
%44 = call i32 @fclose(i32* %43)
store i32 0, i32* %7
br label %64
45: ; preds = %36
%46 = load i8*, i8** %15
%47 = load float*, float** %9
%48 = load float*, float** %10
%49 = load float*, float** %11
%50 = load float*, float** %12
%51 = load i64*, i64** %13
%52 = call i32 @sscanf(i8* %46, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), float* %47, float* %48, float* %49, float* %50, i64* %51)
%53 = icmp ne i32 5, %52
br i1 %53, label %54, label %59
54: ; preds = %45
%55 = load i8*, i8** %15
%56 = call i32 @free(i8* %55)
%57 = load i32*, i32** %14
%58 = call i32 @fclose(i32* %57)
store i32 0, i32* %7
br label %64
59: ; preds = %45
%60 = load i8*, i8** %15
%61 = call i32 @free(i8* %60)
%62 = load i32*, i32** %14
%63 = call i32 @fclose(i32* %62)
store i32 1, i32* %7
br label %64
64: ; preds = %59, %54, %40, %21
%65 = load i32, i32* %7
ret i32 %65
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [16 x i8] c"%f,%f,%f,%f,%ld\00"
define i32 @_parse_header(i8* nocapture %0, float* %1, float* %2, float* %3, float* %4, i64* %5) {
%7 = alloca i8*
%8 = alloca i64
%9 = bitcast i8** %7 to i8*
%10 = bitcast i64* %8 to i8*
%11 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %35, label %13
13: ; preds = %6
store i8* null, i8** %7
br label %14
14: ; preds = %17, %13
%15 = call i64 @getline(i8** %7, i64* %8, i32* %11)
%16 = icmp sgt i64 %15, -1
br i1 %16, label %17, label %21
17: ; preds = %14
%18 = load i8*, i8** %7
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 35
br i1 %20, label %14, label %21
21: ; preds = %14, %17
%22 = call i64 @feof(i32* %11)
%23 = icmp eq i64 %22, 0
%24 = load i8*, i8** %7
br i1 %23, label %28, label %25
25: ; preds = %21
%26 = call i32 @free(i8* %24)
%27 = call i32 @fclose(i32* %11)
br label %35
28: ; preds = %21
%29 = call i32 @sscanf(i8* %24, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), float* %1, float* %2, float* %3, float* %4, i64* %5)
%30 = icmp eq i32 %29, 5
%31 = load i8*, i8** %7
%32 = call i32 @free(i8* %31)
%33 = call i32 @fclose(i32* %11)
%34 = zext i1 %30 to i32
br label %35
35: ; preds = %28, %6, %25
%36 = phi i32 [ 0, %25 ], [ 0, %6 ], [ %34, %28 ]
ret i32 %36
}