#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*/ data;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
scalar_t__ strcmp(char *, char *);
int parse_header(FILE *in, unsigned *line_count) {
  char data[1024];
  *line_count = 0;
  while (fgets(data, sizeof(data), in)) {
    (*line_count)++;
    if (strcmp(data, "-----BEGIN GEEK CODE BLOCK-----\n"))
      continue;
    if (!fgets(data, sizeof(data), in))
      return -1;
    (*line_count)++;
    return 0;
  }
  return -1;
}


x86 assembly (clang, -O0):
<parse_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
lea    -0x420(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x400,%esi
call   1030 <fgets@plt>
cmp    $0x0,%rax
je     11cb <parse_header+0xab>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
lea    -0x420(%rbp),%rdi
lea    0xe8b(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     1189 <parse_header+0x69>
jmp    113d <parse_header+0x1d>
lea    -0x420(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x400,%esi
call   1030 <fgets@plt>
cmp    $0x0,%rax
jne    11b4 <parse_header+0x94>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d2 <parse_header+0xb2>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    11d2 <parse_header+0xb2>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_header>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x400,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
movl   $0x0,(%rsi)
mov    %rsp,%rbx
lea    0xebb(%rip),%r12
mov    $0xffffffff,%ebp
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %r15,%rdx
call   1030 <fgets@plt>
test   %rax,%rax
je     1194 <parse_header+0x74>
addl   $0x1,(%r14)
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1150 <parse_header+0x30>
mov    %rsp,%rdi
mov    $0x400,%esi
mov    %r15,%rdx
call   1030 <fgets@plt>
test   %rax,%rax
je     1194 <parse_header+0x74>
addl   $0x1,(%r14)
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"-----BEGIN GEEK CODE BLOCK-----\0A\00"
define i32 @parse_header(i32* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca [1024 x i8]
store i32* %0, i32** %4
store i32* %1, i32** %5
%7 = load i32*, i32** %5
store i32 0, i32* %7
br label %8
8: ; preds = %20, %2
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%10 = load i32*, i32** %4
%11 = call i64 @fgets(i8* %9, i32 1024, i32* %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %31
13: ; preds = %8
%14 = load i32*, i32** %5
%15 = load i32, i32* %14
%16 = add i32 %15, 1
store i32 %16, i32* %14
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%18 = call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %13
br label %8
21: ; preds = %13
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%23 = load i32*, i32** %4
%24 = call i64 @fgets(i8* %22, i32 1024, i32* %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %27, label %26
26: ; preds = %21
store i32 -1, i32* %3
br label %32
27: ; preds = %21
%28 = load i32*, i32** %5
%29 = load i32, i32* %28
%30 = add i32 %29, 1
store i32 %30, i32* %28
store i32 0, i32* %3
br label %32
31: ; preds = %8
store i32 -1, i32* %3
br label %32
32: ; preds = %31, %27, %26
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
@.str = [33 x i8] c"-----BEGIN GEEK CODE BLOCK-----\0A\00"
define i32 @parse_header(i32* nocapture %0, i32* nocapture %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
store i32 0, i32* %1
br label %5
5: ; preds = %8, %2
%6 = call i64 @fgets(i8* %4, i32 1024, i32* %0)
%7 = icmp eq i64 %6, 0
br i1 %7, label %19, label %8
8: ; preds = %5
%9 = load i32, i32* %1
%10 = add i32 %9, 1
store i32 %10, i32* %1
%11 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %5
13: ; preds = %8
%14 = call i64 @fgets(i8* %4, i32 1024, i32* %0)
%15 = icmp eq i64 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %13
%17 = load i32, i32* %1
%18 = add i32 %17, 1
store i32 %18, i32* %1
br label %19
19: ; preds = %5, %13, %16
%20 = phi i32 [ 0, %16 ], [ -1, %13 ], [ -1, %5 ]
ret i32 %20
}