#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 */

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int fread(unsigned char **, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ fwrite(unsigned char **, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ putchar(int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int main(int argc, char **argv) {
  unsigned int cylinder, head, sector;
  unsigned char *data[256];
  for (cylinder = 0; cylinder < 77; cylinder++) {
    for (head = 0; head < 2; head++) {
      for (sector = 1; sector < 17; sector++) {
        if (fread(data, sizeof(char), 256, stdin) != 256) {
          fprintf(stderr, "lifaddhdr: Unexpected end of input\n");
          exit(1);
        }
        putchar(cylinder);
        putchar(head);
        putchar(cylinder);
        putchar(head);
        putchar(sector);
        putchar(1);
        putchar(0);
        putchar(1);
        fwrite(data, sizeof(char), 256, stdout);
      }
    }
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x820,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x4d,-0x14(%rbp)
jae    127b <main+0x12b>
movl   $0x0,-0x18(%rbp)
cmpl   $0x2,-0x18(%rbp)
jae    1268 <main+0x118>
movl   $0x1,-0x1c(%rbp)
cmpl   $0x11,-0x1c(%rbp)
jae    1255 <main+0x105>
lea    -0x820(%rbp),%rdi
mov    0x2e3e(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
mov    $0x100,%edx
call   1040 <fread@plt>
cmp    $0x100,%eax
je     11e5 <main+0x95>
mov    0x2e0b(%rip),%rax
mov    (%rax),%edi
lea    0xe2a(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x14(%rbp),%edi
call   1030 <putchar@plt>
mov    -0x18(%rbp),%edi
call   1030 <putchar@plt>
mov    -0x14(%rbp),%edi
call   1030 <putchar@plt>
mov    -0x18(%rbp),%edi
call   1030 <putchar@plt>
mov    -0x1c(%rbp),%edi
call   1030 <putchar@plt>
mov    $0x1,%edi
call   1030 <putchar@plt>
xor    %edi,%edi
call   1030 <putchar@plt>
mov    $0x1,%edi
call   1030 <putchar@plt>
lea    -0x820(%rbp),%rdi
mov    0x2d9a(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
mov    $0x100,%edx
call   1070 <fwrite@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1192 <main+0x42>
jmp    125a <main+0x10a>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1181 <main+0x31>
jmp    126d <main+0x11d>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1170 <main+0x20>
xor    %edi,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x800,%rsp
xor    %ebx,%ebx
mov    0x2e80(%rip),%r15
mov    %rsp,%r14
mov    0x2e5e(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x1,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r15),%ecx
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x100,%edx
call   1040 <fread@plt>
cmp    $0x100,%eax
jne    12b1 <main+0x161>
mov    %ebx,%edi
call   1030 <putchar@plt>
xor    %edi,%edi
call   1030 <putchar@plt>
mov    %ebx,%edi
call   1030 <putchar@plt>
xor    %edi,%edi
call   1030 <putchar@plt>
mov    %ebp,%edi
call   1030 <putchar@plt>
mov    $0x1,%edi
call   1030 <putchar@plt>
xor    %edi,%edi
call   1030 <putchar@plt>
mov    $0x1,%edi
call   1030 <putchar@plt>
mov    (%r12),%ecx
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x100,%edx
call   1070 <fwrite@plt>
add    $0x1,%ebp
cmp    $0x11,%ebp
jne    1190 <main+0x40>
mov    $0x1,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r15),%ecx
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x100,%edx
call   1040 <fread@plt>
cmp    $0x100,%eax
jne    12b1 <main+0x161>
mov    %ebx,%edi
call   1030 <putchar@plt>
mov    $0x1,%edi
call   1030 <putchar@plt>
mov    %ebx,%edi
call   1030 <putchar@plt>
mov    $0x1,%edi
call   1030 <putchar@plt>
mov    %ebp,%edi
call   1030 <putchar@plt>
mov    $0x1,%edi
call   1030 <putchar@plt>
xor    %edi,%edi
call   1030 <putchar@plt>
mov    $0x1,%edi
call   1030 <putchar@plt>
mov    (%r12),%ecx
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x100,%edx
call   1070 <fwrite@plt>
add    $0x1,%ebp
cmp    $0x11,%ebp
jne    1220 <main+0xd0>
add    $0x1,%ebx
cmp    $0x4d,%ebx
jne    1180 <main+0x30>
xor    %edi,%edi
call   1060 <exit@plt>
mov    0x2d20(%rip),%rax
mov    (%rax),%edi
lea    0xd3f(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stdin = global i32 0
@stderr = global i32 0
@.str = [36 x i8] c"lifaddhdr: Unexpected end of input\0A\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [256 x i8*]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
br label %10
10: ; preds = %55, %2
%11 = load i32, i32* %6
%12 = icmp ult i32 %11, 77
br i1 %12, label %13, label %58
13: ; preds = %10
store i32 0, i32* %7
br label %14
14: ; preds = %51, %13
%15 = load i32, i32* %7
%16 = icmp ult i32 %15, 2
br i1 %16, label %17, label %54
17: ; preds = %14
store i32 1, i32* %8
br label %18
18: ; preds = %47, %17
%19 = load i32, i32* %8
%20 = icmp ult i32 %19, 17
br i1 %20, label %21, label %50
21: ; preds = %18
%22 = getelementptr inbounds [256 x i8*], [256 x i8*]* %9, i64 0, i64 0
%23 = load i32, i32* @stdin
%24 = call i32 @fread(i8** %22, i32 1, i32 256, i32 %23)
%25 = icmp ne i32 %24, 256
br i1 %25, label %26, label %30
26: ; preds = %21
%27 = load i32, i32* @stderr
%28 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%29 = call i32 @exit(i32 1)
unreachable
30: ; preds = %21
%31 = load i32, i32* %6
%32 = call i32 @putchar(i32 %31)
%33 = load i32, i32* %7
%34 = call i32 @putchar(i32 %33)
%35 = load i32, i32* %6
%36 = call i32 @putchar(i32 %35)
%37 = load i32, i32* %7
%38 = call i32 @putchar(i32 %37)
%39 = load i32, i32* %8
%40 = call i32 @putchar(i32 %39)
%41 = call i32 @putchar(i32 1)
%42 = call i32 @putchar(i32 0)
%43 = call i32 @putchar(i32 1)
%44 = getelementptr inbounds [256 x i8*], [256 x i8*]* %9, i64 0, i64 0
%45 = load i32, i32* @stdout
%46 = call i32 @fwrite(i8** %44, i32 1, i32 256, i32 %45)
br label %47
47: ; preds = %30
%48 = load i32, i32* %8
%49 = add i32 %48, 1
store i32 %49, i32* %8
br label %18
50: ; preds = %18
br label %51
51: ; preds = %50
%52 = load i32, i32* %7
%53 = add i32 %52, 1
store i32 %53, i32* %7
br label %14
54: ; preds = %14
br label %55
55: ; preds = %54
%56 = load i32, i32* %6
%57 = add i32 %56, 1
store i32 %57, i32* %6
br label %10
58: ; preds = %10
%59 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@stdin = global i32 0
@stderr = global i32 0
@.str = [36 x i8] c"lifaddhdr: Unexpected end of input\0A\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [256 x i8*]
%4 = bitcast [256 x i8*]* %3 to i8*
%5 = getelementptr inbounds [256 x i8*], [256 x i8*]* %3, i64 0, i64 0
br label %6
6: ; preds = %2, %48
%7 = phi i32 [ 0, %2 ], [ %49, %48 ]
br label %8
8: ; preds = %6, %17
%9 = phi i32 [ 1, %6 ], [ %28, %17 ]
%10 = load i32, i32* @stdin
%11 = call i32 @fread(i8** %5, i32 1, i32 256, i32 %10)
%12 = icmp eq i32 %11, 256
br i1 %12, label %17, label %13
13: ; preds = %8, %30
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %8
%18 = call i32 @putchar(i32 %7)
%19 = call i32 @putchar(i32 0)
%20 = call i32 @putchar(i32 %7)
%21 = call i32 @putchar(i32 0)
%22 = call i32 @putchar(i32 %9)
%23 = call i32 @putchar(i32 1)
%24 = call i32 @putchar(i32 0)
%25 = call i32 @putchar(i32 1)
%26 = load i32, i32* @stdout
%27 = call i32 @fwrite(i8** %5, i32 1, i32 256, i32 %26)
%28 = add nuw nsw i32 %9, 1
%29 = icmp eq i32 %28, 17
br i1 %29, label %30, label %8
30: ; preds = %17, %35
%31 = phi i32 [ %46, %35 ], [ 1, %17 ]
%32 = load i32, i32* @stdin
%33 = call i32 @fread(i8** %5, i32 1, i32 256, i32 %32)
%34 = icmp eq i32 %33, 256
br i1 %34, label %35, label %13
35: ; preds = %30
%36 = call i32 @putchar(i32 %7)
%37 = call i32 @putchar(i32 1)
%38 = call i32 @putchar(i32 %7)
%39 = call i32 @putchar(i32 1)
%40 = call i32 @putchar(i32 %31)
%41 = call i32 @putchar(i32 1)
%42 = call i32 @putchar(i32 0)
%43 = call i32 @putchar(i32 1)
%44 = load i32, i32* @stdout
%45 = call i32 @fwrite(i8** %5, i32 1, i32 256, i32 %44)
%46 = add nuw nsw i32 %31, 1
%47 = icmp eq i32 %46, 17
br i1 %47, label %48, label %30
48: ; preds = %35
%49 = add nuw nsw i32 %7, 1
%50 = icmp eq i32 %49, 77
br i1 %50, label %51, label %6
51: ; preds = %48
%52 = call i32 @exit(i32 0)
unreachable
}