#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*/ printf(char *, ...);
void fsd_processsector(FILE *fsdfile, const unsigned char readability) {
  unsigned char sectorheader[6];
  fread(sectorheader, 4, 1, fsdfile);
  printf("    C%d H%d S%d N%d", sectorheader[0], sectorheader[1],
         sectorheader[2], sectorheader[3]);
  if (readability != 0) {
    unsigned char databyte;
    int datasize, i;
    fread(&sectorheader[4], 2, 1, fsdfile);
    printf(" (%d) code %.2x\n", sectorheader[4], sectorheader[5]);
    datasize = 128 << sectorheader[4];
    printf("      [%d]", datasize);
    for (i = 0; i < datasize; i++) {
      fread(&databyte, 1, 1, fsdfile);
      printf("%c", ((databyte >= ' ') && (databyte <= '~')) ? databyte : '.');
    }
    printf("\n");
  } else
    printf("\n");
}


x86 assembly (clang, -O0):
<fsd_processsector>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
lea    -0xf(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
movzbl -0xf(%rbp),%esi
movzbl -0xe(%rbp),%edx
movzbl -0xd(%rbp),%ecx
movzbl -0xc(%rbp),%r8d
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movzbl -0x9(%rbp),%eax
cmp    $0x0,%eax
je     1251 <fsd_processsector+0x131>
lea    -0xf(%rbp),%rdi
add    $0x4,%rdi
mov    -0x8(%rbp),%rcx
mov    $0x2,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
movzbl -0xb(%rbp),%esi
movzbl -0xa(%rbp),%edx
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movzbl -0xb(%rbp),%ecx
mov    $0x80,%eax
shl    %cl,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    123e <fsd_processsector+0x11e>
mov    -0x8(%rbp),%rcx
lea    -0x10(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
movzbl -0x10(%rbp),%eax
cmp    $0x20,%eax
jl     1212 <fsd_processsector+0xf2>
movzbl -0x10(%rbp),%eax
cmp    $0x7e,%eax
jg     1212 <fsd_processsector+0xf2>
movzbl -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    121f <fsd_processsector+0xff>
mov    $0x2e,%eax
mov    %eax,-0x1c(%rbp)
jmp    121f <fsd_processsector+0xff>
mov    -0x1c(%rbp),%esi
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11cc <fsd_processsector+0xac>
lea    0xdde(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    125f <fsd_processsector+0x13f>
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fsd_processsector>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0x2(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
movzbl 0x2(%rsp),%esi
movzbl 0x3(%rsp),%edx
movzbl 0x4(%rsp),%ecx
movzbl 0x5(%rsp),%r8d
lea    0xe91(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
test   %ebp,%ebp
je     1211 <fsd_processsector+0xe1>
lea    0x6(%rsp),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
movzbl 0x6(%rsp),%r14d
movzbl 0x7(%rsp),%edx
lea    0xe6d(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x80,%ebp
mov    %r14d,%ecx
shl    %cl,%ebp
lea    0xe63(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
test   %ebp,%ebp
jle    1211 <fsd_processsector+0xe1>
lea    0x1(%rsp),%r14
mov    $0x2e,%r15d
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
movzbl 0x1(%rsp),%eax
lea    -0x20(%rax),%ecx
cmp    $0x5f,%cl
cmovae %r15d,%eax
movzbl %al,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    11e0 <fsd_processsector+0xb0>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

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

LLVM IR (-O2):
@.str = [20 x i8] c" C%d H%d S%d N%d\00"
@.str.1 = [17 x i8] c" (%d) code %.2x\0A\00"
@.str.2 = [11 x i8] c" [%d]\00"
define void @fsd_processsector(i32* nocapture %0, i8 zeroext %1) {
%3 = alloca [6 x i8]
%4 = alloca i8
%5 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%6 = call i32 @fread(i8* %5, i32 4, i32 1, i32* %0)
%7 = load i8, i8* %5
%8 = zext i8 %7 to i32
%9 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 1
%10 = load i8, i8* %9
%11 = zext i8 %10 to i32
%12 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 2
%13 = load i8, i8* %12
%14 = zext i8 %13 to i32
%15 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 3
%16 = load i8, i8* %15
%17 = zext i8 %16 to i32
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %11, i32 %14, i32 %17)
%19 = icmp eq i8 %1, 0
br i1 %19, label %45, label %20
20: ; preds = %2
%21 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 4
%22 = call i32 @fread(i8* %21, i32 2, i32 1, i32* %0)
%23 = load i8, i8* %21
%24 = zext i8 %23 to i32
%25 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 5
%26 = load i8, i8* %25
%27 = zext i8 %26 to i32
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %24, i32 %27)
%29 = shl i32 128, %24
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %29)
%31 = icmp sgt i32 %29, 0
br i1 %31, label %32, label %43
32: ; preds = %20, %32
%33 = phi i32 [ %41, %32 ], [ 0, %20 ]
%34 = call i32 @fread(i8* %4, i32 1, i32 1, i32* %0)
%35 = load i8, i8* %4
%36 = add i8 %35, -32
%37 = icmp ult i8 %36, 95
%38 = select i1 %37, i8 %35, i8 46
%39 = zext i8 %38 to i32
%40 = tail call i32 @putchar(i32 %39)
%41 = add nuw nsw i32 %33, 1
%42 = icmp eq i32 %41, %29
br i1 %42, label %43, label %32
43: ; preds = %32, %20
%44 = tail call i32 @putchar(i32 10)
br label %47
45: ; preds = %2
%46 = tail call i32 @putchar(i32 10)
br label %47
47: ; preds = %45, %43
ret void
}