#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 /*<<< orphan*/ printf(char *, ...);
void show_shellcode(int *inst, int length) {
  printf("\t\t\t    [----Shellcode----]\n\n");
  for (unsigned volatile int i = 0; i < length;
       printf("\t\t\t\t0x%08x\n", inst[i++]))
    ;
}


x86 assembly (clang, -O0):
<show_shellcode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    116c <show_shellcode+0x5c>
jmp    1145 <show_shellcode+0x35>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x10(%rbp)
mov    %ecx,%ecx
mov    (%rax,%rcx,4),%esi
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1134 <show_shellcode+0x24>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_shellcode>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebx
mov    %rdi,%r14
lea    0xed7(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,0xc(%rsp)
mov    0xc(%rsp),%eax
cmp    %ebx,%eax
jae    1181 <show_shellcode+0x61>
lea    0xeaf(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0xc(%rsp),%eax
lea    0x1(%rax),%ecx
mov    %ecx,0xc(%rsp)
mov    (%r14,%rax,4),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%eax
cmp    %ebx,%eax
jb     1160 <show_shellcode+0x40>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [29 x i8] c"\09\09\09 [----Shellcode----]\0A\0A\00"
@.str.1 = [12 x i8] c"\09\09\09\090x%08x\0A\00"
define void @show_shellcode(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
store volatile i32 0, i32* %5
br label %7
7: ; preds = %12, %2
%8 = load volatile i32, i32* %5
%9 = load i32, i32* %4
%10 = icmp ult i32 %8, %9
br i1 %10, label %11, label %20
11: ; preds = %7
br label %12
12: ; preds = %11
%13 = load i32*, i32** %3
%14 = load volatile i32, i32* %5
%15 = add i32 %14, 1
store volatile i32 %15, i32* %5
%16 = zext i32 %14 to i64
%17 = getelementptr inbounds i32, i32* %13, i64 %16
%18 = load i32, i32* %17
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %18)
br label %7
20: ; preds = %7
ret void
}

LLVM IR (-O2):
@.str.1 = [12 x i8] c"\09\09\09\090x%08x\0A\00"
@str = [28 x i8] c"\09\09\09 [----Shellcode----]\0A\00"
define void @show_shellcode(i32* nocapture %0, i32 %1) {
%3 = alloca i32
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%5 = bitcast i32* %3 to i8*
store volatile i32 0, i32* %3
%6 = load volatile i32, i32* %3
%7 = icmp ult i32 %6, %1
br i1 %7, label %9, label %8
8: ; preds = %9, %2
ret void
9: ; preds = %2, %9
%10 = load volatile i32, i32* %3
%11 = add i32 %10, 1
store volatile i32 %11, i32* %3
%12 = zext i32 %10 to i64
%13 = getelementptr inbounds i32, i32* %0, i64 %12
%14 = load i32, i32* %13
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = load volatile i32, i32* %3
%17 = icmp ult i32 %16, %1
br i1 %17, label %9, label %8
}