#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*/ x6;
typedef int /*<<< orphan*/ line;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
unsigned char AtoH(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fwrite(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(unsigned char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int strlen(char *);
char *strtok(char *, char *);
int main(int argc, char *argv[]) {
  char dst_file[20], line[100], *p, xb[2];
  FILE *fp_s, *fp_d;
  unsigned char x, x6[16];
  int i = 0;
  int j = 0;
  if (!argv[1]) {
    printf("no src file\n");
    return -1;
  } else {
    sprintf(dst_file, "%s_v.bin", argv[1]);
  }
  if (((fp_s = fopen(argv[1], "r")) == NULL) ||
      ((fp_d = fopen(dst_file, "w+")) == NULL)) {
    printf("open src/dst fail\n");
    return -1;
  }
  while (fgets(line, sizeof(line), fp_s) != (char *)0) {
    if (line[8] == ':' && line[9] == ' ') {
      p = line;
      i = 0;
      memset(x6, 0, sizeof(x6));
      while (p) {
        p = strtok(p, "\r\n ");
        if (p == NULL)
          break;
        if (strlen(p) > 3) {
          p += strlen(p) + 1;
          continue;
        }
        xb[0] = *p;
        xb[1] = *(p + 1);
        x = AtoH(xb);
        x6[i++] = x;
        p += strlen(p) + 1;
      }
      if (*x6)
        fwrite(x6, 1, sizeof(x6), fp_d);
    }
  }
  fclose(fp_s);
  fclose(fp_d);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0xe4(%rbp)
movl   $0x0,-0xe8(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x8(%rax)
jne    11f4 <main+0x54>
lea    0xe1d(%rip),%rdi
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1424 <main+0x284>
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe06(%rip),%rsi
call   10a0 <sprintf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdfb(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0xb8(%rbp)
cmp    $0x0,%rax
je     1252 <main+0xb2>
lea    -0x30(%rbp),%rdi
lea    0xddc(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0xc0(%rbp)
cmp    $0x0,%rax
jne    126a <main+0xca>
lea    0xdc2(%rip),%rdi
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1424 <main+0x284>
jmp    126f <main+0xcf>
lea    -0xa0(%rbp),%rdi
mov    -0xb8(%rbp),%rdx
mov    $0x64,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     1405 <main+0x265>
movsbl -0x98(%rbp),%eax
cmp    $0x3a,%eax
jne    1400 <main+0x260>
movsbl -0x97(%rbp),%eax
cmp    $0x20,%eax
jne    1400 <main+0x260>
lea    -0xa0(%rbp),%rax
mov    %rax,-0xa8(%rbp)
movl   $0x0,-0xe4(%rbp)
lea    -0xe0(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1060 <memset@plt>
cmpq   $0x0,-0xa8(%rbp)
je     13d1 <main+0x231>
mov    -0xa8(%rbp),%rdi
lea    0xd36(%rip),%rsi
call   1090 <strtok@plt>
mov    %rax,-0xa8(%rbp)
cmpq   $0x0,-0xa8(%rbp)
jne    1317 <main+0x177>
jmp    13d1 <main+0x231>
mov    -0xa8(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x3,%eax
jle    1356 <main+0x1b6>
mov    -0xa8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
add    $0x1,%ecx
mov    -0xa8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0xa8(%rbp)
jmp    12dc <main+0x13c>
mov    -0xa8(%rbp),%rax
mov    (%rax),%al
mov    %al,-0xaa(%rbp)
mov    -0xa8(%rbp),%rax
mov    0x1(%rax),%al
mov    %al,-0xa9(%rbp)
lea    -0xaa(%rbp),%rdi
call   10c0 <AtoH@plt>
mov    %al,-0xc1(%rbp)
mov    -0xc1(%rbp),%cl
mov    -0xe4(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0xe4(%rbp)
cltq
mov    %cl,-0xe0(%rbp,%rax,1)
mov    -0xa8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
add    $0x1,%ecx
mov    -0xa8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0xa8(%rbp)
jmp    12dc <main+0x13c>
cmpb   $0x0,-0xe0(%rbp)
je     13fb <main+0x25b>
lea    -0xe0(%rbp),%rdi
mov    -0xc0(%rbp),%rcx
mov    $0x1,%esi
mov    $0x10,%edx
call   10b0 <fwrite@plt>
jmp    1400 <main+0x260>
jmp    126f <main+0xcf>
mov    -0xb8(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0xc0(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa8,%rsp
mov    0x8(%rsi),%rdx
test   %rdx,%rdx
je     1317 <main+0x177>
mov    %rsi,%rbx
lea    0xe38(%rip),%rsi
lea    0x20(%rsp),%rdi
call   10a0 <sprintf@plt>
mov    0x8(%rbx),%rdi
lea    0xe2c(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1320 <main+0x180>
mov    %rax,%r12
lea    0xe16(%rip),%rsi
lea    0x20(%rsp),%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     1320 <main+0x180>
mov    %rax,%r14
lea    0x40(%rsp),%rdi
mov    $0x64,%esi
mov    %r12,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     1333 <main+0x193>
lea    0xde1(%rip),%rbx
lea    0x40(%rsp),%r13
jmp    1259 <main+0xb9>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r13,%rdi
mov    $0x64,%esi
mov    %r12,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     1333 <main+0x193>
cmpb   $0x3a,0x48(%rsp)
jne    1240 <main+0xa0>
cmpb   $0x20,0x49(%rsp)
jne    1240 <main+0xa0>
lea    0x10(%rsp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1060 <memset@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1090 <strtok@plt>
test   %rax,%rax
je     12f0 <main+0x150>
mov    %rax,%rbp
xor    %r15d,%r15d
xchg   %ax,%ax
mov    %rbp,%rdi
call   1050 <strlen@plt>
cmp    $0x4,%eax
jl     12c1 <main+0x121>
mov    %rbp,%rdi
call   1050 <strlen@plt>
cltq
lea    (%rax,%rbp,1),%rdi
add    $0x1,%rdi
mov    %rbx,%rsi
call   1090 <strtok@plt>
mov    %rax,%rbp
test   %rax,%rax
jne    1290 <main+0xf0>
jmp    12f0 <main+0x150>
movzbl 0x0(%rbp),%eax
mov    %al,0xe(%rsp)
movzbl 0x1(%rbp),%eax
mov    %al,0xf(%rsp)
lea    0xe(%rsp),%rdi
call   10c0 <AtoH@plt>
mov    %al,0x10(%rsp,%r15,1)
add    $0x1,%r15
jmp    129d <main+0xfd>
cs nopw 0x0(%rax,%rax,1)
cmpb   $0x0,0x10(%rsp)
je     1240 <main+0xa0>
lea    0x10(%rsp),%rdi
mov    $0x1,%esi
mov    $0x10,%edx
mov    %r14,%rcx
call   10b0 <fwrite@plt>
jmp    1240 <main+0xa0>
lea    0xcf4(%rip),%rdi
jmp    1327 <main+0x187>
lea    0xcf7(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
jmp    1345 <main+0x1a5>
mov    %r12,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0xa8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"no src file\0A\00"
@.str.1 = [9 x i8] c"%s_v.bin\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [3 x i8] c"w+\00"
@.str.4 = [19 x i8] c"open src/dst fail\0A\00"
@.str.5 = [4 x i8] c"\0D\0A \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [20 x i8]
%7 = alloca [100 x i8]
%8 = alloca i8*
%9 = alloca [2 x i8]
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i8
%13 = alloca [16 x i8]
%14 = alloca i32
%15 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %14
store i32 0, i32* %15
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = icmp ne i8* %18, null
br i1 %19, label %22, label %20
20: ; preds = %2
%21 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %116
22: ; preds = %2
%23 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32 @sprintf(i8* %23, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %26)
br label %28
28: ; preds = %22
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = call i32* @fopen(i8* %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %32, i32** %10
%33 = icmp eq i32* %32, null
br i1 %33, label %38, label %34
34: ; preds = %28
%35 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%36 = call i32* @fopen(i8* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %36, i32** %11
%37 = icmp eq i32* %36, null
br i1 %37, label %38, label %40
38: ; preds = %34, %28
%39 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %3
br label %116
40: ; preds = %34
br label %41
41: ; preds = %110, %40
%42 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%43 = load i32*, i32** %10
%44 = call i8* @fgets(i8* %42, i32 100, i32* %43)
%45 = icmp ne i8* %44, null
br i1 %45, label %46, label %111
46: ; preds = %41
%47 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 8
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = icmp eq i32 %49, 58
br i1 %50, label %51, label %110
51: ; preds = %46
%52 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 9
%53 = load i8, i8* %52
%54 = sext i8 %53 to i32
%55 = icmp eq i32 %54, 32
br i1 %55, label %56, label %110
56: ; preds = %51
%57 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
store i8* %57, i8** %8
store i32 0, i32* %14
%58 = getelementptr inbounds [16 x i8], [16 x i8]* %13, i64 0, i64 0
%59 = call i32 @memset(i8* %58, i32 0, i32 16)
br label %60
60: ; preds = %80, %73, %56
%61 = load i8*, i8** %8
%62 = icmp ne i8* %61, null
br i1 %62, label %63, label %101
63: ; preds = %60
%64 = load i8*, i8** %8
%65 = call i8* @strtok(i8* %64, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
store i8* %65, i8** %8
%66 = load i8*, i8** %8
%67 = icmp eq i8* %66, null
br i1 %67, label %68, label %69
68: ; preds = %63
br label %101
69: ; preds = %63
%70 = load i8*, i8** %8
%71 = call i32 @strlen(i8* %70)
%72 = icmp sgt i32 %71, 3
br i1 %72, label %73, label %80
73: ; preds = %69
%74 = load i8*, i8** %8
%75 = call i32 @strlen(i8* %74)
%76 = add nsw i32 %75, 1
%77 = load i8*, i8** %8
%78 = sext i32 %76 to i64
%79 = getelementptr inbounds i8, i8* %77, i64 %78
store i8* %79, i8** %8
br label %60
80: ; preds = %69
%81 = load i8*, i8** %8
%82 = load i8, i8* %81
%83 = getelementptr inbounds [2 x i8], [2 x i8]* %9, i64 0, i64 0
store i8 %82, i8* %83
%84 = load i8*, i8** %8
%85 = getelementptr inbounds i8, i8* %84, i64 1
%86 = load i8, i8* %85
%87 = getelementptr inbounds [2 x i8], [2 x i8]* %9, i64 0, i64 1
store i8 %86, i8* %87
%88 = getelementptr inbounds [2 x i8], [2 x i8]* %9, i64 0, i64 0
%89 = call zeroext i8 @AtoH(i8* %88)
store i8 %89, i8* %12
%90 = load i8, i8* %12
%91 = load i32, i32* %14
%92 = add nsw i32 %91, 1
store i32 %92, i32* %14
%93 = sext i32 %91 to i64
%94 = getelementptr inbounds [16 x i8], [16 x i8]* %13, i64 0, i64 %93
store i8 %90, i8* %94
%95 = load i8*, i8** %8
%96 = call i32 @strlen(i8* %95)
%97 = add nsw i32 %96, 1
%98 = load i8*, i8** %8
%99 = sext i32 %97 to i64
%100 = getelementptr inbounds i8, i8* %98, i64 %99
store i8* %100, i8** %8
br label %60
101: ; preds = %68, %60
%102 = getelementptr inbounds [16 x i8], [16 x i8]* %13, i64 0, i64 0
%103 = load i8, i8* %102
%104 = icmp ne i8 %103, 0
br i1 %104, label %105, label %109
105: ; preds = %101
%106 = getelementptr inbounds [16 x i8], [16 x i8]* %13, i64 0, i64 0
%107 = load i32*, i32** %11
%108 = call i32 @fwrite(i8* %106, i32 1, i32 16, i32* %107)
br label %109
109: ; preds = %105, %101
br label %110
110: ; preds = %109, %51, %46
br label %41
111: ; preds = %41
%112 = load i32*, i32** %10
%113 = call i32 @fclose(i32* %112)
%114 = load i32*, i32** %11
%115 = call i32 @fclose(i32* %114)
store i32 0, i32* %3
br label %116
116: ; preds = %111, %38, %20
%117 = load i32, i32* %3
ret i32 %117
}

LLVM IR (-O2):
@.str.1 = [9 x i8] c"%s_v.bin\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [3 x i8] c"w+\00"
@.str.5 = [4 x i8] c"\0D\0A \00"
@str = [12 x i8] c"no src file\00"
@str.6 = [18 x i8] c"open src/dst fail\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [20 x i8]
%4 = alloca [100 x i8]
%5 = alloca [2 x i8]
%6 = alloca [16 x i8]
%7 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%9 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%10 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
br label %81
16: ; preds = %2
%17 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%18 = load i8*, i8** %11
%19 = tail call i32* @fopen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp eq i32* %19, null
br i1 %20, label %31, label %21
21: ; preds = %16
%22 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%23 = icmp eq i32* %22, null
br i1 %23, label %31, label %24
24: ; preds = %21
%25 = call i8* @fgets(i8* %8, i32 100, i32* %19)
%26 = icmp eq i8* %25, null
br i1 %26, label %78, label %27
27: ; preds = %24
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 8
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 9
%30 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 1
br label %33
31: ; preds = %21, %16
%32 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.6, i64 0, i64 0))
br label %81
33: ; preds = %27, %75
%34 = load i8, i8* %28
%35 = icmp eq i8 %34, 58
%36 = load i8, i8* %29
%37 = icmp eq i8 %36, 32
%38 = select i1 %35, i1 %37, i1 false
br i1 %38, label %39, label %75
39: ; preds = %33
%40 = call i32 @memset(i8* %10, i32 0, i32 16)
%41 = call i8* @strtok(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%42 = icmp eq i8* %41, null
br i1 %42, label %70, label %43
43: ; preds = %39, %57
%44 = phi i64 [ %62, %57 ], [ 0, %39 ]
%45 = phi i8* [ %68, %57 ], [ %41, %39 ]
br label %46
46: ; preds = %43, %50
%47 = phi i8* [ %45, %43 ], [ %55, %50 ]
%48 = call i32 @strlen(i8* %47)
%49 = icmp sgt i32 %48, 3
br i1 %49, label %50, label %57
50: ; preds = %46
%51 = call i32 @strlen(i8* %47)
%52 = add nsw i32 %51, 1
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8, i8* %47, i64 %53
%55 = call i8* @strtok(i8* %54, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%56 = icmp eq i8* %55, null
br i1 %56, label %70, label %46
57: ; preds = %46
%58 = load i8, i8* %47
store i8 %58, i8* %9
%59 = getelementptr inbounds i8, i8* %47, i64 1
%60 = load i8, i8* %59
store i8 %60, i8* %30
%61 = call zeroext i8 @AtoH(i8* %9)
%62 = add nuw i64 %44, 1
%63 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 %44
store i8 %61, i8* %63
%64 = call i32 @strlen(i8* %47)
%65 = add nsw i32 %64, 1
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i8, i8* %47, i64 %66
%68 = call i8* @strtok(i8* %67, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%69 = icmp eq i8* %68, null
br i1 %69, label %70, label %43
70: ; preds = %57, %50, %39
%71 = load i8, i8* %10
%72 = icmp eq i8 %71, 0
br i1 %72, label %75, label %73
73: ; preds = %70
%74 = call i32 @fwrite(i8* %10, i32 1, i32 16, i32* %22)
br label %75
75: ; preds = %70, %73, %33
%76 = call i8* @fgets(i8* %8, i32 100, i32* %19)
%77 = icmp eq i8* %76, null
br i1 %77, label %78, label %33
78: ; preds = %75, %24
%79 = call i32 @fclose(i32* %19)
%80 = call i32 @fclose(i32* %22)
br label %81
81: ; preds = %78, %31, %14
%82 = phi i32 [ -1, %31 ], [ 0, %78 ], [ -1, %14 ]
ret i32 %82
}