#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 */
size_t ConvertLine(char *, unsigned char *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
size_t GetTableHeader(FILE *InputFile, unsigned char *OutputData) {
  size_t BytesConverted;
  size_t TotalConverted = 0;
  char Buffer[256];
  int i;
  for (i = 0; i < 3; i++) {
    if (!fgets(Buffer, 256, InputFile)) {
      return (TotalConverted);
    }
    BytesConverted = ConvertLine(Buffer, OutputData);
    TotalConverted += BytesConverted;
    OutputData += 16;
    if (BytesConverted != 16) {
      return (TotalConverted);
    }
  }
  return (TotalConverted);
}


x86 assembly (clang, -O0):
<GetTableHeader>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x28(%rbp)
movl   $0x0,-0x134(%rbp)
cmpl   $0x3,-0x134(%rbp)
jge    11da <GetTableHeader+0xba>
lea    -0x130(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x100,%esi
call   1040 <fgets@plt>
cmp    $0x0,%eax
jne    117d <GetTableHeader+0x5d>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11e2 <GetTableHeader+0xc2>
lea    -0x130(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <ConvertLine@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x10,-0x20(%rbp)
je     11c1 <GetTableHeader+0xa1>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11e2 <GetTableHeader+0xc2>
jmp    11c6 <GetTableHeader+0xa6>
mov    -0x134(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x134(%rbp)
jmp    1145 <GetTableHeader+0x25>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetTableHeader>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x100,%rsp
mov    %rsi,%rbx
mov    %rdi,%r15
xor    %r13d,%r13d
mov    %rsp,%r12
xor    %r14d,%r14d
nop
mov    %r12,%rdi
mov    $0x100,%esi
mov    %r15,%rdx
call   1040 <fgets@plt>
test   %eax,%eax
je     1179 <GetTableHeader+0x59>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <ConvertLine@plt>
add    %rax,%r14
cmp    $0x10,%rax
jne    1179 <GetTableHeader+0x59>
add    $0x10,%rbx
lea    0x1(%r13),%eax
cmp    $0x2,%r13d
mov    %eax,%r13d
jb     1140 <GetTableHeader+0x20>
mov    %r14,%rax
add    $0x100,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @GetTableHeader(i32* %0, i8* %1) {
%3 = alloca i64
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
%8 = alloca [256 x i8]
%9 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
store i64 0, i64* %7
store i32 0, i32* %9
br label %10
10: ; preds = %34, %2
%11 = load i32, i32* %9
%12 = icmp slt i32 %11, 3
br i1 %12, label %13, label %37
13: ; preds = %10
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%15 = load i32*, i32** %4
%16 = call i32 @fgets(i8* %14, i32 256, i32* %15)
%17 = icmp ne i32 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %13
%19 = load i64, i64* %7
store i64 %19, i64* %3
br label %39
20: ; preds = %13
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%22 = load i8*, i8** %5
%23 = call i64 @ConvertLine(i8* %21, i8* %22)
store i64 %23, i64* %6
%24 = load i64, i64* %6
%25 = load i64, i64* %7
%26 = add i64 %25, %24
store i64 %26, i64* %7
%27 = load i8*, i8** %5
%28 = getelementptr inbounds i8, i8* %27, i64 16
store i8* %28, i8** %5
%29 = load i64, i64* %6
%30 = icmp ne i64 %29, 16
br i1 %30, label %31, label %33
31: ; preds = %20
%32 = load i64, i64* %7
store i64 %32, i64* %3
br label %39
33: ; preds = %20
br label %34
34: ; preds = %33
%35 = load i32, i32* %9
%36 = add nsw i32 %35, 1
store i32 %36, i32* %9
br label %10
37: ; preds = %10
%38 = load i64, i64* %7
store i64 %38, i64* %3
br label %39
39: ; preds = %37, %31, %18
%40 = load i64, i64* %3
ret i64 %40
}

LLVM IR (-O2):
define i64 @GetTableHeader(i32* nocapture %0, i8* %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
br label %5
5: ; preds = %11, %2
%6 = phi i32 [ 0, %2 ], [ %16, %11 ]
%7 = phi i64 [ 0, %2 ], [ %13, %11 ]
%8 = phi i8* [ %1, %2 ], [ %15, %11 ]
%9 = call i32 @fgets(i8* %4, i32 256, i32* %0)
%10 = icmp eq i32 %9, 0
br i1 %10, label %19, label %11
11: ; preds = %5
%12 = call i64 @ConvertLine(i8* %4, i8* %8)
%13 = add i64 %12, %7
%14 = icmp eq i64 %12, 16
%15 = getelementptr inbounds i8, i8* %8, i64 16
%16 = add nuw nsw i32 %6, 1
%17 = icmp ult i32 %6, 2
%18 = select i1 %14, i1 %17, i1 false
br i1 %18, label %5, label %19
19: ; preds = %11, %5
%20 = phi i64 [ %7, %5 ], [ %13, %11 ]
ret i64 %20
}