#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 char uint8_t;
typedef int uint64_t;
typedef char uint32_t;
typedef char uint16_t;

/* Variables and functions */
int /*<<< orphan*/ add_reverse_insn(char *, size_t);
void create_reverse_instruction(uint64_t value, size_t size) {
  char mov[8];
  char mov2[8];
  char jc[2];
  char cmp[7];
  size_t mov_size;
  mov[0] = (uint64_t)0;
  switch (size) {
  case 1:
    mov[0] = 0xc6;
    mov[1] = 0x07;
    mov[2] = (uint8_t)value;
    mov_size = 3;
    break;
  case 2:
    mov[0] = 0x66;
    mov[1] = 0xc7;
    mov[2] = 0x07;
    mov[3] = (uint16_t)value;
    mov_size = 5;
    break;
  case 4:
    mov[0] = 0xc7;
    mov[1] = 0x07;
    mov[2] = (uint32_t)value;
    mov_size = 6;
    break;
  case 8:
    mov[0] = mov2[0] = 0x48;
    mov[1] = mov2[1] = 0xc7;
    mov[2] = mov2[2] = 0x47;
    mov[3] = mov2[3] = 0x00;
    mov[4] = (uint32_t)value;
    mov2[4] = (uint32_t)(value >> 32);
    mov_size = 8;
    break;
  default:
    return;
  }
  add_reverse_insn(mov, mov_size);
  if (size == 8) {
    add_reverse_insn(mov2, mov_size);
  }
}


