#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 *, char *);
int /*<<< orphan*/ putchar(char);
int read(int, unsigned char *, int);
int main(int argc, char **argv) {
  int infile = 0;
  char *prog = argv[0];
  unsigned char buf[16];
  int retval;
  int i, j;
  argv++;
  argc--;
  if (argc) {
    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 = 15; i >= 8; 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)
movl   $0x0,-0x14(%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)
je     11cd <main+0x8d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    0x2e53(%rip),%rax
mov    (%rax),%esi
call   1060 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    11c8 <main+0x88>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe49(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1281 <main+0x141>
jmp    11cd <main+0x8d>
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     11f7 <main+0xb7>
jmp    1281 <main+0x141>
movl   $0xf,-0x38(%rbp)
cmpl   $0x8,-0x38(%rbp)
jl     126d <main+0x12d>
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    124b <main+0x10b>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    120f <main+0xcf>
mov    $0x2a,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x38(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x38(%rbp)
jmp    11fe <main+0xbe>
jmp    1272 <main+0x132>
mov    $0x1,%al
test   $0x1,%al
jne    11d4 <main+0x94>
jmp    1281 <main+0x141>
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
xor    %r14d,%r14d
mov    $0x0,%r12d
cmp    $0x1,%edi
je     117b <main+0x3b>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
mov    0x2e80(%rip),%rax
mov    (%rax),%esi
call   1060 <open@plt>
mov    %eax,%r12d
cmp    $0xffffffff,%eax
je     120c <main+0xcc>
mov    %rsp,%rsi
mov    %r12d,%edi
mov    $0x10,%edx
call   1050 <read@plt>
cmp    $0x10,%eax
jne    1222 <main+0xe2>
mov    $0xf,%ebx
mov    %rsp,%r15
jmp    11c1 <main+0x81>
xchg   %ax,%ax
mov    $0x2a,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    -0x1(%rbx),%rax
cmp    $0x8,%rbx
mov    %rax,%rbx
jbe    11f0 <main+0xb0>
movzbl (%rsp,%rbx,1),%ebp
cmp    $0x4,%ebp
jb     11a0 <main+0x60>
shr    $0x2,%ebp
nopl   (%rax)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    11d0 <main+0x90>
jmp    11a0 <main+0x60>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r12d,%edi
mov    %r15,%rsi
mov    $0x10,%edx
call   1050 <read@plt>
mov    $0xf,%ebx
cmp    $0x10,%eax
je     11c1 <main+0x81>
jmp    1222 <main+0xe2>
mov    0x8(%rbx),%rsi
lea    0xde9(%rip),%rdi
call   1040 <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):
@O_RDONLY = global i32 0
@.str = [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
store i32 0, i32* %6
%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 %21, label %33
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = load i8*, i8** %22
%24 = load i32, i32* @O_RDONLY
%25 = call i32 @open(i8* %23, i32 %24)
store i32 %25, i32* %6
%26 = load i32, i32* %6
%27 = icmp eq i32 %26, -1
br i1 %27, label %28, label %32
28: ; preds = %21
%29 = load i8**, i8*** %5
%30 = load i8*, i8** %29
%31 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %30)
store i32 1, i32* %3
br label %68
32: ; preds = %21
br label %33
33: ; preds = %32, %2
store i32 16, i32* %9
br label %34
34: ; preds = %67, %33
%35 = load i32, i32* %6
%36 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%37 = call i32 @read(i32 %35, i8* %36, i32 16)
store i32 %37, i32* %9
%38 = load i32, i32* %9
%39 = icmp ne i32 %38, 16
br i1 %39, label %40, label %41
40: ; preds = %34
br label %68
41: ; preds = %34
store i32 15, i32* %10
br label %42
42: ; preds = %63, %41
%43 = load i32, i32* %10
%44 = icmp sge i32 %43, 8
br i1 %44, label %45, label %66
45: ; preds = %42
store i32 0, i32* %11
br label %46
46: ; preds = %57, %45
%47 = load i32, i32* %11
%48 = load i32, i32* %10
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 %49
%51 = load i8, i8* %50
%52 = zext i8 %51 to i32
%53 = sdiv i32 %52, 4
%54 = icmp slt i32 %47, %53
br i1 %54, label %55, label %60
55: ; preds = %46
%56 = call i32 @putchar(i8 signext 32)
br label %57
57: ; preds = %55
%58 = load i32, i32* %11
%59 = add nsw i32 %58, 1
store i32 %59, i32* %11
br label %46
60: ; preds = %46
%61 = call i32 @putchar(i8 signext 42)
%62 = call i32 @putchar(i8 signext 10)
br label %63
63: ; preds = %60
%64 = load i32, i32* %10
%65 = add nsw i32 %64, -1
store i32 %65, i32* %10
br label %42
66: ; preds = %42
br label %67
67: ; preds = %66
br i1 true, label %34, label %68
68: ; preds = %28, %67, %40
%69 = load i32, i32* %3
ret i32 %69
}

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