#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 void FILE;

/* Variables and functions */
int /*<<< orphan*/ dodump(void *, long, long);
void *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ skipb(void *, long);
long strtol(char *, void *, int /*<<< orphan*/);
main(int argc, char **argv) {
  FILE *fp;
  long start, count;
  if (argc < 2) {
    puts("Usage: HEXDUMP file_name [start] [length]");
    return (1);
  }
  if (argc > 2) {
    start = strtol(*(argv + 2), ((void *)0), 0);
  } else {
    start = 0L;
  }
  if (argc > 3) {
    count = strtol(*(argv + 3), ((void *)0), 0);
  } else {
    count = -1L;
  }
  fp = fopen(*(argv + 1), "rb");
  if (fp == ((void *)0)) {
    printf("unable to open file %s for input\n", *(argv + 1));
    return (1);
  }
  skipb(fp, start);
  dodump(fp, start, count);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1198 <main+0x38>
lea    0xe79(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0x4(%rbp)
jmp    125c <main+0xfc>
cmpl   $0x2,-0x8(%rbp)
jle    11be <main+0x5e>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1060 <strtol@plt>
mov    %rax,-0x20(%rbp)
jmp    11c6 <main+0x66>
movq   $0x0,-0x20(%rbp)
cmpl   $0x3,-0x8(%rbp)
jle    11ec <main+0x8c>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1060 <strtol@plt>
mov    %rax,-0x28(%rbp)
jmp    11f4 <main+0x94>
movq   $0xffffffffffffffff,-0x28(%rbp)
ff
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe27(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1237 <main+0xd7>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe07(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    125c <main+0xfc>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1070 <skipb@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1040 <dodump@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x1,%edi
jg     117d <main+0x1d>
lea    0xe8d(%rip),%rdi
call   1030 <puts@plt>
jmp    11fd <main+0x9d>
mov    %rsi,%rbx
mov    %edi,%ebp
mov    $0xffffffffffffffff,%r14
cmp    $0x2,%edi
jne    1193 <main+0x33>
xor    %r15d,%r15d
jmp    11b8 <main+0x58>
mov    0x10(%rbx),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1060 <strtol@plt>
mov    %rax,%r15
cmp    $0x4,%ebp
jb     11b8 <main+0x58>
mov    0x18(%rbx),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1060 <strtol@plt>
mov    %rax,%r14
mov    0x8(%rbx),%rdi
lea    0xe67(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     11ed <main+0x8d>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %r15,%rsi
call   1070 <skipb@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1040 <dodump@plt>
xor    %eax,%eax
jmp    1202 <main+0xa2>
mov    0x8(%rbx),%rsi
lea    0xe35(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [42 x i8] c"Usage: HEXDUMP file_name [start] [length]\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [34 x i8] c"unable to open file %s for input\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 @puts(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %51
13: ; preds = %2
%14 = load i32, i32* %4
%15 = icmp sgt i32 %14, 2
br i1 %15, label %16, label %21
16: ; preds = %13
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 2
%19 = load i8*, i8** %18
%20 = call i64 @strtol(i8* %19, i8* null, i32 0)
store i64 %20, i64* %7
br label %22
21: ; preds = %13
store i64 0, i64* %7
br label %22
22: ; preds = %21, %16
%23 = load i32, i32* %4
%24 = icmp sgt i32 %23, 3
br i1 %24, label %25, label %30
25: ; preds = %22
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 3
%28 = load i8*, i8** %27
%29 = call i64 @strtol(i8* %28, i8* null, i32 0)
store i64 %29, i64* %8
br label %31
30: ; preds = %22
store i64 -1, i64* %8
br label %31
31: ; preds = %30, %25
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = call i8* @fopen(i8* %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i8* %35, i8** %6
%36 = load i8*, i8** %6
%37 = icmp eq i8* %36, null
br i1 %37, label %38, label %43
38: ; preds = %31
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 1
%41 = load i8*, i8** %40
%42 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %41)
store i32 1, i32* %3
br label %51
43: ; preds = %31
%44 = load i8*, i8** %6
%45 = load i64, i64* %7
%46 = call i32 @skipb(i8* %44, i64 %45)
%47 = load i8*, i8** %6
%48 = load i64, i64* %7
%49 = load i64, i64* %8
%50 = call i32 @dodump(i8* %47, i64 %48, i64 %49)
store i32 0, i32* %3
br label %51
51: ; preds = %43, %38, %11
%52 = load i32, i32* %3
ret i32 %52
}

LLVM IR (-O2):
@.str = [42 x i8] c"Usage: HEXDUMP file_name [start] [length]\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [34 x i8] c"unable to open file %s for input\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
br label %30
6: ; preds = %2
%7 = icmp eq i32 %0, 2
br i1 %7, label %17, label %8
8: ; preds = %6
%9 = getelementptr inbounds i8*, i8** %1, i64 2
%10 = load i8*, i8** %9
%11 = tail call i64 @strtol(i8* nocapture %10, i8* null, i32 0)
%12 = icmp ugt i32 %0, 3
br i1 %12, label %13, label %17
13: ; preds = %8
%14 = getelementptr inbounds i8*, i8** %1, i64 3
%15 = load i8*, i8** %14
%16 = tail call i64 @strtol(i8* nocapture %15, i8* null, i32 0)
br label %17
17: ; preds = %6, %8, %13
%18 = phi i64 [ %11, %13 ], [ %11, %8 ], [ 0, %6 ]
%19 = phi i64 [ %16, %13 ], [ -1, %8 ], [ -1, %6 ]
%20 = getelementptr inbounds i8*, i8** %1, i64 1
%21 = load i8*, i8** %20
%22 = tail call i8* @fopen(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp eq i8* %22, null
br i1 %23, label %24, label %27
24: ; preds = %17
%25 = load i8*, i8** %20
%26 = tail call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %25)
br label %30
27: ; preds = %17
%28 = tail call i32 @skipb(i8* %22, i64 %18)
%29 = tail call i32 @dodump(i8* %22, i64 %18, i64 %19)
br label %30
30: ; preds = %27, %24, %4
%31 = phi i32 [ 1, %4 ], [ 1, %24 ], [ 0, %27 ]
ret i32 %31
}