#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*/ fprintf(int /*<<< orphan*/ *, char *, int, char, char);
int /*<<< orphan*/ printf(char *, int);
void jmp(FILE *fo, char input[], int counter) {
  int flags;
  switch (input[2]) {
  case 'p':
    flags = 0;
    break;
  case 'z':
    flags = 2;
    break;
  case 'g':
    flags = 6;
    break;
  case 'o':
    flags = 4;
    break;
  case 'i':
    flags = 14;
    break;
  case 'a':
    flags = 0;
    break;
  default:
    printf("Unable to resolve code written at line %d\n", counter);
    return;
  }
  if (input[5] != ' ' && input[6] != ' ' && input[5] != '\n' &&
      input[6] != '\n') {
    flags = flags | 1;
    fprintf(fo, "c%x%c%c ", flags, input[5], input[6]);
  } else
    fprintf(fo, "c%x%c%c ", flags, input[4], input[5]);
  return;
}


x86 assembly (clang, -O0):
<jmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movsbl 0x2(%rax),%eax
add    $0xffffff9f,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x19,%eax
ja     11a9 <jmp+0x89>
mov    -0x20(%rbp),%rax
lea    0xea8(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x0,-0x18(%rbp)
jmp    11bd <jmp+0x9d>
movl   $0x2,-0x18(%rbp)
jmp    11bd <jmp+0x9d>
movl   $0x6,-0x18(%rbp)
jmp    11bd <jmp+0x9d>
movl   $0x4,-0x18(%rbp)
jmp    11bd <jmp+0x9d>
movl   $0xe,-0x18(%rbp)
jmp    11bd <jmp+0x9d>
movl   $0x0,-0x18(%rbp)
jmp    11bd <jmp+0x9d>
mov    -0x14(%rbp),%esi
lea    0xeb5(%rip),%rdi
call   1030 <printf@plt>
jmp    1260 <jmp+0x140>
mov    -0x10(%rbp),%rax
movsbl 0x5(%rax),%eax
cmp    $0x20,%eax
je     1235 <jmp+0x115>
mov    -0x10(%rbp),%rax
movsbl 0x6(%rax),%eax
cmp    $0x20,%eax
je     1235 <jmp+0x115>
mov    -0x10(%rbp),%rax
movsbl 0x5(%rax),%eax
cmp    $0xa,%eax
je     1235 <jmp+0x115>
mov    -0x10(%rbp),%rax
movsbl 0x6(%rax),%eax
cmp    $0xa,%eax
je     1235 <jmp+0x115>
mov    -0x18(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%edx
mov    -0x10(%rbp),%rax
mov    0x5(%rax),%cl
mov    -0x10(%rbp),%rax
lea    0xe70(%rip),%rsi
movsbl %cl,%ecx
movsbl 0x6(%rax),%r8d
call   1040 <fprintf@plt>
jmp    125b <jmp+0x13b>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%edx
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%cl
mov    -0x10(%rbp),%rax
lea    0xe45(%rip),%rsi
movsbl %cl,%ecx
movsbl 0x5(%rax),%r8d
call   1040 <fprintf@plt>
jmp    1260 <jmp+0x140>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<jmp>:
mov    %edx,%r8d
movsbl 0x2(%rsi),%ecx
add    $0xffffff9f,%ecx
cmp    $0x19,%ecx
ja     1148 <jmp+0x28>
xor    %edx,%edx
lea    0xec8(%rip),%rax
movslq (%rax,%rcx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
mov    $0x6,%edx
jmp    116a <jmp+0x4a>
lea    0xf19(%rip),%rdi
mov    %r8d,%esi
jmp    1030 <printf@plt>
mov    $0xe,%edx
jmp    116a <jmp+0x4a>
mov    $0x4,%edx
jmp    116a <jmp+0x4a>
mov    $0x2,%edx
mov    0x5(%rsi),%al
cmp    $0x20,%al
je     1185 <jmp+0x65>
cmp    $0xa,%al
je     1185 <jmp+0x65>
mov    0x6(%rsi),%r8b
cmp    $0xa,%r8b
je     1185 <jmp+0x65>
cmp    $0x20,%r8b
jne    1199 <jmp+0x79>
movsbl 0x4(%rsi),%ecx
movsbl %al,%r8d
lea    0xeff(%rip),%rsi
jmp    1040 <fprintf@plt>
or     $0x1,%edx
movsbl %al,%ecx
movsbl %r8b,%r8d
lea    0xee9(%rip),%rsi
jmp    1040 <fprintf@plt>

LLVM IR (-O0):
@.str = [43 x i8] c"Unable to resolve code written at line %d\0A\00"
@.str.1 = [9 x i8] c"c%x%c%c \00"
define void @jmp(i32* %0, i8* %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%8 = load i8*, i8** %5
%9 = getelementptr inbounds i8, i8* %8, i64 2
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
switch i32 %11, label %18 [
i32 112, label %12
i32 122, label %13
i32 103, label %14
i32 111, label %15
i32 105, label %16
i32 97, label %17
]
12: ; preds = %3
store i32 0, i32* %7
br label %21
13: ; preds = %3
store i32 2, i32* %7
br label %21
14: ; preds = %3
store i32 6, i32* %7
br label %21
15: ; preds = %3
store i32 4, i32* %7
br label %21
16: ; preds = %3
store i32 14, i32* %7
br label %21
17: ; preds = %3
store i32 0, i32* %7
br label %21
18: ; preds = %3
%19 = load i32, i32* %6
%20 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 %19)
br label %68
21: ; preds = %17, %16, %15, %14, %13, %12
%22 = load i8*, i8** %5
%23 = getelementptr inbounds i8, i8* %22, i64 5
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %25, 32
br i1 %26, label %27, label %57
27: ; preds = %21
%28 = load i8*, i8** %5
%29 = getelementptr inbounds i8, i8* %28, i64 6
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp ne i32 %31, 32
br i1 %32, label %33, label %57
33: ; preds = %27
%34 = load i8*, i8** %5
%35 = getelementptr inbounds i8, i8* %34, i64 5
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp ne i32 %37, 10
br i1 %38, label %39, label %57
39: ; preds = %33
%40 = load i8*, i8** %5
%41 = getelementptr inbounds i8, i8* %40, i64 6
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp ne i32 %43, 10
br i1 %44, label %45, label %57
45: ; preds = %39
%46 = load i32, i32* %7
%47 = or i32 %46, 1
store i32 %47, i32* %7
%48 = load i32*, i32** %4
%49 = load i32, i32* %7
%50 = load i8*, i8** %5
%51 = getelementptr inbounds i8, i8* %50, i64 5
%52 = load i8, i8* %51
%53 = load i8*, i8** %5
%54 = getelementptr inbounds i8, i8* %53, i64 6
%55 = load i8, i8* %54
%56 = call i32 @fprintf(i32* %48, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %49, i8 signext %52, i8 signext %55)
br label %67
57: ; preds = %39, %33, %27, %21
%58 = load i32*, i32** %4
%59 = load i32, i32* %7
%60 = load i8*, i8** %5
%61 = getelementptr inbounds i8, i8* %60, i64 4
%62 = load i8, i8* %61
%63 = load i8*, i8** %5
%64 = getelementptr inbounds i8, i8* %63, i64 5
%65 = load i8, i8* %64
%66 = call i32 @fprintf(i32* %58, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %59, i8 signext %62, i8 signext %65)
br label %67
67: ; preds = %57, %45
br label %68
68: ; preds = %67, %18
ret void
}

LLVM IR (-O2):
@.str = [43 x i8] c"Unable to resolve code written at line %d\0A\00"
@.str.1 = [9 x i8] c"c%x%c%c \00"
define void @jmp(i32* nocapture %0, i8* nocapture %1, i32 %2) {
%4 = getelementptr inbounds i8, i8* %1, i64 2
%5 = load i8, i8* %4
%6 = sext i8 %5 to i32
switch i32 %6, label %11 [
i32 112, label %13
i32 122, label %7
i32 103, label %8
i32 111, label %9
i32 105, label %10
i32 97, label %13
]
7: ; preds = %3
br label %13
8: ; preds = %3
br label %13
9: ; preds = %3
br label %13
10: ; preds = %3
br label %13
11: ; preds = %3
%12 = tail call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 %2)
br label %31
13: ; preds = %3, %3, %10, %9, %8, %7
%14 = phi i32 [ 14, %10 ], [ 4, %9 ], [ 6, %8 ], [ 2, %7 ], [ 0, %3 ], [ 0, %3 ]
%15 = getelementptr inbounds i8, i8* %1, i64 5
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 32
br i1 %17, label %27, label %18
18: ; preds = %13
%19 = getelementptr inbounds i8, i8* %1, i64 6
%20 = load i8, i8* %19
%21 = freeze i8 %16
%22 = icmp eq i8 %21, 10
br i1 %22, label %27, label %23
23: ; preds = %18
switch i8 %20, label %24 [
i8 32, label %27
i8 10, label %27
]
24: ; preds = %23
%25 = or i32 %14, 1
%26 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %25, i8 signext %21, i8 signext %20)
br label %31
27: ; preds = %23, %23, %18, %13
%28 = getelementptr inbounds i8, i8* %1, i64 4
%29 = load i8, i8* %28
%30 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %14, i8 signext %29, i8 signext %16)
br label %31
31: ; preds = %24, %27, %11
ret void
}