#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 print_sect(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int /*<<< orphan*/ strncmp(char *, char *, int);
int /*<<< orphan*/ usage(char *);
int main(int argc, char **argv) {
  int exit_code = 0;
  int x, nsec, loc;
  if (argc < 3) {
    usage(argv[0]);
  }
  if (!strncmp(argv[2], "0x", 2)) {
    (void)sscanf(argv[2] + 2, "%x", &loc);
  } else {
    (void)sscanf(argv[2], "%d", &loc);
  }
  if (argc > 3) {
    (void)sscanf(argv[3], "%d", &nsec);
  } else {
    nsec = 1;
  }
  for (x = 0; x < nsec; ++x, ++loc) {
    if (nsec > 1) {
      if (x > 0) {
        printf("\n");
      }
      printf("Sector %d(0x%x):\n", loc, loc);
    }
    exit_code = print_sect(argv[1], loc);
  }
  return (exit_code);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    1183 <main+0x33>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe6e(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    11c6 <main+0x76>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
add    $0x2,%rdi
lea    0xe4b(%rip),%rsi
lea    -0x20(%rbp),%rdx
call   1050 <sscanf@plt>
jmp    11de <main+0x8e>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe31(%rip),%rsi
lea    -0x20(%rbp),%rdx
call   1050 <sscanf@plt>
cmpl   $0x3,-0x8(%rbp)
jle    1205 <main+0xb5>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xe0f(%rip),%rsi
lea    -0x1c(%rbp),%rdx
call   1050 <sscanf@plt>
jmp    120c <main+0xbc>
movl   $0x1,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    127f <main+0x12f>
cmpl   $0x1,-0x1c(%rbp)
jle    1255 <main+0x105>
cmpl   $0x0,-0x18(%rbp)
jle    1241 <main+0xf1>
lea    0xddf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%esi
mov    -0x20(%rbp),%edx
lea    0xdbb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x20(%rbp),%esi
call   1070 <print_sect@plt>
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1213 <main+0xc3>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
cmp    $0x2,%edi
jg     117a <main+0x1a>
mov    (%rbx),%rdi
call   1070 <usage@plt>
mov    0x10(%rbx),%rdi
lea    0xe7b(%rip),%rsi
mov    $0x2,%edx
call   1040 <strncmp@plt>
mov    0x10(%rbx),%rdi
test   %eax,%eax
je     11a0 <main+0x40>
lea    0xe68(%rip),%rsi
jmp    11ab <main+0x4b>
add    $0x2,%rdi
lea    0xe58(%rip),%rsi
lea    0x8(%rsp),%rdx
call   1060 <sscanf@plt>
cmp    $0x3,%ebp
jle    11f6 <main+0x96>
mov    0x18(%rbx),%rdi
lea    0xe41(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1060 <sscanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    1274 <main+0x114>
cmp    $0x1,%eax
je     11fe <main+0x9e>
mov    0x8(%rsp),%edx
lea    0xe1e(%rip),%rdi
mov    %edx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11fe <main+0x9e>
movl   $0x1,0xc(%rsp)
mov    0x8(%rbx),%rdi
mov    0x8(%rsp),%esi
call   1080 <print_sect@plt>
mov    0x8(%rsp),%esi
add    $0x1,%esi
mov    %esi,0x8(%rsp)
mov    0xc(%rsp),%ecx
cmp    $0x2,%ecx
jl     1276 <main+0x116>
mov    $0x1,%ebp
lea    0xdde(%rip),%r14
jmp    124f <main+0xef>
nopl   (%rax)
mov    0x8(%rbx),%rdi
call   1080 <print_sect@plt>
add    $0x1,%ebp
mov    0x8(%rsp),%esi
add    $0x1,%esi
mov    %esi,0x8(%rsp)
mov    0xc(%rsp),%ecx
cmp    %ecx,%ebp
jge    1276 <main+0x116>
cmp    $0x2,%ecx
jl     1230 <main+0xd0>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x8(%rsp),%edx
mov    %r14,%rdi
mov    %edx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%esi
jmp    1230 <main+0xd0>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"0x\00"
@.str.1 = [3 x i8] c"%x\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [18 x i8] c"Sector %d(0x%x):\0A\00"
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 i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 3
br i1 %11, label %12, label %17
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 @usage(i8* %15)
br label %17
17: ; preds = %12, %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 2
%20 = load i8*, i8** %19
%21 = call i32 @strncmp(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%22 = icmp ne i32 %21, 0
br i1 %22, label %29, label %23
23: ; preds = %17
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 2
%26 = load i8*, i8** %25
%27 = getelementptr inbounds i8, i8* %26, i64 2
%28 = call i32 @sscanf(i8* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %9)
br label %34
29: ; preds = %17
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 2
%32 = load i8*, i8** %31
%33 = call i32 @sscanf(i8* %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %9)
br label %34
34: ; preds = %29, %23
%35 = load i32, i32* %4
%36 = icmp sgt i32 %35, 3
br i1 %36, label %37, label %42
37: ; preds = %34
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 3
%40 = load i8*, i8** %39
%41 = call i32 @sscanf(i8* %40, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %8)
br label %43
42: ; preds = %34
store i32 1, i32* %8
br label %43
43: ; preds = %42, %37
store i32 0, i32* %7
br label %44
44: ; preds = %66, %43
%45 = load i32, i32* %7
%46 = load i32, i32* %8
%47 = icmp slt i32 %45, %46
br i1 %47, label %48, label %71
48: ; preds = %44
%49 = load i32, i32* %8
%50 = icmp sgt i32 %49, 1
br i1 %50, label %51, label %60
51: ; preds = %48
%52 = load i32, i32* %7
%53 = icmp sgt i32 %52, 0
br i1 %53, label %54, label %56
54: ; preds = %51
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %56
56: ; preds = %54, %51
%57 = load i32, i32* %9
%58 = load i32, i32* %9
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %57, i32 %58)
br label %60
60: ; preds = %56, %48
%61 = load i8**, i8*** %5
%62 = getelementptr inbounds i8*, i8** %61, i64 1
%63 = load i8*, i8** %62
%64 = load i32, i32* %9
%65 = call i32 @print_sect(i8* %63, i32 %64)
store i32 %65, i32* %6
br label %66
66: ; preds = %60
%67 = load i32, i32* %7
%68 = add nsw i32 %67, 1
store i32 %68, i32* %7
%69 = load i32, i32* %9
%70 = add nsw i32 %69, 1
store i32 %70, i32* %9
br label %44
71: ; preds = %44
%72 = load i32, i32* %6
ret i32 %72
}

LLVM IR (-O2):
@.str = [3 x i8] c"0x\00"
@.str.1 = [3 x i8] c"%x\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.4 = [18 x i8] c"Sector %d(0x%x):\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = icmp slt i32 %0, 3
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load i8*, i8** %1
%10 = tail call i32 @usage(i8* %9)
br label %11
11: ; preds = %8, %2
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = tail call i32 @strncmp(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%15 = icmp eq i32 %14, 0
%16 = load i8*, i8** %12
br i1 %15, label %17, label %20
17: ; preds = %11
%18 = getelementptr inbounds i8, i8* %16, i64 2
%19 = call i32 @sscanf(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
br label %22
20: ; preds = %11
%21 = call i32 @sscanf(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %4)
br label %22
22: ; preds = %20, %17
%23 = icmp sgt i32 %0, 3
br i1 %23, label %25, label %24
24: ; preds = %22
store i32 1, i32* %3
br label %36
25: ; preds = %22
%26 = getelementptr inbounds i8*, i8** %1, i64 3
%27 = load i8*, i8** %26
%28 = call i32 @sscanf(i8* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%29 = load i32, i32* %3
%30 = icmp sgt i32 %29, 0
br i1 %30, label %31, label %64
31: ; preds = %25
%32 = icmp eq i32 %29, 1
br i1 %32, label %36, label %33
33: ; preds = %31
%34 = load i32, i32* %4
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %34, i32 %34)
br label %36
36: ; preds = %24, %33, %31
%37 = getelementptr inbounds i8*, i8** %1, i64 1
%38 = load i8*, i8** %37
%39 = load i32, i32* %4
%40 = call i32 @print_sect(i8* %38, i32 %39)
%41 = load i32, i32* %4
%42 = add nsw i32 %41, 1
store i32 %42, i32* %4
%43 = load i32, i32* %3
%44 = icmp sgt i32 %43, 1
br i1 %44, label %45, label %64
45: ; preds = %36, %55
%46 = phi i32 [ %61, %55 ], [ %42, %36 ]
%47 = phi i32 [ %62, %55 ], [ %43, %36 ]
%48 = phi i32 [ %59, %55 ], [ 1, %36 ]
%49 = icmp sgt i32 %47, 1
br i1 %49, label %50, label %55
50: ; preds = %45
%51 = call i32 @putchar(i32 10)
%52 = load i32, i32* %4
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %52, i32 %52)
%54 = load i32, i32* %4
br label %55
55: ; preds = %50, %45
%56 = phi i32 [ %54, %50 ], [ %46, %45 ]
%57 = load i8*, i8** %37
%58 = call i32 @print_sect(i8* %57, i32 %56)
%59 = add nuw nsw i32 %48, 1
%60 = load i32, i32* %4
%61 = add nsw i32 %60, 1
store i32 %61, i32* %4
%62 = load i32, i32* %3
%63 = icmp slt i32 %59, %62
br i1 %63, label %45, label %64
64: ; preds = %55, %36, %25
%65 = phi i32 [ 0, %25 ], [ %40, %36 ], [ %58, %55 ]
ret i32 %65
}