#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, unsigned int *);
int /*<<< orphan*/ printf(char *, unsigned int);
int scanf(char *, unsigned int *);
int main(int argc, char *argv[]) {
  unsigned int map[0x100];
  unsigned int letter_map[0x10000];
  unsigned int i;
  FILE *f;
  f = fopen(argv[1], "r");
  for (i = 0; i < 0x100; i++)
    fscanf(f, "%x", map + i);
  fclose(f);
  for (i = 0; i < 0x10000; i++)
    letter_map[i] = 0;
  while (scanf("%x", &i) == 1)
    letter_map[i] = 1;
  for (i = 0; i < 0x100; i++) {
    if (letter_map[map[i]])
      printf("%02x\n", i);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40420,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe88(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x40420(%rbp)
movl   $0x0,-0x40414(%rbp)
cmpl   $0x100,-0x40414(%rbp)
jae    11d9 <main+0x89>
mov    -0x40420(%rbp),%rdi
lea    -0x410(%rbp),%rdx
mov    -0x40414(%rbp),%eax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xe42(%rip),%rsi
call   1050 <fscanf@plt>
mov    -0x40414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40414(%rbp)
jmp    118e <main+0x3e>
mov    -0x40420(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x40414(%rbp)
cmpl   $0x10000,-0x40414(%rbp)
jae    1224 <main+0xd4>
mov    -0x40414(%rbp),%eax
movl   $0x0,-0x40410(%rbp,%rax,4)
mov    -0x40414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40414(%rbp)
jmp    11ef <main+0x9f>
jmp    1229 <main+0xd9>
lea    0xdd2(%rip),%rdi
lea    -0x40414(%rbp),%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    125b <main+0x10b>
mov    -0x40414(%rbp),%eax
movl   $0x1,-0x40410(%rbp,%rax,4)
jmp    1229 <main+0xd9>
movl   $0x0,-0x40414(%rbp)
cmpl   $0x100,-0x40414(%rbp)
jae    12bb <main+0x16b>
mov    -0x40414(%rbp),%eax
mov    -0x410(%rbp,%rax,4),%eax
cmpl   $0x0,-0x40410(%rbp,%rax,4)
je     12a2 <main+0x152>
mov    -0x40414(%rbp),%esi
lea    0xd68(%rip),%rdi
call   1040 <printf@plt>
jmp    12a7 <main+0x157>
mov    -0x40414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40414(%rbp)
jmp    1265 <main+0x115>
xor    %eax,%eax
add    $0x40420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x40418,%rsp
mov    0x8(%rsi),%rdi
lea    0xe88(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r14
mov    $0xffffffff,%ebp
lea    0x10(%rsp),%rbx
lea    0xe71(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1060 <fscanf@plt>
add    $0x1,%ebp
add    $0x4,%rbx
cmp    $0xff,%ebp
jb     11a0 <main+0x40>
mov    %r14,%rdi
call   1030 <fclose@plt>
lea    0x410(%rsp),%rdi
xor    %ebx,%ebx
mov    $0x40000,%edx
xor    %esi,%esi
call   1050 <memset@plt>
movl   $0x10000,0xc(%rsp)
lea    0xe18(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
cmp    $0x1,%eax
jne    122f <main+0xcf>
lea    0xe02(%rip),%r14
lea    0xc(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
nop
mov    0xc(%rsp),%eax
movl   $0x1,0x410(%rsp,%rax,4)
mov    %r14,%rdi
mov    %r15,%rsi
call   1070 <scanf@plt>
cmp    $0x1,%eax
je     1210 <main+0xb0>
movl   $0x0,0xc(%rsp)
lea    0xdc7(%rip),%r14
jmp    124f <main+0xef>
add    $0x1,%ebx
mov    %ebx,0xc(%rsp)
cmp    $0x100,%ebx
jae    126f <main+0x10f>
mov    %ebx,%eax
mov    0x10(%rsp,%rax,4),%eax
cmpl   $0x0,0x410(%rsp,%rax,4)
je     1240 <main+0xe0>
mov    %r14,%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
mov    0xc(%rsp),%ebx
jmp    1240 <main+0xe0>
xor    %eax,%eax
add    $0x40418,%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"%x\00"
@.str.2 = [6 x i8] c"%02x\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [256 x i32]
%7 = alloca [65536 x i32]
%8 = alloca i32
%9 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %13, i32** %9
store i32 0, i32* %8
br label %14
14: ; preds = %24, %2
%15 = load i32, i32* %8
%16 = icmp ult i32 %15, 256
br i1 %16, label %17, label %27
17: ; preds = %14
%18 = load i32*, i32** %9
%19 = getelementptr inbounds [256 x i32], [256 x i32]* %6, i64 0, i64 0
%20 = load i32, i32* %8
%21 = zext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %19, i64 %21
%23 = call i32 @fscanf(i32* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %22)
br label %24
24: ; preds = %17
%25 = load i32, i32* %8
%26 = add i32 %25, 1
store i32 %26, i32* %8
br label %14
27: ; preds = %14
%28 = load i32*, i32** %9
%29 = call i32 @fclose(i32* %28)
store i32 0, i32* %8
br label %30
30: ; preds = %37, %27
%31 = load i32, i32* %8
%32 = icmp ult i32 %31, 65536
br i1 %32, label %33, label %40
33: ; preds = %30
%34 = load i32, i32* %8
%35 = zext i32 %34 to i64
%36 = getelementptr inbounds [65536 x i32], [65536 x i32]* %7, i64 0, i64 %35
store i32 0, i32* %36
br label %37
37: ; preds = %33
%38 = load i32, i32* %8
%39 = add i32 %38, 1
store i32 %39, i32* %8
br label %30
40: ; preds = %30
br label %41
41: ; preds = %44, %40
%42 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%43 = icmp eq i32 %42, 1
br i1 %43, label %44, label %48
44: ; preds = %41
%45 = load i32, i32* %8
%46 = zext i32 %45 to i64
%47 = getelementptr inbounds [65536 x i32], [65536 x i32]* %7, i64 0, i64 %46
store i32 1, i32* %47
br label %41
48: ; preds = %41
store i32 0, i32* %8
br label %49
49: ; preds = %65, %48
%50 = load i32, i32* %8
%51 = icmp ult i32 %50, 256
br i1 %51, label %52, label %68
52: ; preds = %49
%53 = load i32, i32* %8
%54 = zext i32 %53 to i64
%55 = getelementptr inbounds [256 x i32], [256 x i32]* %6, i64 0, i64 %54
%56 = load i32, i32* %55
%57 = zext i32 %56 to i64
%58 = getelementptr inbounds [65536 x i32], [65536 x i32]* %7, i64 0, i64 %57
%59 = load i32, i32* %58
%60 = icmp ne i32 %59, 0
br i1 %60, label %61, label %64
61: ; preds = %52
%62 = load i32, i32* %8
%63 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %62)
br label %64
64: ; preds = %61, %52
br label %65
65: ; preds = %64
%66 = load i32, i32* %8
%67 = add i32 %66, 1
store i32 %67, i32* %8
br label %49
68: ; preds = %49
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"%x\00"
@.str.2 = [6 x i8] c"%02x\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [256 x i32]
%4 = alloca [65536 x i32]
%5 = bitcast [65536 x i32]* %4 to i8*
%6 = alloca i32
%7 = bitcast [256 x i32]* %3 to i8*
%8 = bitcast i32* %6 to i8*
%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))
br label %12
12: ; preds = %2, %12
%13 = phi i32 [ 0, %2 ], [ %17, %12 ]
%14 = zext i32 %13 to i64
%15 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 %14
%16 = call i32 @fscanf(i32* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %15)
%17 = add nuw nsw i32 %13, 1
%18 = icmp ult i32 %13, 255
br i1 %18, label %12, label %19
19: ; preds = %12
%20 = call i32 @fclose(i32* %11)
store i32 65536, i32* %6
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%22 = icmp eq i32 %21, 1
br i1 %22, label %24, label %23
23: ; preds = %24, %19
store i32 0, i32* %6
br label %30
24: ; preds = %19, %24
%25 = load i32, i32* %6
%26 = zext i32 %25 to i64
%27 = getelementptr inbounds [65536 x i32], [65536 x i32]* %4, i64 0, i64 %26
store i32 1, i32* %27
%28 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%29 = icmp eq i32 %28, 1
br i1 %29, label %24, label %23
30: ; preds = %23, %42
%31 = phi i32 [ 0, %23 ], [ %44, %42 ]
%32 = zext i32 %31 to i64
%33 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 %32
%34 = load i32, i32* %33
%35 = zext i32 %34 to i64
%36 = getelementptr inbounds [65536 x i32], [65536 x i32]* %4, i64 0, i64 %35
%37 = load i32, i32* %36
%38 = icmp eq i32 %37, 0
br i1 %38, label %42, label %39
39: ; preds = %30
%40 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %31)
%41 = load i32, i32* %6
br label %42
42: ; preds = %30, %39
%43 = phi i32 [ %31, %30 ], [ %41, %39 ]
%44 = add i32 %43, 1
store i32 %44, i32* %6
%45 = icmp ult i32 %44, 256
br i1 %45, label %30, label %46
46: ; preds = %42
ret i32 0
}