#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 */

/* Variables and functions */
int disasm_invariant_tbllookup(unsigned char *, int /*<<< orphan*/,
                               unsigned char *, int /*<<< orphan*/);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char *, int);
int disasm_invariant(unsigned char *in, int in_len, unsigned char *out,
                     int out_len) {
  unsigned char bytes[20] = {0};
  unsigned char buf[20] = {0};
  int len, size;
  len = (in_len > 20) ? 20 : in_len;
  memcpy(bytes, in, len);
  size = disasm_invariant_tbllookup(bytes, 0, buf, 0);
  len = (out_len > 20) ? 20 : out_len;
  memcpy(out, buf, len);
  return (size);
}


x86 assembly (clang, -O0):
<disasm_invariant>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1030 <memset@plt>
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1030 <memset@plt>
cmpl   $0x14,-0xc(%rbp)
jle    117d <disasm_invariant+0x4d>
mov    $0x14,%eax
mov    %eax,-0x5c(%rbp)
jmp    1183 <disasm_invariant+0x53>
mov    -0xc(%rbp),%eax
mov    %eax,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
mov    %eax,-0x54(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x54(%rbp),%edx
call   1040 <memcpy@plt>
lea    -0x30(%rbp),%rdi
lea    -0x50(%rbp),%rdx
xor    %ecx,%ecx
mov    %ecx,%esi
call   1050 <disasm_invariant_tbllookup@plt>
mov    %eax,-0x58(%rbp)
cmpl   $0x14,-0x1c(%rbp)
jle    11c4 <disasm_invariant+0x94>
mov    $0x14,%eax
mov    %eax,-0x60(%rbp)
jmp    11ca <disasm_invariant+0x9a>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x60(%rbp)
mov    -0x60(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x50(%rbp),%rsi
mov    -0x54(%rbp),%edx
call   1040 <memcpy@plt>
mov    -0x58(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<disasm_invariant>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %ecx,%r13d
mov    %rdx,%r14
mov    %esi,%edx
mov    %rdi,%rsi
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movl   $0x0,0x30(%rsp)
movaps %xmm0,(%rsp)
movl   $0x0,0x10(%rsp)
cmp    $0x14,%edx
mov    $0x14,%ebx
cmovge %ebx,%edx
lea    0x20(%rsp),%r15
mov    %r15,%rdi
call   1030 <memcpy@plt>
mov    %rsp,%r12
mov    %r15,%rdi
xor    %esi,%esi
mov    %r12,%rdx
xor    %ecx,%ecx
call   1040 <disasm_invariant_tbllookup@plt>
mov    %eax,%ebp
cmp    $0x14,%r13d
cmovl  %r13d,%ebx
mov    %r14,%rdi
mov    %r12,%rsi
mov    %ebx,%edx
call   1030 <memcpy@plt>
mov    %ebp,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @disasm_invariant(i8* %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca [20 x i8]
%10 = alloca [20 x i8]
%11 = alloca i32
%12 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%13 = bitcast [20 x i8]* %9 to i8*
%14 = bitcast [20 x i8]* %10 to i8*
%15 = load i32, i32* %6
%16 = icmp sgt i32 %15, 20
br i1 %16, label %17, label %18
17: ; preds = %4
br label %20
18: ; preds = %4
%19 = load i32, i32* %6
br label %20
20: ; preds = %18, %17
%21 = phi i32 [ 20, %17 ], [ %19, %18 ]
store i32 %21, i32* %11
%22 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 0
%23 = load i8*, i8** %5
%24 = load i32, i32* %11
%25 = call i32 @memcpy(i8* %22, i8* %23, i32 %24)
%26 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 0
%27 = getelementptr inbounds [20 x i8], [20 x i8]* %10, i64 0, i64 0
%28 = call i32 @disasm_invariant_tbllookup(i8* %26, i32 0, i8* %27, i32 0)
store i32 %28, i32* %12
%29 = load i32, i32* %8
%30 = icmp sgt i32 %29, 20
br i1 %30, label %31, label %32
31: ; preds = %20
br label %34
32: ; preds = %20
%33 = load i32, i32* %8
br label %34
34: ; preds = %32, %31
%35 = phi i32 [ 20, %31 ], [ %33, %32 ]
store i32 %35, i32* %11
%36 = load i8*, i8** %7
%37 = getelementptr inbounds [20 x i8], [20 x i8]* %10, i64 0, i64 0
%38 = load i32, i32* %11
%39 = call i32 @memcpy(i8* %36, i8* %37, i32 %38)
%40 = load i32, i32* %12
ret i32 %40
}

LLVM IR (-O2):
define i32 @disasm_invariant(i8* %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca [20 x i8]
%6 = alloca [20 x i8]
%7 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%9 = icmp slt i32 %1, 20
%10 = select i1 %9, i32 %1, i32 20
%11 = call i32 @memcpy(i8* %7, i8* %0, i32 %10)
%12 = call i32 @disasm_invariant_tbllookup(i8* %7, i32 0, i8* %8, i32 0)
%13 = icmp slt i32 %3, 20
%14 = select i1 %13, i32 %3, i32 20
%15 = call i32 @memcpy(i8* %2, i8* %8, i32 %14)
ret i32 %12
}