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

/* Variables and functions */
int /*<<< orphan*/ fwrite(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ sscanf(char *, char *, unsigned char *);
scalar_t__ strcmp(char *, char *);
void mvi_asm(char *reg, char *word, FILE *file) {
  unsigned char buffer[] = {0, 0};
  if (strcmp(reg, "a") == 0)
    buffer[0] = 0x3e;
  else if (strcmp(reg, "b") == 0)
    buffer[0] = 0x06;
  else if (strcmp(reg, "c") == 0)
    buffer[0] = 0x0e;
  else if (strcmp(reg, "d") == 0)
    buffer[0] = 0x16;
  else if (strcmp(reg, "e") == 0)
    buffer[0] = 0x1e;
  else if (strcmp(reg, "h") == 0)
    buffer[0] = 0x26;
  else if (strcmp(reg, "l") == 0)
    buffer[0] = 0x2e;
  else if (strcmp(reg, "m") == 0)
    buffer[0] = 0x36;
  sscanf(word, "%02x", &buffer[1]);
  fwrite(buffer, sizeof(buffer), 1, file);
}


x86 assembly (clang, -O0):
<mvi_asm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x1a(%rbp),%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1030 <memset@plt>
mov    -0x8(%rbp),%rdi
lea    0xe91(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1187 <mvi_asm+0x47>
movb   $0x3e,-0x1a(%rbp)
jmp    129a <mvi_asm+0x15a>
mov    -0x8(%rbp),%rdi
lea    0xe70(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11aa <mvi_asm+0x6a>
movb   $0x6,-0x1a(%rbp)
jmp    1295 <mvi_asm+0x155>
mov    -0x8(%rbp),%rdi
lea    0xe4f(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11cd <mvi_asm+0x8d>
movb   $0xe,-0x1a(%rbp)
jmp    1290 <mvi_asm+0x150>
mov    -0x8(%rbp),%rdi
lea    0xe2e(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11f0 <mvi_asm+0xb0>
movb   $0x16,-0x1a(%rbp)
jmp    128b <mvi_asm+0x14b>
mov    -0x8(%rbp),%rdi
lea    0xe0d(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1213 <mvi_asm+0xd3>
movb   $0x1e,-0x1a(%rbp)
jmp    1286 <mvi_asm+0x146>
mov    -0x8(%rbp),%rdi
lea    0xdec(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1236 <mvi_asm+0xf6>
movb   $0x26,-0x1a(%rbp)
jmp    1281 <mvi_asm+0x141>
mov    -0x8(%rbp),%rdi
lea    0xdcb(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1259 <mvi_asm+0x119>
movb   $0x2e,-0x1a(%rbp)
jmp    127c <mvi_asm+0x13c>
mov    -0x8(%rbp),%rdi
lea    0xdaa(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1277 <mvi_asm+0x137>
movb   $0x36,-0x1a(%rbp)
jmp    127c <mvi_asm+0x13c>
jmp    1281 <mvi_asm+0x141>
jmp    1286 <mvi_asm+0x146>
jmp    128b <mvi_asm+0x14b>
jmp    1290 <mvi_asm+0x150>
jmp    1295 <mvi_asm+0x155>
jmp    129a <mvi_asm+0x15a>
mov    -0x10(%rbp),%rdi
lea    -0x1a(%rbp),%rdx
add    $0x1,%rdx
lea    0xd63(%rip),%rsi
call   1050 <sscanf@plt>
lea    -0x1a(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x2,%esi
mov    $0x1,%edx
call   1060 <fwrite@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mvi_asm>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
movw   $0x0,0xe(%rsp)
lea    0xeb0(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11f5 <mvi_asm+0xc5>
lea    0xe9d(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11fc <mvi_asm+0xcc>
lea    0xe87(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1203 <mvi_asm+0xd3>
lea    0xe75(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     120a <mvi_asm+0xda>
lea    0xe63(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1211 <mvi_asm+0xe1>
lea    0xe51(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1218 <mvi_asm+0xe8>
lea    0xe3f(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     121f <mvi_asm+0xef>
lea    0xe2d(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
jne    1224 <mvi_asm+0xf4>
movb   $0x36,0xe(%rsp)
jmp    1224 <mvi_asm+0xf4>
movb   $0x3e,0xe(%rsp)
jmp    1224 <mvi_asm+0xf4>
movb   $0x6,0xe(%rsp)
jmp    1224 <mvi_asm+0xf4>
movb   $0xe,0xe(%rsp)
jmp    1224 <mvi_asm+0xf4>
movb   $0x16,0xe(%rsp)
jmp    1224 <mvi_asm+0xf4>
movb   $0x1e,0xe(%rsp)
jmp    1224 <mvi_asm+0xf4>
movb   $0x26,0xe(%rsp)
jmp    1224 <mvi_asm+0xf4>
movb   $0x2e,0xe(%rsp)
lea    0xf(%rsp),%rdx
lea    0xde0(%rip),%rsi
mov    %r15,%rdi
call   1040 <sscanf@plt>
lea    0xe(%rsp),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1050 <fwrite@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"a\00"
@.str.1 = [2 x i8] c"b\00"
@.str.2 = [2 x i8] c"c\00"
@.str.3 = [2 x i8] c"d\00"
@.str.4 = [2 x i8] c"e\00"
@.str.5 = [2 x i8] c"h\00"
@.str.6 = [2 x i8] c"l\00"
@.str.7 = [2 x i8] c"m\00"
@.str.8 = [5 x i8] c"%02x\00"
define void @mvi_asm(i8* %0, i8* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca [2 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32* %2, i32** %6
%8 = bitcast [2 x i8]* %7 to i8*
%9 = load i8*, i8** %4
%10 = call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %3
%13 = getelementptr inbounds [2 x i8], [2 x i8]* %7, i64 0, i64 0
store i8 62, i8* %13
br label %63
14: ; preds = %3
%15 = load i8*, i8** %4
%16 = call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = getelementptr inbounds [2 x i8], [2 x i8]* %7, i64 0, i64 0
store i8 6, i8* %19
br label %62
20: ; preds = %14
%21 = load i8*, i8** %4
%22 = call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = getelementptr inbounds [2 x i8], [2 x i8]* %7, i64 0, i64 0
store i8 14, i8* %25
br label %61
26: ; preds = %20
%27 = load i8*, i8** %4
%28 = call i64 @strcmp(i8* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = getelementptr inbounds [2 x i8], [2 x i8]* %7, i64 0, i64 0
store i8 22, i8* %31
br label %60
32: ; preds = %26
%33 = load i8*, i8** %4
%34 = call i64 @strcmp(i8* %33, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %32
%37 = getelementptr inbounds [2 x i8], [2 x i8]* %7, i64 0, i64 0
store i8 30, i8* %37
br label %59
38: ; preds = %32
%39 = load i8*, i8** %4
%40 = call i64 @strcmp(i8* %39, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %38
%43 = getelementptr inbounds [2 x i8], [2 x i8]* %7, i64 0, i64 0
store i8 38, i8* %43
br label %58
44: ; preds = %38
%45 = load i8*, i8** %4
%46 = call i64 @strcmp(i8* %45, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %50
48: ; preds = %44
%49 = getelementptr inbounds [2 x i8], [2 x i8]* %7, i64 0, i64 0
store i8 46, i8* %49
br label %57
50: ; preds = %44
%51 = load i8*, i8** %4
%52 = call i64 @strcmp(i8* %51, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%53 = icmp eq i64 %52, 0
br i1 %53, label %54, label %56
54: ; preds = %50
%55 = getelementptr inbounds [2 x i8], [2 x i8]* %7, i64 0, i64 0
store i8 54, i8* %55
br label %56
56: ; preds = %54, %50
br label %57
57: ; preds = %56, %48
br label %58
58: ; preds = %57, %42
br label %59
59: ; preds = %58, %36
br label %60
60: ; preds = %59, %30
br label %61
61: ; preds = %60, %24
br label %62
62: ; preds = %61, %18
br label %63
63: ; preds = %62, %12
%64 = load i8*, i8** %5
%65 = getelementptr inbounds [2 x i8], [2 x i8]* %7, i64 0, i64 1
%66 = call i32 @sscanf(i8* %64, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i8* %65)
%67 = getelementptr inbounds [2 x i8], [2 x i8]* %7, i64 0, i64 0
%68 = load i32*, i32** %6
%69 = call i32 @fwrite(i8* %67, i32 2, i32 1, i32* %68)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"a\00"
@.str.1 = [2 x i8] c"b\00"
@.str.2 = [2 x i8] c"c\00"
@.str.3 = [2 x i8] c"d\00"
@.str.4 = [2 x i8] c"e\00"
@.str.5 = [2 x i8] c"h\00"
@.str.6 = [2 x i8] c"l\00"
@.str.7 = [2 x i8] c"m\00"
@.str.8 = [5 x i8] c"%02x\00"
define void @mvi_asm(i8* %0, i8* nocapture %1, i32* nocapture %2) {
%4 = alloca i16
%5 = bitcast i16* %4 to i8*
store i16 0, i16* %4
%6 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %3
store i8 62, i8* %5
br label %37
9: ; preds = %3
%10 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %9
store i8 6, i8* %5
br label %37
13: ; preds = %9
%14 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %13
store i8 14, i8* %5
br label %37
17: ; preds = %13
%18 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %17
store i8 22, i8* %5
br label %37
21: ; preds = %17
%22 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %21
store i8 30, i8* %5
br label %37
25: ; preds = %21
%26 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %25
store i8 38, i8* %5
br label %37
29: ; preds = %25
%30 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %29
store i8 46, i8* %5
br label %37
33: ; preds = %29
%34 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %33
store i8 54, i8* %5
br label %37
37: ; preds = %12, %20, %28, %33, %36, %32, %24, %16, %8
%38 = bitcast i16* %4 to [2 x i8]*
%39 = getelementptr inbounds [2 x i8], [2 x i8]* %38, i64 0, i64 1
%40 = call i32 @sscanf(i8* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i8* %39)
%41 = call i32 @fwrite(i8* %5, i32 2, i32 1, i32* %2)
ret void
}