#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *);
int reoxoo(char);
int main() {
  FILE *fpin;
  FILE *fpout;
  char str[2];
  fpin = fopen("test.264.txt", "rb");
  if (fpin == NULL) {
    printf("error: files can not open!\n");
    exit(1);
  }
  fpout = fopen("test.264", "wb");
  for (; !feof(fpin);) {
    fscanf(fpin, "%s", str);
    fprintf(fpout, "%c", 16 * reoxoo(str[0]) + reoxoo(str[1]));
  }
  fclose(fpin);
  fclose(fpout);
  printf("ok");
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe5a(%rip),%rdi
lea    0xe60(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11d7 <main+0x47>
lea    0xe48(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
lea    0xe4e(%rip),%rdi
lea    0xe50(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1090 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    120c <main+0x7c>
jmp    125a <main+0xca>
mov    -0x10(%rbp),%rdi
lea    -0x1a(%rbp),%rdx
lea    0xe1d(%rip),%rsi
call   1060 <fscanf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
movsbl -0x1a(%rbp),%edi
call   1030 <reoxoo@plt>
shl    $0x4,%eax
mov    %eax,-0x2c(%rbp)
movsbl -0x19(%rbp),%edi
call   1030 <reoxoo@plt>
mov    -0x2c(%rbp),%edx
mov    -0x28(%rbp),%rdi
add    %eax,%edx
lea    0xdeb(%rip),%rsi
call   1080 <fprintf@plt>
jmp    11ee <main+0x5e>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xdcb(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1070 <getchar@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xe4d(%rip),%rdi
lea    0xe53(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     1271 <main+0xd1>
mov    %rax,%rbx
lea    0xe3e(%rip),%rdi
lea    0xe40(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   10a0 <feof@plt>
test   %eax,%eax
jne    123f <main+0x9f>
lea    0xe28(%rip),%r15
lea    0xe(%rsp),%r12
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1070 <fscanf@plt>
movsbl 0xe(%rsp),%edi
call   1030 <reoxoo@plt>
mov    %eax,%ebp
shl    $0x4,%ebp
movsbl 0xf(%rsp),%edi
call   1030 <reoxoo@plt>
add    %eax,%ebp
mov    %ebp,%edi
mov    %r14,%rsi
call   1080 <fputc@plt>
mov    %rbx,%rdi
call   10a0 <feof@plt>
test   %eax,%eax
je     1200 <main+0x60>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
lea    0xdc9(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
call   1090 <getchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdaa(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"test.264.txt\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [28 x i8] c"error: files can not open!\0A\00"
@.str.3 = [9 x i8] c"test.264\00"
@.str.4 = [3 x i8] c"wb\00"
@.str.5 = [3 x i8] c"%s\00"
@.str.6 = [3 x i8] c"%c\00"
@.str.7 = [3 x i8] c"ok\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca [2 x i8]
store i32 0, i32* %1
%5 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %5, i32** %2
%6 = load i32*, i32** %2
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @exit(i32 1)
unreachable
11: ; preds = %0
%12 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %12, i32** %3
br label %13
13: ; preds = %18, %11
%14 = load i32*, i32** %2
%15 = call i32 @feof(i32* %14)
%16 = icmp ne i32 %15, 0
%17 = xor i1 %16, true
br i1 %17, label %18, label %32
18: ; preds = %13
%19 = load i32*, i32** %2
%20 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%21 = call i32 @fscanf(i32* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %20)
%22 = load i32*, i32** %3
%23 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%24 = load i8, i8* %23
%25 = call i32 @reoxoo(i8 signext %24)
%26 = mul nsw i32 16, %25
%27 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 1
%28 = load i8, i8* %27
%29 = call i32 @reoxoo(i8 signext %28)
%30 = add nsw i32 %26, %29
%31 = call i32 @fprintf(i32* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %30)
br label %13
32: ; preds = %13
%33 = load i32*, i32** %2
%34 = call i32 @fclose(i32* %33)
%35 = load i32*, i32** %3
%36 = call i32 @fclose(i32* %35)
%37 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%38 = call i32 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"test.264.txt\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.3 = [9 x i8] c"test.264\00"
@.str.4 = [3 x i8] c"wb\00"
@.str.5 = [3 x i8] c"%s\00"
@.str.7 = [3 x i8] c"ok\00"
@str = [27 x i8] c"error: files can not open!\00"
define i32 @main() {
%1 = alloca [2 x i8]
%2 = getelementptr inbounds [2 x i8], [2 x i8]* %1, i64 0, i64 0
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %8
5: ; preds = %0
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %0
%9 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%10 = call i32 @feof(i32* %3)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %25
12: ; preds = %8
%13 = getelementptr inbounds [2 x i8], [2 x i8]* %1, i64 0, i64 1
br label %14
14: ; preds = %12, %14
%15 = call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %2)
%16 = load i8, i8* %2
%17 = call i32 @reoxoo(i8 signext %16)
%18 = shl nsw i32 %17, 4
%19 = load i8, i8* %13
%20 = call i32 @reoxoo(i8 signext %19)
%21 = add nsw i32 %20, %18
%22 = call i32 @fputc(i32 %21, i32* %9)
%23 = call i32 @feof(i32* %3)
%24 = icmp eq i32 %23, 0
br i1 %24, label %14, label %25
25: ; preds = %14, %8
%26 = call i32 @fclose(i32* %3)
%27 = call i32 @fclose(i32* %9)
%28 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%29 = call i32 (...) @getchar()
ret i32 0
}