#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 EOF;
char codeToChar(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ printf(char *, char);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  if (argc != 2) {
    fprintf(stderr, "Usage: %s <bwtfile>\n", argv[0]);
    return 1;
  }
  FILE *pFile;
  int c;
  char c1, c2;
  pFile = fopen(argv[1], "r");
  if (pFile == NULL) {
    fprintf(stderr, "Error while opening the file\n");
    return 1;
  } else {
    while ((c = fgetc(pFile)) != EOF) {
      c1 = codeToChar((c >> 4));
      c2 = codeToChar((c & 0b1111));
      printf("%c", c1);
      if (c2 != '@')
        printf("%c", c2);
    }
  }
  fclose(pFile);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11aa <main+0x4a>
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe69(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1273 <main+0x113>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe5c(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11f0 <main+0x90>
mov    0x2e04(%rip),%rax
mov    (%rax),%edi
lea    0xe3a(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1273 <main+0x113>
jmp    11f5 <main+0x95>
mov    -0x18(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2de0(%rip),%rcx
cmp    (%rcx),%eax
je     125e <main+0xfe>
mov    -0x1c(%rbp),%edi
sar    $0x4,%edi
call   1080 <codeToChar@plt>
mov    %al,-0x1d(%rbp)
mov    -0x1c(%rbp),%edi
and    $0xf,%edi
call   1080 <codeToChar@plt>
mov    %al,-0x1e(%rbp)
lea    0xe02(%rip),%rdi
movsbl -0x1d(%rbp),%esi
call   1040 <printf@plt>
movsbl -0x1e(%rbp),%eax
cmp    $0x40,%eax
je     1259 <main+0xf9>
lea    0xde5(%rip),%rdi
movsbl -0x1e(%rbp),%esi
call   1040 <printf@plt>
jmp    11f5 <main+0x95>
jmp    1263 <main+0x103>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    11a9 <main+0x49>
mov    0x8(%rsi),%rdi
lea    0xe9a(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11c5 <main+0x65>
mov    %rax,%r15
mov    %rax,%rdi
call   1050 <fgetc@plt>
mov    0x2e51(%rip),%r13
cmp    0x0(%r13),%eax
jne    11f0 <main+0x90>
mov    %r15,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
jmp    11e1 <main+0x81>
mov    0x2e28(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xe44(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    11dc <main+0x7c>
mov    0x2e0c(%rip),%rax
mov    (%rax),%edi
lea    0xe42(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebp
lea    0xe3c(%rip),%r14
jmp    1210 <main+0xb0>
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1050 <fgetc@plt>
mov    %eax,%ebp
cmp    0x0(%r13),%eax
je     119d <main+0x3d>
mov    %ebp,%edi
sar    $0x4,%edi
call   1080 <codeToChar@plt>
mov    %eax,%r12d
and    $0xf,%ebp
mov    %ebp,%edi
call   1080 <codeToChar@plt>
mov    %eax,%ebx
movsbl %r12b,%esi
mov    %r14,%rdi
call   1040 <printf@plt>
cmp    $0x40,%bl
je     1200 <main+0xa0>
movsbl %bl,%esi
mov    %r14,%rdi
call   1040 <printf@plt>
jmp    1200 <main+0xa0>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [21 x i8] c"Usage: %s <bwtfile>\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [30 x i8] c"Error while opening the file\0A\00"
@EOF = global i32 0
@.str.3 = [3 x i8] c"%c\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i8
%9 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 2
br i1 %11, label %12, label %18
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %16)
store i32 1, i32* %3
br label %54
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32* @fopen(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %22, i32** %6
%23 = load i32*, i32** %6
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %28
25: ; preds = %18
%26 = load i32, i32* @stderr
%27 = call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %54
28: ; preds = %18
br label %29
29: ; preds = %49, %28
%30 = load i32*, i32** %6
%31 = call i32 @fgetc(i32* %30)
store i32 %31, i32* %7
%32 = load i32, i32* @EOF
%33 = icmp ne i32 %31, %32
br i1 %33, label %34, label %50
34: ; preds = %29
%35 = load i32, i32* %7
%36 = ashr i32 %35, 4
%37 = call signext i8 @codeToChar(i32 %36)
store i8 %37, i8* %8
%38 = load i32, i32* %7
%39 = and i32 %38, 15
%40 = call signext i8 @codeToChar(i32 %39)
store i8 %40, i8* %9
%41 = load i8, i8* %8
%42 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8 signext %41)
%43 = load i8, i8* %9
%44 = sext i8 %43 to i32
%45 = icmp ne i32 %44, 64
br i1 %45, label %46, label %49
46: ; preds = %34
%47 = load i8, i8* %9
%48 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8 signext %47)
br label %49
49: ; preds = %46, %34
br label %29
50: ; preds = %29
br label %51
51: ; preds = %50
%52 = load i32*, i32** %6
%53 = call i32 @fclose(i32* %52)
store i32 0, i32* %3
br label %54
54: ; preds = %51, %25, %12
%55 = load i32, i32* %3
ret i32 %55
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [21 x i8] c"Usage: %s <bwtfile>\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [30 x i8] c"Error while opening the file\0A\00"
@EOF = global i32 0
@.str.3 = [3 x i8] c"%c\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %36
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 ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %17, label %13
13: ; preds = %8
%14 = tail call i32 @fgetc(i32* %11)
%15 = load i32, i32* @EOF
%16 = icmp eq i32 %14, %15
br i1 %16, label %34, label %20
17: ; preds = %8
%18 = load i32, i32* @stderr
%19 = tail call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
br label %36
20: ; preds = %13, %30
%21 = phi i32 [ %31, %30 ], [ %14, %13 ]
%22 = ashr i32 %21, 4
%23 = tail call signext i8 @codeToChar(i32 %22)
%24 = and i32 %21, 15
%25 = tail call signext i8 @codeToChar(i32 %24)
%26 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8 signext %23)
%27 = icmp eq i8 %25, 64
br i1 %27, label %30, label %28
28: ; preds = %20
%29 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8 signext %25)
br label %30
30: ; preds = %28, %20
%31 = tail call i32 @fgetc(i32* %11)
%32 = load i32, i32* @EOF
%33 = icmp eq i32 %31, %32
br i1 %33, label %34, label %20
34: ; preds = %30, %13
%35 = tail call i32 @fclose(i32* %11)
br label %36
36: ; preds = %17, %34, %4
%37 = phi i32 [ 1, %4 ], [ 1, %17 ], [ 0, %34 ]
ret i32 %37
}