#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 EXIT_SUCCESS;
int /*<<< orphan*/ die(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, unsigned char);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ usage(char *);
int main(int argc, char *argv[]) {
  if (argc < 2)
    usage(argv[0]);
  FILE *f = fopen(argv[1], "r");
  if (!f)
    die(argv[1]);
  unsigned char buf[1];
  int d = fread(buf, 1, 1, f);
  while (d) {
    int i;
    for (i = 1; i <= 8; i++)
      printf("%d", (*buf >> i) % 2);
    d = fread(buf, 1, 1, f);
  }
  puts("");
  fclose(f);
  return EXIT_SUCCESS;
}


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    119c <main+0x2c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1070 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe55(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11cc <main+0x5c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1090 <die@plt>
lea    -0x19(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x1,%edx
mov    %edx,%esi
call   1040 <fread@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     124a <main+0xda>
movl   $0x1,-0x24(%rbp)
cmpl   $0x8,-0x24(%rbp)
jg     122e <main+0xbe>
movzbl -0x19(%rbp),%eax
mov    -0x24(%rbp),%ecx
sar    %cl,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %dl,%al
lea    0xdea(%rip),%rdi
movzbl %al,%esi
call   1060 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11f4 <main+0x84>
lea    -0x19(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x1,%edx
mov    %edx,%esi
call   1040 <fread@plt>
mov    %eax,-0x20(%rbp)
jmp    11e3 <main+0x73>
lea    0xdb3(%rip),%rdi
call   1030 <puts@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    0x2d7a(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x1,%edi
jg     1187 <main+0x17>
mov    (%rbx),%rdi
call   1070 <usage@plt>
mov    0x8(%rbx),%rdi
lea    0xe6e(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r14
test   %rax,%rax
jne    11a8 <main+0x38>
mov    0x8(%rbx),%rdi
call   1090 <die@plt>
lea    0x7(%rsp),%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1040 <fread@plt>
test   %eax,%eax
je     1285 <main+0x115>
lea    0xe34(%rip),%rbx
lea    0x7(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl 0x7(%rsp),%ebp
mov    %ebp,%eax
shr    %al
and    $0x1,%al
movzbl %al,%esi
mov    %rbx,%rdi
call   1060 <printf@plt>
mov    %ebp,%eax
shr    $0x2,%al
and    $0x1,%al
movzbl %al,%esi
mov    %rbx,%rdi
call   1060 <printf@plt>
mov    %ebp,%eax
shr    $0x3,%al
and    $0x1,%al
movzbl %al,%esi
mov    %rbx,%rdi
call   1060 <printf@plt>
mov    %ebp,%eax
shr    $0x4,%al
and    $0x1,%al
movzbl %al,%esi
mov    %rbx,%rdi
call   1060 <printf@plt>
mov    %ebp,%eax
shr    $0x5,%al
and    $0x1,%al
movzbl %al,%esi
mov    %rbx,%rdi
call   1060 <printf@plt>
mov    %ebp,%esi
shr    $0x6,%esi
and    $0x1,%esi
mov    %rbx,%rdi
call   1060 <printf@plt>
shr    $0x7,%bpl
movzbl %bpl,%esi
mov    %rbx,%rdi
call   1060 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1060 <printf@plt>
mov    %r15,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1040 <fread@plt>
test   %eax,%eax
jne    11e0 <main+0x70>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
mov    0x2d42(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [1 x i8] zeroinitializer
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [1 x i8]
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 2
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 1
%20 = load i8*, i8** %19
%21 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %21, i32** %6
%22 = load i32*, i32** %6
%23 = icmp ne i32* %22, null
br i1 %23, label %29, label %24
24: ; preds = %17
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i32 @die(i8* %27)
br label %29
29: ; preds = %24, %17
%30 = getelementptr inbounds [1 x i8], [1 x i8]* %7, i64 0, i64 0
%31 = load i32*, i32** %6
%32 = call i32 @fread(i8* %30, i32 1, i32 1, i32* %31)
store i32 %32, i32* %8
br label %33
33: ; preds = %52, %29
%34 = load i32, i32* %8
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %56
36: ; preds = %33
store i32 1, i32* %9
br label %37
37: ; preds = %49, %36
%38 = load i32, i32* %9
%39 = icmp sle i32 %38, 8
br i1 %39, label %40, label %52
40: ; preds = %37
%41 = getelementptr inbounds [1 x i8], [1 x i8]* %7, i64 0, i64 0
%42 = load i8, i8* %41
%43 = zext i8 %42 to i32
%44 = load i32, i32* %9
%45 = ashr i32 %43, %44
%46 = srem i32 %45, 2
%47 = trunc i32 %46 to i8
%48 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %47)
br label %49
49: ; preds = %40
%50 = load i32, i32* %9
%51 = add nsw i32 %50, 1
store i32 %51, i32* %9
br label %37
52: ; preds = %37
%53 = getelementptr inbounds [1 x i8], [1 x i8]* %7, i64 0, i64 0
%54 = load i32*, i32** %6
%55 = call i32 @fread(i8* %53, i32 1, i32 1, i32* %54)
store i32 %55, i32* %8
br label %33
56: ; preds = %33
%57 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%58 = load i32*, i32** %6
%59 = call i32 @fclose(i32* %58)
%60 = load i32, i32* @EXIT_SUCCESS
ret i32 %60
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"%d\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1 x i8]
%4 = icmp slt i32 %0, 2
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = load i8*, i8** %1
%7 = tail call i32 @usage(i8* %6)
br label %8
8: ; preds = %5, %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %16
13: ; preds = %8
%14 = load i8*, i8** %9
%15 = tail call i32 @die(i8* %14)
br label %16
16: ; preds = %13, %8
%17 = getelementptr inbounds [1 x i8], [1 x i8]* %3, i64 0, i64 0
%18 = call i32 @fread(i8* %17, i32 1, i32 1, i32* %11)
%19 = icmp eq i32 %18, 0
br i1 %19, label %45, label %20
20: ; preds = %16, %20
%21 = load i8, i8* %17
%22 = lshr i8 %21, 1
%23 = and i8 %22, 1
%24 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %23)
%25 = lshr i8 %21, 2
%26 = and i8 %25, 1
%27 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %26)
%28 = lshr i8 %21, 3
%29 = and i8 %28, 1
%30 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %29)
%31 = lshr i8 %21, 4
%32 = and i8 %31, 1
%33 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %32)
%34 = lshr i8 %21, 5
%35 = and i8 %34, 1
%36 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %35)
%37 = lshr i8 %21, 6
%38 = and i8 %37, 1
%39 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %38)
%40 = lshr i8 %21, 7
%41 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %40)
%42 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 zeroext 0)
%43 = call i32 @fread(i8* %17, i32 1, i32 1, i32* %11)
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %20
45: ; preds = %20, %16
%46 = tail call i32 @putchar(i32 10)
%47 = tail call i32 @fclose(i32* %11)
%48 = load i32, i32* @EXIT_SUCCESS
ret i32 %48
}