#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);
int /*<<< orphan*/ *fgets(unsigned char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, unsigned char);
int /*<<< orphan*/ putchar(unsigned char);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ usage();
main(int argc, char *argv[]) {
  FILE *eight_bit_file;
  unsigned char line[80];
  int i;
  if (argc != 2)
    usage();
  eight_bit_file = fopen(argv[1], "r");
  if (eight_bit_file == NULL) {
    fprintf(stderr, "%s: can\'t open\n", argv[1]);
    exit(1);
  }
  while (fgets(line, 80, eight_bit_file) != NULL) {
    for (i = 0; line[i] != '\0'; i++) {
      if (line[i] > 128)
        printf("^^%02x", line[i]);
      else
        putchar(line[i]);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     119a <main+0x2a>
mov    $0x0,%al
call   1070 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe57(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11e4 <main+0x74>
mov    0x2e1c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe2d(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
jmp    11e9 <main+0x79>
lea    -0x70(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x50,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     1272 <main+0x102>
movl   $0x0,-0x74(%rbp)
movslq -0x74(%rbp),%rax
movzbl -0x70(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     126d <main+0xfd>
movslq -0x74(%rbp),%rax
movzbl -0x70(%rbp,%rax,1),%eax
cmp    $0x80,%eax
jle    124c <main+0xdc>
movslq -0x74(%rbp),%rax
lea    0xdd5(%rip),%rdi
movzbl -0x70(%rbp,%rax,1),%esi
call   1040 <printf@plt>
jmp    125a <main+0xea>
movslq -0x74(%rbp),%rax
movzbl -0x70(%rbp,%rax,1),%edi
call   1030 <putchar@plt>
jmp    125f <main+0xef>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    120c <main+0x9c>
jmp    11e9 <main+0x79>
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x50,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
je     118c <main+0x1c>
xor    %eax,%eax
call   1070 <usage@plt>
mov    0x8(%rbx),%rdi
lea    0xe69(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1234 <main+0xc4>
mov    %rax,%r15
mov    %rsp,%rdi
mov    $0x50,%esi
mov    %rax,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     1224 <main+0xb4>
lea    0x1(%rsp),%r12
mov    %rsp,%r14
lea    0xe46(%rip),%r13
jmp    11e5 <main+0x75>
xchg   %ax,%ax
mov    %r14,%rdi
mov    $0x50,%esi
mov    %r15,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     1224 <main+0xb4>
mov    (%rsp),%al
test   %al,%al
je     11d0 <main+0x60>
mov    %r12,%rbx
jmp    1213 <main+0xa3>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl %al,%edi
call   1030 <putchar@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     11d0 <main+0x60>
cmp    $0x81,%al
jb     1200 <main+0x90>
movzbl %al,%esi
mov    %r13,%rdi
call   1040 <printf@plt>
jmp    1208 <main+0x98>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
mov    0x2da5(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xdba(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [16 x i8] c"%s: can't open\0A\00"
@.str.2 = [7 x i8] c"^^%02x\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [80 x i8]
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 (...) @usage()
br label %13
13: ; preds = %11, %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %17, i32** %6
%18 = load i32*, i32** %6
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %27
20: ; preds = %13
%21 = load i32, i32* @stderr
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %24)
%26 = call i32 @exit(i32 1)
unreachable
27: ; preds = %13
br label %28
28: ; preds = %64, %27
%29 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%30 = load i32*, i32** %6
%31 = call i32* @fgets(i8* %29, i32 80, i32* %30)
%32 = icmp ne i32* %31, null
br i1 %32, label %33, label %65
33: ; preds = %28
store i32 0, i32* %8
br label %34
34: ; preds = %61, %33
%35 = load i32, i32* %8
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 %36
%38 = load i8, i8* %37
%39 = zext i8 %38 to i32
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %64
41: ; preds = %34
%42 = load i32, i32* %8
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 %43
%45 = load i8, i8* %44
%46 = zext i8 %45 to i32
%47 = icmp sgt i32 %46, 128
br i1 %47, label %48, label %54
48: ; preds = %41
%49 = load i32, i32* %8
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 %50
%52 = load i8, i8* %51
%53 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %52)
br label %60
54: ; preds = %41
%55 = load i32, i32* %8
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 %56
%58 = load i8, i8* %57
%59 = call i32 @putchar(i8 zeroext %58)
br label %60
60: ; preds = %54, %48
br label %61
61: ; preds = %60
%62 = load i32, i32* %8
%63 = add nsw i32 %62, 1
store i32 %63, i32* %8
br label %34
64: ; preds = %34
br label %28
65: ; preds = %28
%66 = load i32, i32* %3
ret i32 %66
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [16 x i8] c"%s: can't open\0A\00"
@.str.2 = [7 x i8] c"^^%02x\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [80 x i8]
%4 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 2
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = tail call i32 (...) @usage()
br label %8
8: ; preds = %6, %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 %16, label %13
13: ; preds = %8
%14 = call i32* @fgets(i8* %4, i32 80, i32* %11)
%15 = icmp eq i32* %14, null
br i1 %15, label %40, label %24
16: ; preds = %8
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %9
%19 = tail call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%20 = tail call i32 @exit(i32 1)
unreachable
21: ; preds = %35, %24
%22 = call i32* @fgets(i8* %4, i32 80, i32* %11)
%23 = icmp eq i32* %22, null
br i1 %23, label %40, label %24
24: ; preds = %13, %21
%25 = load i8, i8* %4
%26 = icmp eq i8 %25, 0
br i1 %26, label %21, label %27
27: ; preds = %24, %35
%28 = phi i64 [ %36, %35 ], [ 0, %24 ]
%29 = phi i8 [ %38, %35 ], [ %25, %24 ]
%30 = icmp ugt i8 %29, -128
br i1 %30, label %31, label %33
31: ; preds = %27
%32 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %29)
br label %35
33: ; preds = %27
%34 = call i32 @putchar(i8 zeroext %29)
br label %35
35: ; preds = %31, %33
%36 = add nuw i64 %28, 1
%37 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 %36
%38 = load i8, i8* %37
%39 = icmp eq i8 %38, 0
br i1 %39, label %21, label %27
40: ; preds = %21, %13
ret i32 0
}