#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ hex_dump_fp(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ *stdout;
scalar_t__ strcmp(char *, char *);
int main(int argc, char **argv) {
  char *filename;
  FILE *in_fp;
  FILE *out_fp;
  int do_raw = 0;
  int argi = 1;
  if (argc >= 2 && strcmp(argv[1], "-r") == 0) {
    do_raw = 1;
    argi++;
  }
  int num_file_names = argc - argi;
  if (num_file_names == 0) {
    hex_dump_fp(stdin, stdout, do_raw);
  } else {
    for (; argi < argc; argi++) {
      if (!do_raw) {
        if (num_file_names > 1)
          printf("%s:\n", argv[argi]);
      }
      filename = argv[argi];
      in_fp = fopen(filename, "rb");
      out_fp = stdout;
      if (in_fp == NULL) {
        fprintf(stderr, "Couldn't open \"%s\"; skipping.\n", filename);
      } else {
        hex_dump_fp(in_fp, out_fp, do_raw);
        fclose(in_fp);
        if (out_fp != stdout)
          fclose(out_fp);
      }
      if (!do_raw) {
        if (num_file_names > 1)
          printf("\n");
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x1,-0x30(%rbp)
cmpl   $0x2,-0x8(%rbp)
jl     11bc <main+0x5c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe63(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    11bc <main+0x5c>
movl   $0x1,-0x2c(%rbp)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
mov    -0x8(%rbp),%eax
sub    -0x30(%rbp),%eax
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jne    11f0 <main+0x90>
mov    0x2e12(%rip),%rax
mov    (%rax),%rdi
mov    0x2df0(%rip),%rax
mov    (%rax),%rsi
mov    -0x2c(%rbp),%edx
call   1050 <hex_dump_fp@plt>
jmp    1309 <main+0x1a9>
jmp    11f5 <main+0x95>
mov    -0x30(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1304 <main+0x1a4>
cmpl   $0x0,-0x2c(%rbp)
jne    1234 <main+0xd4>
cmpl   $0x1,-0x34(%rbp)
jle    122f <main+0xcf>
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xddb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1234 <main+0xd4>
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xdb9(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    0x2d71(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    128f <main+0x12f>
mov    0x2d60(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xd86(%rip),%rsi
call   1070 <fprintf@plt>
jmp    12ca <main+0x16a>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x2c(%rbp),%edx
call   1050 <hex_dump_fp@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x28(%rbp),%rax
mov    0x2d1d(%rip),%rcx
cmp    (%rcx),%rax
je     12c5 <main+0x165>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
jmp    12ca <main+0x16a>
cmpl   $0x0,-0x2c(%rbp)
jne    12f1 <main+0x191>
cmpl   $0x1,-0x34(%rbp)
jle    12ec <main+0x18c>
lea    0xd43(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12f1 <main+0x191>
jmp    12f6 <main+0x196>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    11f5 <main+0x95>
jmp    1309 <main+0x1a9>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
movl   $0x0,0xc(%rsp)
mov    $0x1,%r14b
mov    $0x1,%r15d
cmp    $0x2,%edi
jl     11bf <main+0x4f>
mov    0x8(%rbx),%rdi
lea    0xe5c(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    11bf <main+0x4f>
movl   $0x1,0xc(%rsp)
mov    $0x2,%r15d
xor    %r14d,%r14d
mov    %ebp,%eax
sub    %r15d,%eax
je     12a0 <main+0x130>
jle    12bd <main+0x14d>
cmp    $0x2,%eax
setge  %al
and    %al,%r14b
mov    %r15d,%r15d
mov    %ebp,%eax
mov    %rax,0x10(%rsp)
jmp    11ff <main+0x8f>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%r15
cmp    %r15,0x10(%rsp)
je     12bd <main+0x14d>
test   %r14b,%r14b
je     1216 <main+0xa6>
mov    (%rbx,%r15,8),%rsi
lea    0xdf4(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rbx,%r15,8),%rbp
mov    %rbp,%rdi
lea    0xde4(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     1270 <main+0x100>
mov    %rax,%r12
mov    0x2d98(%rip),%r13
mov    0x0(%r13),%rbp
mov    %rax,%rdi
mov    %rbp,%rsi
mov    0xc(%rsp),%edx
call   1060 <hex_dump_fp@plt>
mov    %r12,%rdi
call   1040 <fclose@plt>
cmp    0x0(%r13),%rbp
je     1261 <main+0xf1>
mov    %rbp,%rdi
call   1040 <fclose@plt>
test   %r14b,%r14b
je     11f0 <main+0x80>
jmp    1291 <main+0x121>
nopl   0x0(%rax,%rax,1)
mov    0x2d61(%rip),%rax
mov    (%rax),%edi
lea    0xd8b(%rip),%rsi
mov    %rbp,%rdx
call   1080 <fprintf@plt>
test   %r14b,%r14b
je     11f0 <main+0x80>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11f0 <main+0x80>
mov    0x2d41(%rip),%rax
mov    (%rax),%rdi
mov    0x2d1f(%rip),%rax
mov    (%rax),%rsi
mov    0xc(%rsp),%edx
call   1060 <hex_dump_fp@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"-r\00"
@stdin = global i32* null
@stdout = global i32* null
@.str.1 = [5 x i8] c"%s:\0A\00"
@.str.2 = [3 x i8] c"rb\00"
@stderr = global i32 0
@.str.3 = [31 x i8] c"Couldn't open \22%s\22; skipping.\0A\00"
@.str.4 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %9
store i32 1, i32* %10
%12 = load i32, i32* %4
%13 = icmp sge i32 %12, 2
br i1 %13, label %14, label %23
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %14
store i32 1, i32* %9
%21 = load i32, i32* %10
%22 = add nsw i32 %21, 1
store i32 %22, i32* %10
br label %23
23: ; preds = %20, %14, %2
%24 = load i32, i32* %4
%25 = load i32, i32* %10
%26 = sub nsw i32 %24, %25
store i32 %26, i32* %11
%27 = load i32, i32* %11
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %34
29: ; preds = %23
%30 = load i32*, i32** @stdin
%31 = load i32*, i32** @stdout
%32 = load i32, i32* %9
%33 = call i32 @hex_dump_fp(i32* %30, i32* %31, i32 %32)
br label %96
34: ; preds = %23
br label %35
35: ; preds = %92, %34
%36 = load i32, i32* %10
%37 = load i32, i32* %4
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %95
39: ; preds = %35
%40 = load i32, i32* %9
%41 = icmp ne i32 %40, 0
br i1 %41, label %53, label %42
42: ; preds = %39
%43 = load i32, i32* %11
%44 = icmp sgt i32 %43, 1
br i1 %44, label %45, label %52
45: ; preds = %42
%46 = load i8**, i8*** %5
%47 = load i32, i32* %10
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8*, i8** %46, i64 %48
%50 = load i8*, i8** %49
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %50)
br label %52
52: ; preds = %45, %42
br label %53
53: ; preds = %52, %39
%54 = load i8**, i8*** %5
%55 = load i32, i32* %10
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8*, i8** %54, i64 %56
%58 = load i8*, i8** %57
store i8* %58, i8** %6
%59 = load i8*, i8** %6
%60 = call i32* @fopen(i8* %59, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %60, i32** %7
%61 = load i32*, i32** @stdout
store i32* %61, i32** %8
%62 = load i32*, i32** %7
%63 = icmp eq i32* %62, null
br i1 %63, label %64, label %68
64: ; preds = %53
%65 = load i32, i32* @stderr
%66 = load i8*, i8** %6
%67 = call i32 @fprintf(i32 %65, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %66)
br label %82
68: ; preds = %53
%69 = load i32*, i32** %7
%70 = load i32*, i32** %8
%71 = load i32, i32* %9
%72 = call i32 @hex_dump_fp(i32* %69, i32* %70, i32 %71)
%73 = load i32*, i32** %7
%74 = call i32 @fclose(i32* %73)
%75 = load i32*, i32** %8
%76 = load i32*, i32** @stdout
%77 = icmp ne i32* %75, %76
br i1 %77, label %78, label %81
78: ; preds = %68
%79 = load i32*, i32** %8
%80 = call i32 @fclose(i32* %79)
br label %81
81: ; preds = %78, %68
br label %82
82: ; preds = %81, %64
%83 = load i32, i32* %9
%84 = icmp ne i32 %83, 0
br i1 %84, label %91, label %85
85: ; preds = %82
%86 = load i32, i32* %11
%87 = icmp sgt i32 %86, 1
br i1 %87, label %88, label %90
88: ; preds = %85
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %90
90: ; preds = %88, %85
br label %91
91: ; preds = %90, %82
br label %92
92: ; preds = %91
%93 = load i32, i32* %10
%94 = add nsw i32 %93, 1
store i32 %94, i32* %10
br label %35
95: ; preds = %35
br label %96
96: ; preds = %95, %29
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"-r\00"
@stdin = global i32* null
@stdout = global i32* null
@.str.1 = [5 x i8] c"%s:\0A\00"
@.str.2 = [3 x i8] c"rb\00"
@stderr = global i32 0
@.str.3 = [31 x i8] c"Couldn't open \22%s\22; skipping.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %10
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %4
br label %10
10: ; preds = %9, %4, %2
%11 = phi i32 [ 2, %9 ], [ 1, %4 ], [ 1, %2 ]
%12 = phi i1 [ false, %9 ], [ true, %4 ], [ true, %2 ]
%13 = phi i32 [ 1, %9 ], [ 0, %4 ], [ 0, %2 ]
%14 = sub nsw i32 %0, %11
%15 = icmp eq i32 %14, 0
br i1 %15, label %23, label %16
16: ; preds = %10
%17 = icmp slt i32 %11, %0
br i1 %17, label %18, label %55
18: ; preds = %16
%19 = icmp sgt i32 %14, 1
%20 = select i1 %12, i1 %19, i1 false
%21 = zext i32 %11 to i64
%22 = zext i32 %0 to i64
br label %27
23: ; preds = %10
%24 = load i32*, i32** @stdin
%25 = load i32*, i32** @stdout
%26 = tail call i32 @hex_dump_fp(i32* %24, i32* %25, i32 %13)
br label %55
27: ; preds = %18, %52
%28 = phi i64 [ %21, %18 ], [ %53, %52 ]
br i1 %20, label %29, label %33
29: ; preds = %27
%30 = getelementptr inbounds i8*, i8** %1, i64 %28
%31 = load i8*, i8** %30
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %31)
br label %33
33: ; preds = %29, %27
%34 = getelementptr inbounds i8*, i8** %1, i64 %28
%35 = load i8*, i8** %34
%36 = tail call i32* @fopen(i8* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%37 = load i32*, i32** @stdout
%38 = icmp eq i32* %36, null
br i1 %38, label %39, label %42
39: ; preds = %33
%40 = load i32, i32* @stderr
%41 = tail call i32 @fprintf(i32 %40, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %35)
br label %49
42: ; preds = %33
%43 = tail call i32 @hex_dump_fp(i32* %36, i32* %37, i32 %13)
%44 = tail call i32 @fclose(i32* %36)
%45 = load i32*, i32** @stdout
%46 = icmp eq i32* %37, %45
br i1 %46, label %49, label %47
47: ; preds = %42
%48 = tail call i32 @fclose(i32* %37)
br label %49
49: ; preds = %42, %47, %39
br i1 %20, label %50, label %52
50: ; preds = %49
%51 = tail call i32 @putchar(i32 10)
br label %52
52: ; preds = %49, %50
%53 = add nuw nsw i64 %28, 1
%54 = icmp eq i64 %53, %22
br i1 %54, label %55, label %27
55: ; preds = %52, %16, %23
ret i32 0
}