#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
unsigned char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
void main(int argc, char *argv[]) {
  FILE *fp;
  unsigned char in_array[84];
  unsigned int i, j, x, y;
  if (argc == 1)
    exit(0);
  fp = fopen(argv[1], "r+");
  fputc('b', fp);
  printf("P1\n84 48\n");
  for (y = 0; y < 6; ++y) {
    for (x = 0; x < 84; ++x)
      in_array[x] = fgetc(fp);
    for (j = 1; j < 129; j <<= 1) {
      for (x = 0; x < 84; ++x)
        printf("%c", (in_array[x] & j) ? '1' : '0');
      printf("\n");
    }
  }
  fclose(fp);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x4(%rbp)
jne    1183 <main+0x23>
xor    %edi,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe6e(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
mov    $0x62,%edi
call   1060 <fputc@plt>
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x80(%rbp)
cmpl   $0x6,-0x80(%rbp)
jae    1284 <main+0x124>
movl   $0x0,-0x7c(%rbp)
cmpl   $0x54,-0x7c(%rbp)
jae    11f9 <main+0x99>
mov    -0x18(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,%cl
mov    -0x7c(%rbp),%eax
mov    %cl,-0x70(%rbp,%rax,1)
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
jmp    11cf <main+0x6f>
movl   $0x1,-0x78(%rbp)
cmpl   $0x81,-0x78(%rbp)
jae    1271 <main+0x111>
movl   $0x0,-0x7c(%rbp)
cmpl   $0x54,-0x7c(%rbp)
jae    1255 <main+0xf5>
mov    -0x7c(%rbp),%eax
movzbl -0x70(%rbp,%rax,1),%ecx
and    -0x78(%rbp),%ecx
mov    $0x30,%esi
mov    $0x31,%eax
cmp    $0x0,%ecx
cmovne %eax,%esi
lea    0xdcd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
jmp    1214 <main+0xb4>
lea    0xdaf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x78(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x78(%rbp)
jmp    1200 <main+0xa0>
jmp    1276 <main+0x116>
mov    -0x80(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x80(%rbp)
jmp    11be <main+0x5e>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x60,%rsp
cmp    $0x1,%edi
je     1385 <main+0x215>
mov    0x8(%rsi),%rdi
lea    0xe73(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r15
mov    $0x62,%edi
mov    %rax,%rsi
call   1070 <fputc@plt>
lea    0xe5a(%rip),%rdi
call   1040 <puts@plt>
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15,%rdi
call   1060 <fgetc@plt>
mov    %al,(%rsp,%rbx,1)
add    $0x1,%rbx
cmp    $0x54,%rbx
jne    11d0 <main+0x60>
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movzbl (%rsp,%rbx,1),%edi
and    $0x1,%edi
or     $0x30,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    $0x54,%rbx
jne    11f0 <main+0x80>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
movzbl (%rsp,%rbx,1),%eax
and    $0x2,%al
cmp    $0x1,%al
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    $0x54,%rbx
jne    1220 <main+0xb0>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movzbl (%rsp,%rbx,1),%eax
and    $0x4,%al
cmp    $0x1,%al
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    $0x54,%rbx
jne    1250 <main+0xe0>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movzbl (%rsp,%rbx,1),%eax
and    $0x8,%al
cmp    $0x1,%al
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    $0x54,%rbx
jne    1280 <main+0x110>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movzbl (%rsp,%rbx,1),%eax
and    $0x10,%al
cmp    $0x1,%al
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    $0x54,%rbx
jne    12b0 <main+0x140>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movzbl (%rsp,%rbx,1),%eax
and    $0x20,%al
cmp    $0x1,%al
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    $0x54,%rbx
jne    12e0 <main+0x170>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movzbl (%rsp,%rbx,1),%eax
and    $0x40,%al
cmp    $0x1,%al
mov    $0x31,%edi
sbb    $0x0,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    $0x54,%rbx
jne    1310 <main+0x1a0>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
xor    %edi,%edi
cmpb   $0x0,(%rsp,%rbx,1)
setns  %dil
xor    $0x31,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    $0x54,%rbx
jne    1340 <main+0x1d0>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r14d
cmp    $0x6,%r14d
jne    11c0 <main+0x50>
mov    %r15,%rdi
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <fclose@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"r+\00"
@.str.1 = [10 x i8] c"P1\0A84 48\0A\00"
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [2 x i8] c"\0A\00"
define void @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32*
%6 = alloca [84 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%11 = load i32, i32* %3
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 @exit(i32 0)
unreachable
15: ; preds = %2
%16 = load i8**, i8*** %4
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32* @fopen(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %19, i32** %5
%20 = load i32*, i32** %5
%21 = call i32 @fputc(i8 signext 98, i32* %20)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %10
br label %23
23: ; preds = %68, %15
%24 = load i32, i32* %10
%25 = icmp ult i32 %24, 6
br i1 %25, label %26, label %71
26: ; preds = %23
store i32 0, i32* %9
br label %27
27: ; preds = %36, %26
%28 = load i32, i32* %9
%29 = icmp ult i32 %28, 84
br i1 %29, label %30, label %39
30: ; preds = %27
%31 = load i32*, i32** %5
%32 = call zeroext i8 @fgetc(i32* %31)
%33 = load i32, i32* %9
%34 = zext i32 %33 to i64
%35 = getelementptr inbounds [84 x i8], [84 x i8]* %6, i64 0, i64 %34
store i8 %32, i8* %35
br label %36
36: ; preds = %30
%37 = load i32, i32* %9
%38 = add i32 %37, 1
store i32 %38, i32* %9
br label %27
39: ; preds = %27
store i32 1, i32* %8
br label %40
40: ; preds = %64, %39
%41 = load i32, i32* %8
%42 = icmp ult i32 %41, 129
br i1 %42, label %43, label %67
43: ; preds = %40
store i32 0, i32* %9
br label %44
44: ; preds = %59, %43
%45 = load i32, i32* %9
%46 = icmp ult i32 %45, 84
br i1 %46, label %47, label %62
47: ; preds = %44
%48 = load i32, i32* %9
%49 = zext i32 %48 to i64
%50 = getelementptr inbounds [84 x i8], [84 x i8]* %6, i64 0, i64 %49
%51 = load i8, i8* %50
%52 = zext i8 %51 to i32
%53 = load i32, i32* %8
%54 = and i32 %52, %53
%55 = icmp ne i32 %54, 0
%56 = zext i1 %55 to i64
%57 = select i1 %55, i32 49, i32 48
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %57)
br label %59
59: ; preds = %47
%60 = load i32, i32* %9
%61 = add i32 %60, 1
store i32 %61, i32* %9
br label %44
62: ; preds = %44
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %64
64: ; preds = %62
%65 = load i32, i32* %8
%66 = shl i32 %65, 1
store i32 %66, i32* %8
br label %40
67: ; preds = %40
br label %68
68: ; preds = %67
%69 = load i32, i32* %10
%70 = add i32 %69, 1
store i32 %70, i32* %10
br label %23
71: ; preds = %23
%72 = load i32*, i32** %5
%73 = call i32 @fclose(i32* %72)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"r+\00"
@str = [9 x i8] c"P1\0A84 48\00"
define void @main(i32 %0, i8** nocapture %1) {
%3 = alloca [84 x i8]
%4 = getelementptr inbounds [84 x i8], [84 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 1
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @exit(i32 0)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32* @fopen(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%12 = tail call i32 @fputc(i8 signext 98, i32* %11)
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
br label %14
14: ; preds = %8, %115
%15 = phi i32 [ 0, %8 ], [ %117, %115 ]
br label %16
16: ; preds = %14, %16
%17 = phi i64 [ 0, %14 ], [ %20, %16 ]
%18 = tail call zeroext i8 @fgetc(i32* %11)
%19 = getelementptr inbounds [84 x i8], [84 x i8]* %3, i64 0, i64 %17
store i8 %18, i8* %19
%20 = add nuw nsw i64 %17, 1
%21 = icmp eq i64 %20, 84
br i1 %21, label %22, label %16
22: ; preds = %16, %22
%23 = phi i64 [ %30, %22 ], [ 0, %16 ]
%24 = getelementptr inbounds [84 x i8], [84 x i8]* %3, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = and i8 %25, 1
%27 = icmp eq i8 %26, 0
%28 = select i1 %27, i32 48, i32 49
%29 = tail call i32 @putchar(i32 %28)
%30 = add nuw nsw i64 %23, 1
%31 = icmp eq i64 %30, 84
br i1 %31, label %32, label %22
32: ; preds = %22
%33 = tail call i32 @putchar(i32 10)
br label %34
34: ; preds = %34, %32
%35 = phi i64 [ 0, %32 ], [ %42, %34 ]
%36 = getelementptr inbounds [84 x i8], [84 x i8]* %3, i64 0, i64 %35
%37 = load i8, i8* %36
%38 = and i8 %37, 2
%39 = icmp eq i8 %38, 0
%40 = select i1 %39, i32 48, i32 49
%41 = tail call i32 @putchar(i32 %40)
%42 = add nuw nsw i64 %35, 1
%43 = icmp eq i64 %42, 84
br i1 %43, label %44, label %34
44: ; preds = %34
%45 = tail call i32 @putchar(i32 10)
br label %46
46: ; preds = %46, %44
%47 = phi i64 [ 0, %44 ], [ %54, %46 ]
%48 = getelementptr inbounds [84 x i8], [84 x i8]* %3, i64 0, i64 %47
%49 = load i8, i8* %48
%50 = and i8 %49, 4
%51 = icmp eq i8 %50, 0
%52 = select i1 %51, i32 48, i32 49
%53 = tail call i32 @putchar(i32 %52)
%54 = add nuw nsw i64 %47, 1
%55 = icmp eq i64 %54, 84
br i1 %55, label %56, label %46
56: ; preds = %46
%57 = tail call i32 @putchar(i32 10)
br label %58
58: ; preds = %58, %56
%59 = phi i64 [ 0, %56 ], [ %66, %58 ]
%60 = getelementptr inbounds [84 x i8], [84 x i8]* %3, i64 0, i64 %59
%61 = load i8, i8* %60
%62 = and i8 %61, 8
%63 = icmp eq i8 %62, 0
%64 = select i1 %63, i32 48, i32 49
%65 = tail call i32 @putchar(i32 %64)
%66 = add nuw nsw i64 %59, 1
%67 = icmp eq i64 %66, 84
br i1 %67, label %68, label %58
68: ; preds = %58
%69 = tail call i32 @putchar(i32 10)
br label %70
70: ; preds = %70, %68
%71 = phi i64 [ 0, %68 ], [ %78, %70 ]
%72 = getelementptr inbounds [84 x i8], [84 x i8]* %3, i64 0, i64 %71
%73 = load i8, i8* %72
%74 = and i8 %73, 16
%75 = icmp eq i8 %74, 0
%76 = select i1 %75, i32 48, i32 49
%77 = tail call i32 @putchar(i32 %76)
%78 = add nuw nsw i64 %71, 1
%79 = icmp eq i64 %78, 84
br i1 %79, label %80, label %70
80: ; preds = %70
%81 = tail call i32 @putchar(i32 10)
br label %82
82: ; preds = %82, %80
%83 = phi i64 [ 0, %80 ], [ %90, %82 ]
%84 = getelementptr inbounds [84 x i8], [84 x i8]* %3, i64 0, i64 %83
%85 = load i8, i8* %84
%86 = and i8 %85, 32
%87 = icmp eq i8 %86, 0
%88 = select i1 %87, i32 48, i32 49
%89 = tail call i32 @putchar(i32 %88)
%90 = add nuw nsw i64 %83, 1
%91 = icmp eq i64 %90, 84
br i1 %91, label %92, label %82
92: ; preds = %82
%93 = tail call i32 @putchar(i32 10)
br label %94
94: ; preds = %94, %92
%95 = phi i64 [ 0, %92 ], [ %102, %94 ]
%96 = getelementptr inbounds [84 x i8], [84 x i8]* %3, i64 0, i64 %95
%97 = load i8, i8* %96
%98 = and i8 %97, 64
%99 = icmp eq i8 %98, 0
%100 = select i1 %99, i32 48, i32 49
%101 = tail call i32 @putchar(i32 %100)
%102 = add nuw nsw i64 %95, 1
%103 = icmp eq i64 %102, 84
br i1 %103, label %104, label %94
104: ; preds = %94
%105 = tail call i32 @putchar(i32 10)
br label %106
106: ; preds = %106, %104
%107 = phi i64 [ 0, %104 ], [ %113, %106 ]
%108 = getelementptr inbounds [84 x i8], [84 x i8]* %3, i64 0, i64 %107
%109 = load i8, i8* %108
%110 = icmp sgt i8 %109, -1
%111 = select i1 %110, i32 48, i32 49
%112 = tail call i32 @putchar(i32 %111)
%113 = add nuw nsw i64 %107, 1
%114 = icmp eq i64 %113, 84
br i1 %114, label %115, label %106
115: ; preds = %106
%116 = tail call i32 @putchar(i32 10)
%117 = add nuw nsw i32 %15, 1
%118 = icmp eq i32 %117, 6
br i1 %118, label %119, label %14
119: ; preds = %115
%120 = tail call i32 @fclose(i32* %11)
ret void
}