#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 /*<<< orphan*/ O_RDONLY;
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
int read(int, unsigned char *, int);
int main(int argc, char **argv) {
  int infile;
  char *prog = argv[0];
  unsigned char buf[16];
  int retval;
  int i, j;
  argv++;
  argc--;
  if (!argc) {
    printf("Please specify file to chee-z-print.\n");
    return 1;
  }
  infile = open(*argv, O_RDONLY);
  if (infile == -1) {
    printf("Unable to open %s\n", *argv);
    return 1;
  }
  retval = 16;
  do {
    retval = read(infile, buf, 16);
    if (retval != 16)
      break;
    for (i = 8; i < 16; i++) {
      for (j = 0; j < (buf[i] / 4); j++) {
        putchar(' ');
      }
      putchar('*');
      putchar('\n');
    }
  } while (1);
}


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)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    119a <main+0x5a>
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1291 <main+0x151>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    0x2e40(%rip),%rax
mov    (%rax),%esi
call   1060 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    11dd <main+0x9d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1291 <main+0x151>
movl   $0x10,-0x34(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0x10,%edx
call   1050 <read@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x10,-0x34(%rbp)
je     1207 <main+0xc7>
jmp    1291 <main+0x151>
movl   $0x8,-0x38(%rbp)
cmpl   $0x10,-0x38(%rbp)
jge    127d <main+0x13d>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    %eax,-0x40(%rbp)
movslq -0x38(%rbp),%rax
movzbl -0x30(%rbp,%rax,1),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x40(%rbp),%eax
cmp    %ecx,%eax
jge    125b <main+0x11b>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    121f <main+0xdf>
mov    $0x2a,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    120e <main+0xce>
jmp    1282 <main+0x142>
mov    $0x1,%al
test   $0x1,%al
jne    11e4 <main+0xa4>
jmp    1291 <main+0x151>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
cmp    $0x1,%edi
jne    1172 <main+0x22>
lea    0xeab(%rip),%rdi
call   1040 <puts@plt>
jmp    123e <main+0xee>
mov    %rsi,%rbp
mov    0x8(%rsi),%rdi
mov    0x2e68(%rip),%rax
mov    (%rax),%esi
call   1070 <open@plt>
cmp    $0xffffffff,%eax
je     122c <main+0xdc>
mov    %eax,%r12d
mov    %rsp,%rsi
mov    %eax,%edi
mov    $0x10,%edx
call   1060 <read@plt>
xor    %r14d,%r14d
cmp    $0x10,%eax
jne    1244 <main+0xf4>
mov    $0x8,%ebp
mov    %rsp,%r15
jmp    11de <main+0x8e>
nopl   0x0(%rax,%rax,1)
mov    $0x2a,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
cmp    $0x10,%rbp
je     1210 <main+0xc0>
movzbl (%rsp,%rbp,1),%ebx
cmp    $0x4,%ebx
jb     11c0 <main+0x70>
shr    $0x2,%ebx
nopw   0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    11f0 <main+0xa0>
jmp    11c0 <main+0x70>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r12d,%edi
mov    %r15,%rsi
mov    $0x10,%edx
call   1060 <read@plt>
mov    $0x8,%ebp
cmp    $0x10,%eax
je     11de <main+0x8e>
jmp    1244 <main+0xf4>
mov    0x8(%rbp),%rsi
lea    0xdc9(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [38 x i8] c"Please specify file to chee-z-print.\0A\00"
@O_RDONLY = global i32 0
@.str.1 = [19 x i8] c"Unable to open %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca [16 x i8]
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
store i8* %14, i8** %7
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i32 1
store i8** %16, i8*** %5
%17 = load i32, i32* %4
%18 = add nsw i32 %17, -1
store i32 %18, i32* %4
%19 = load i32, i32* %4
%20 = icmp ne i32 %19, 0
br i1 %20, label %23, label %21
21: ; preds = %2
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %69
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = load i8*, i8** %24
%26 = load i32, i32* @O_RDONLY
%27 = call i32 @open(i8* %25, i32 %26)
store i32 %27, i32* %6
%28 = load i32, i32* %6
%29 = icmp eq i32 %28, -1
br i1 %29, label %30, label %34
30: ; preds = %23
%31 = load i8**, i8*** %5
%32 = load i8*, i8** %31
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %32)
store i32 1, i32* %3
br label %69
34: ; preds = %23
store i32 16, i32* %9
br label %35
35: ; preds = %68, %34
%36 = load i32, i32* %6
%37 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%38 = call i32 @read(i32 %36, i8* %37, i32 16)
store i32 %38, i32* %9
%39 = load i32, i32* %9
%40 = icmp ne i32 %39, 16
br i1 %40, label %41, label %42
41: ; preds = %35
br label %69
42: ; preds = %35
store i32 8, i32* %10
br label %43
43: ; preds = %64, %42
%44 = load i32, i32* %10
%45 = icmp slt i32 %44, 16
br i1 %45, label %46, label %67
46: ; preds = %43
store i32 0, i32* %11
br label %47
47: ; preds = %58, %46
%48 = load i32, i32* %11
%49 = load i32, i32* %10
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 %50
%52 = load i8, i8* %51
%53 = zext i8 %52 to i32
%54 = sdiv i32 %53, 4
%55 = icmp slt i32 %48, %54
br i1 %55, label %56, label %61
56: ; preds = %47
%57 = call i32 @putchar(i8 signext 32)
br label %58
58: ; preds = %56
%59 = load i32, i32* %11
%60 = add nsw i32 %59, 1
store i32 %60, i32* %11
br label %47
61: ; preds = %47
%62 = call i32 @putchar(i8 signext 42)
%63 = call i32 @putchar(i8 signext 10)
br label %64
64: ; preds = %61
%65 = load i32, i32* %10
%66 = add nsw i32 %65, 1
store i32 %66, i32* %10
br label %43
67: ; preds = %43
br label %68
68: ; preds = %67
br i1 true, label %35, label %69
69: ; preds = %21, %30, %68, %41
%70 = load i32, i32* %3
ret i32 %70
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
@.str.1 = [19 x i8] c"Unable to open %s\0A\00"
@str = [37 x i8] c"Please specify file to chee-z-print.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [16 x i8]
%4 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = icmp eq i32 %0, 1
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
br label %43
9: ; preds = %2
%10 = load i8*, i8** %5
%11 = load i32, i32* @O_RDONLY
%12 = tail call i32 @open(i8* %10, i32 %11)
%13 = icmp eq i32 %12, -1
br i1 %13, label %17, label %14
14: ; preds = %9
%15 = call i32 @read(i32 %12, i8* %4, i32 16)
%16 = icmp eq i32 %15, 16
br i1 %16, label %23, label %43
17: ; preds = %9
%18 = load i8*, i8** %5
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %18)
br label %43
20: ; preds = %36
%21 = call i32 @read(i32 %12, i8* %4, i32 16)
%22 = icmp eq i32 %21, 16
br i1 %22, label %41, label %43
23: ; preds = %14, %41
%24 = phi i64 [ %42, %41 ], [ 8, %14 ]
%25 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = icmp ult i8 %26, 4
br i1 %27, label %36, label %28
28: ; preds = %23
%29 = lshr i8 %26, 2
%30 = zext i8 %29 to i32
br label %31
31: ; preds = %28, %31
%32 = phi i32 [ %34, %31 ], [ 0, %28 ]
%33 = tail call i32 @putchar(i8 signext 32)
%34 = add nuw nsw i32 %32, 1
%35 = icmp eq i32 %34, %30
br i1 %35, label %36, label %31
36: ; preds = %31, %23
%37 = tail call i32 @putchar(i8 signext 42)
%38 = tail call i32 @putchar(i8 signext 10)
%39 = add nuw nsw i64 %24, 1
%40 = icmp eq i64 %39, 16
br i1 %40, label %20, label %41
41: ; preds = %36, %20
%42 = phi i64 [ %39, %36 ], [ 8, %20 ]
br label %23
43: ; preds = %20, %14, %17, %7
%44 = phi i32 [ 1, %17 ], [ 1, %7 ], [ 0, %14 ], [ 0, %20 ]
ret i32 %44
}