x86 assembly (clang, -O0):
<create_reverse_instruction>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x40(%rbp)
sub    $0x7,%rax
ja     11e2 <create_reverse_instruction+0xd2>
mov    -0x40(%rbp),%rax
lea    0xebc(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movb   $0xc6,-0x18(%rbp)
movb   $0x7,-0x17(%rbp)
mov    -0x4(%rbp),%eax
mov    %al,-0x16(%rbp)
movq   $0x3,-0x38(%rbp)
jmp    11e7 <create_reverse_instruction+0xd7>
movb   $0x66,-0x18(%rbp)
movb   $0xc7,-0x17(%rbp)
movb   $0x7,-0x16(%rbp)
mov    -0x4(%rbp),%eax
mov    %al,-0x15(%rbp)
movq   $0x5,-0x38(%rbp)
jmp    11e7 <create_reverse_instruction+0xd7>
movb   $0xc7,-0x18(%rbp)
movb   $0x7,-0x17(%rbp)
mov    -0x4(%rbp),%eax
mov    %al,-0x16(%rbp)
movq   $0x6,-0x38(%rbp)
jmp    11e7 <create_reverse_instruction+0xd7>
movb   $0x48,-0x20(%rbp)
movb   $0x48,-0x18(%rbp)
movb   $0xc7,-0x1f(%rbp)
movb   $0xc7,-0x17(%rbp)
movb   $0x47,-0x1e(%rbp)
movb   $0x47,-0x16(%rbp)
movb   $0x0,-0x1d(%rbp)
movb   $0x0,-0x15(%rbp)
mov    -0x4(%rbp),%eax
mov    %al,-0x14(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x20,%ecx
sar    %cl,%eax
mov    %al,-0x1c(%rbp)
movq   $0x8,-0x38(%rbp)
jmp    11e7 <create_reverse_instruction+0xd7>
jmp    120c <create_reverse_instruction+0xfc>
lea    -0x18(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1030 <add_reverse_insn@plt>
cmpq   $0x8,-0x10(%rbp)
jne    120c <create_reverse_instruction+0xfc>
lea    -0x20(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1030 <add_reverse_insn@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_reverse_instruction>:
sub    $0x18,%rsp
add    $0xffffffffffffffff,%rsi
cmp    $0x7,%rsi
ja     11ae <create_reverse_instruction+0x9e>
lea    0xed7(%rip),%rax
movslq (%rax,%rsi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
movb   $0xc6,0x8(%rsp)
mov    $0x3,%esi
jmp    1160 <create_reverse_instruction+0x50>
movw   $0xc766,0x8(%rsp)
mov    $0x5,%esi
mov    $0x3,%eax
mov    $0x2,%ecx
jmp    116a <create_reverse_instruction+0x5a>
movb   $0xc7,0x8(%rsp)
mov    $0x6,%esi
mov    $0x2,%eax
mov    $0x1,%ecx
movb   $0x7,0x8(%rsp,%rcx,1)
mov    %dil,0x8(%rsp,%rax,1)
lea    0x8(%rsp),%rdi
jmp    11a9 <create_reverse_instruction+0x99>
movl   $0x47c748,0x10(%rsp)
movl   $0x47c748,0x8(%rsp)
mov    %dil,0xc(%rsp)
lea    0x8(%rsp),%rdi
mov    $0x8,%esi
call   1030 <add_reverse_insn@plt>
lea    0x10(%rsp),%rdi
mov    $0x8,%esi
call   1030 <add_reverse_insn@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
define void @create_reverse_instruction(i32 %0, i64 %1) {
%3 = alloca i32
%4 = alloca i64
%5 = alloca [8 x i8]
%6 = alloca [8 x i8]
%7 = alloca [2 x i8]
%8 = alloca [7 x i8]
%9 = alloca i64
store i32 %0, i32* %3
store i64 %1, i64* %4
%10 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
store i8 0, i8* %10
%11 = load i64, i64* %4
switch i64 %11, label %47 [
i64 1, label %12
i64 2, label %18
i64 4, label %25
i64 8, label %31
]
12: ; preds = %2
%13 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
store i8 -58, i8* %13
%14 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 1
store i8 7, i8* %14
%15 = load i32, i32* %3
%16 = trunc i32 %15 to i8
%17 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 2
store i8 %16, i8* %17
store i64 3, i64* %9
br label %48
18: ; preds = %2
%19 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
store i8 102, i8* %19
%20 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 1
store i8 -57, i8* %20
%21 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 2
store i8 7, i8* %21
%22 = load i32, i32* %3
%23 = trunc i32 %22 to i8
%24 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 3
store i8 %23, i8* %24
store i64 5, i64* %9
br label %48
25: ; preds = %2
%26 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
store i8 -57, i8* %26
%27 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 1
store i8 7, i8* %27
%28 = load i32, i32* %3
%29 = trunc i32 %28 to i8
%30 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 2
store i8 %29, i8* %30
store i64 6, i64* %9
br label %48
31: ; preds = %2
%32 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 0
store i8 72, i8* %32
%33 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
store i8 72, i8* %33
%34 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 1
store i8 -57, i8* %34
%35 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 1
store i8 -57, i8* %35
%36 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 2
store i8 71, i8* %36
%37 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 2
store i8 71, i8* %37
%38 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 3
store i8 0, i8* %38
%39 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 3
store i8 0, i8* %39
%40 = load i32, i32* %3
%41 = trunc i32 %40 to i8
%42 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 4
store i8 %41, i8* %42
%43 = load i32, i32* %3
%44 = ashr i32 %43, 32
%45 = trunc i32 %44 to i8
%46 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 4
store i8 %45, i8* %46
store i64 8, i64* %9
br label %48
47: ; preds = %2
br label %58
48: ; preds = %31, %25, %18, %12
%49 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%50 = load i64, i64* %9
%51 = call i32 @add_reverse_insn(i8* %49, i64 %50)
%52 = load i64, i64* %4
%53 = icmp eq i64 %52, 8
br i1 %53, label %54, label %58
54: ; preds = %48
%55 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 0
%56 = load i64, i64* %9
%57 = call i32 @add_reverse_insn(i8* %55, i64 %56)
br label %58
58: ; preds = %47, %54, %48
ret void
}

LLVM IR (-O2):
define void @create_reverse_instruction(i32 %0, i64 %1) {
%3 = alloca [8 x i8]
%4 = alloca [8 x i8]
%5 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 0
switch i64 %1, label %30 [
i64 1, label %7
i64 2, label %8
i64 4, label %10
i64 8, label %19
]
7: ; preds = %2
store i8 -58, i8* %5
br label %11
8: ; preds = %2
store i8 102, i8* %5
%9 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 1
store i8 -57, i8* %9
br label %11
10: ; preds = %2
store i8 -57, i8* %5
br label %11
11: ; preds = %10, %8, %7
%12 = phi i64 [ 1, %10 ], [ 2, %8 ], [ 1, %7 ]
%13 = phi i64 [ 2, %10 ], [ 3, %8 ], [ 2, %7 ]
%14 = phi i64 [ 6, %10 ], [ 5, %8 ], [ 3, %7 ]
%15 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 %12
store i8 7, i8* %15
%16 = trunc i32 %0 to i8
%17 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 %13
store i8 %16, i8* %17
%18 = call i32 @add_reverse_insn(i8* %5, i64 %14)
br label %30
19: ; preds = %2
store i8 72, i8* %6
store i8 72, i8* %5
%20 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 1
store i8 -57, i8* %20
%21 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 1
store i8 -57, i8* %21
%22 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 2
store i8 71, i8* %22
%23 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 2
store i8 71, i8* %23
%24 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 3
store i8 0, i8* %24
%25 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 3
store i8 0, i8* %25
%26 = trunc i32 %0 to i8
%27 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 4
store i8 %26, i8* %27
%28 = call i32 @add_reverse_insn(i8* %5, i64 8)
%29 = call i32 @add_reverse_insn(i8* %6, i64 8)
br label %30
30: ; preds = %11, %19, %2
ret void
}