#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*/ fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fsd_processsector(int /*<<< orphan*/ *, unsigned char);
int /*<<< orphan*/ printf(char *, ...);
void fsd_processtrack(FILE *fsdfile, const unsigned char track) {
  unsigned char trackheader[3];
  int sector;
  printf("\n  Track : ");
  fread(trackheader, 2, 1, fsdfile);
  printf("%d (%d)", trackheader[0], track);
  if (trackheader[1] != 0x00) {
    fread(&trackheader[2], 1, 1, fsdfile);
    printf("(%.2x %sreadable)\n", trackheader[2],
           trackheader[2] == 0 ? "un" : "");
  } else
    printf("\n");
  printf("  Sectors: ");
  if (trackheader[1] == 0)
    printf("Unformatted\n");
  else
    printf("%d\n", trackheader[1]);
  for (sector = 0; sector < trackheader[1]; sector++)
    fsd_processsector(fsdfile, trackheader[2]);
}


x86 assembly (clang, -O0):
<fsd_processtrack>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xc(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x2,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
movzbl -0xc(%rbp),%esi
movzbl -0x9(%rbp),%edx
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movzbl -0xb(%rbp),%eax
cmp    $0x0,%eax
je     11d2 <fsd_processtrack+0xa2>
lea    -0xc(%rbp),%rdi
add    $0x2,%rdi
mov    -0x8(%rbp),%rcx
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
movzbl -0xa(%rbp),%esi
movzbl -0xa(%rbp),%ecx
lea    0xe75(%rip),%rdx
lea    0xe6f(%rip),%rax
cmp    $0x0,%ecx
cmove  %rax,%rdx
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11e0 <fsd_processtrack+0xb0>
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movzbl -0xb(%rbp),%eax
cmp    $0x0,%eax
jne    120e <fsd_processtrack+0xde>
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1220 <fsd_processtrack+0xf0>
movzbl -0xb(%rbp),%esi
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
movzbl -0xb(%rbp),%ecx
cmp    %ecx,%eax
jge    1251 <fsd_processtrack+0x121>
mov    -0x8(%rbp),%rdi
movzbl -0xa(%rbp),%esi
call   1050 <fsd_processsector@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1227 <fsd_processtrack+0xf7>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fsd_processtrack>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebx
mov    %rdi,%r14
lea    0xe9c(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xd(%rsp),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1050 <fread@plt>
movzbl 0xd(%rsp),%esi
lea    0xe7e(%rip),%rdi
mov    %ebx,%edx
xor    %eax,%eax
call   1060 <printf@plt>
cmpb   $0x0,0xe(%rsp)
je     1228 <fsd_processtrack+0xd8>
lea    0xf(%rsp),%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1050 <fread@plt>
movzbl 0xf(%rsp),%esi
test   %esi,%esi
lea    0xe60(%rip),%rax
lea    0xe58(%rip),%rdx
cmove  %rax,%rdx
lea    0xe3b(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movzbl 0xe(%rsp),%ebp
lea    0xe3e(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
test   %ebp,%ebp
je     1240 <fsd_processtrack+0xf0>
lea    0xe38(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
movzbl 0xf(%rsp),%ebx
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %ebx,%esi
call   1070 <fsd_processsector@plt>
add    $0xffffffff,%ebp
jne    1210 <fsd_processtrack+0xc0>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xdf1(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xdf3(%rip),%rdi
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"\0A Track : \00"
@.str.1 = [8 x i8] c"%d (%d)\00"
@.str.2 = [19 x i8] c"(%.2x %sreadable)\0A\00"
@.str.3 = [3 x i8] c"un\00"
@.str.4 = [1 x i8] zeroinitializer
@.str.5 = [2 x i8] c"\0A\00"
@.str.6 = [12 x i8] c" Sectors: \00"
@.str.7 = [13 x i8] c"Unformatted\0A\00"
@.str.8 = [4 x i8] c"%d\0A\00"
define void @fsd_processtrack(i32* %0, i8 zeroext %1) {
%3 = alloca i32*
%4 = alloca i8
%5 = alloca [3 x i8]
%6 = alloca i32
store i32* %0, i32** %3
store i8 %1, i8* %4
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%9 = load i32*, i32** %3
%10 = call i32 @fread(i8* %8, i32 2, i32 1, i32* %9)
%11 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%12 = load i8, i8* %11
%13 = zext i8 %12 to i32
%14 = load i8, i8* %4
%15 = zext i8 %14 to i32
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %13, i32 %15)
%17 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 1
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %35
21: ; preds = %2
%22 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 2
%23 = load i32*, i32** %3
%24 = call i32 @fread(i8* %22, i32 1, i32 1, i32* %23)
%25 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 2
%26 = load i8, i8* %25
%27 = zext i8 %26 to i32
%28 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 2
%29 = load i8, i8* %28
%30 = zext i8 %29 to i32
%31 = icmp eq i32 %30, 0
%32 = zext i1 %31 to i64
%33 = select i1 %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0)
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %27, i8* %33)
br label %37
35: ; preds = %2
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %37
37: ; preds = %35, %21
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
%39 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 1
%40 = load i8, i8* %39
%41 = zext i8 %40 to i32
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %45
43: ; preds = %37
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
br label %50
45: ; preds = %37
%46 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 1
%47 = load i8, i8* %46
%48 = zext i8 %47 to i32
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i32 %48)
br label %50
50: ; preds = %45, %43
store i32 0, i32* %6
br label %51
51: ; preds = %62, %50
%52 = load i32, i32* %6
%53 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 1
%54 = load i8, i8* %53
%55 = zext i8 %54 to i32
%56 = icmp slt i32 %52, %55
br i1 %56, label %57, label %65
57: ; preds = %51
%58 = load i32*, i32** %3
%59 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 2
%60 = load i8, i8* %59
%61 = call i32 @fsd_processsector(i32* %58, i8 zeroext %60)
br label %62
62: ; preds = %57
%63 = load i32, i32* %6
%64 = add nsw i32 %63, 1
store i32 %64, i32* %6
br label %51
65: ; preds = %51
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"\0A Track : \00"
@.str.1 = [8 x i8] c"%d (%d)\00"
@.str.2 = [19 x i8] c"(%.2x %sreadable)\0A\00"
@.str.3 = [3 x i8] c"un\00"
@.str.4 = [1 x i8] zeroinitializer
@.str.6 = [12 x i8] c" Sectors: \00"
@.str.8 = [4 x i8] c"%d\0A\00"
@str = [12 x i8] c"Unformatted\00"
define void @fsd_processtrack(i32* %0, i8 zeroext %1) {
%3 = alloca [3 x i8]
%4 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @fread(i8* %4, i32 2, i32 1, i32* %0)
%7 = load i8, i8* %4
%8 = zext i8 %7 to i32
%9 = zext i8 %1 to i32
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %8, i32 %9)
%11 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 1
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = tail call i32 @putchar(i32 10)
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
br label %28
17: ; preds = %2
%18 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 2
%19 = call i32 @fread(i8* %18, i32 1, i32 1, i32* %0)
%20 = load i8, i8* %18
%21 = zext i8 %20 to i32
%22 = icmp eq i8 %20, 0
%23 = select i1 %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0)
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %21, i8* %23)
%25 = load i8, i8* %11
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
%27 = icmp eq i8 %25, 0
br i1 %27, label %28, label %30
28: ; preds = %17, %14
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
br label %40
30: ; preds = %17
%31 = zext i8 %25 to i32
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i32 %31)
%33 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 2
%34 = load i8, i8* %33
br label %35
35: ; preds = %30, %35
%36 = phi i32 [ 0, %30 ], [ %38, %35 ]
%37 = tail call i32 @fsd_processsector(i32* %0, i8 zeroext %34)
%38 = add nuw nsw i32 %36, 1
%39 = icmp eq i32 %38, %31
br i1 %39, label %40, label %35
40: ; preds = %35, %28
ret void
}