#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*/ infc_files_dir(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
char *randstr(int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int system(char *);
void clam_scan_util(char *prog, int targ) {
  int u, sc;
  char command[128];
  infc_files_dir("SCQuarantine", prog);
  strcpy(command, "sleep 1 && clamscan -vir --bell --move=$HOME/");
  strcat(command, "SCQuarantine");
  strcat(command, " --log=$HOME/");
  strcat(command, "SCQuarantine");
  strcat(command, "/");
  strcat(command, "SCReport-0");
  strcat(command, randstr(8));
  strcat(command, ".txt ");
  printf("%s: Updating ClamAV virus database. Please wait...\n", prog);
  if ((u = system("sleep 1 && freshclam --quiet ")) == 0)
    printf("Done\n");
  else
    printf("%s: %s", prog, "Command failed to execute due to error(s).");
  putchar('\n');
  if (targ > 0) {
    strcat(command, "/*");
    printf("%s: Initiating full scan (might take a while). Please wait...\n",
           prog);
  } else {
    strcat(command, "$HOME/*");
    printf("%s: Scanning home directory (recursively). Please wait...\n", prog);
  }
  if ((sc = system(command)) == 0)
    printf("%s: Please check the %s folder for any infected files.\n", prog,
           "SCQuarantine");
  else
    printf("%s: Virus scanning failed due to error(s).\n", prog);
  putchar('\n');
}


x86 assembly (clang, -O0):
<clam_scan_util>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe73(%rip),%rdi
call   1080 <infc_files_dir@plt>
lea    -0xa0(%rbp),%rdi
lea    0xe6d(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0xa0(%rbp),%rdi
lea    0xe4d(%rip),%rsi
call   1090 <strcat@plt>
lea    -0xa0(%rbp),%rdi
lea    0xe75(%rip),%rsi
call   1090 <strcat@plt>
lea    -0xa0(%rbp),%rdi
lea    0xe27(%rip),%rsi
call   1090 <strcat@plt>
lea    -0xa0(%rbp),%rdi
lea    0xe4d(%rip),%rsi
call   1090 <strcat@plt>
lea    -0xa0(%rbp),%rdi
lea    0xe4a(%rip),%rsi
call   1090 <strcat@plt>
lea    -0xa0(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    $0x8,%edi
call   1050 <randstr@plt>
mov    -0xa8(%rbp),%rdi
mov    %rax,%rsi
call   1090 <strcat@plt>
lea    -0xa0(%rbp),%rdi
lea    0xe1b(%rip),%rsi
call   1090 <strcat@plt>
mov    -0x8(%rbp),%rsi
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xe37(%rip),%rdi
call   1060 <system@plt>
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
jne    127b <clam_scan_util+0x10b>
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1294 <clam_scan_util+0x124>
mov    -0x8(%rbp),%rsi
lea    0xe2c(%rip),%rdi
lea    0xe2c(%rip),%rdx
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
cmpl   $0x0,-0xc(%rbp)
jle    12d2 <clam_scan_util+0x162>
lea    -0xa0(%rbp),%rdi
lea    0xe72(%rip),%rsi
call   1090 <strcat@plt>
mov    -0x8(%rbp),%rsi
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    12f7 <clam_scan_util+0x187>
lea    -0xa0(%rbp),%rdi
lea    0xe43(%rip),%rsi
call   1090 <strcat@plt>
mov    -0x8(%rbp),%rsi
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0xa0(%rbp),%rdi
call   1060 <system@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jne    132d <clam_scan_util+0x1bd>
mov    -0x8(%rbp),%rsi
lea    0xe4c(%rip),%rdi
lea    0xcdf(%rip),%rdx
mov    $0x0,%al
call   1070 <printf@plt>
jmp    133f <clam_scan_util+0x1cf>
mov    -0x8(%rbp),%rsi
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clam_scan_util>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x88,%rsp
mov    %esi,%r14d
mov    %rdi,%r15
lea    0xe66(%rip),%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1090 <infc_files_dir@plt>
lea    0xe61(%rip),%rsi
mov    %rsp,%rbp
mov    %rbp,%rdi
call   1040 <strcpy@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   10a0 <strcat@plt>
lea    0xe72(%rip),%rsi
mov    %rbp,%rdi
call   10a0 <strcat@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   10a0 <strcat@plt>
lea    0xe56(%rip),%rsi
mov    %rbp,%rdi
call   10a0 <strcat@plt>
lea    0xe57(%rip),%rsi
mov    %rbp,%rdi
call   10a0 <strcat@plt>
mov    $0x8,%edi
call   1060 <randstr@plt>
mov    %rbp,%rdi
mov    %rax,%rsi
call   10a0 <strcat@plt>
lea    0xe3e(%rip),%rsi
mov    %rbp,%rdi
call   10a0 <strcat@plt>
lea    0xe35(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xe58(%rip),%rdi
call   1070 <system@plt>
test   %eax,%eax
je     1259 <clam_scan_util+0xd9>
lea    0xe66(%rip),%rdi
lea    0xe66(%rip),%rdx
mov    %r15,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    1265 <clam_scan_util+0xe5>
lea    0xf64(%rip),%rdi
call   1050 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
test   %r14d,%r14d
lea    0xea9(%rip),%rax
lea    0xe9d(%rip),%rsi
cmovg  %rax,%rsi
lea    0xe53(%rip),%rax
lea    0xe93(%rip),%rbx
cmovg  %rax,%rbx
mov    %rsp,%rbp
mov    %rbp,%rdi
call   10a0 <strcat@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %rbp,%rdi
call   1070 <system@plt>
test   %eax,%eax
je     12cd <clam_scan_util+0x14d>
lea    0xed7(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    12e5 <clam_scan_util+0x165>
lea    0xe8c(%rip),%rdi
lea    0xd25(%rip),%rdx
mov    %r15,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x88,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"SCQuarantine\00"
@.str.1 = [46 x i8] c"sleep 1 && clamscan -vir --bell --move=$HOME/\00"
@.str.2 = [14 x i8] c" --log=$HOME/\00"
@.str.3 = [2 x i8] c"/\00"
@.str.4 = [11 x i8] c"SCReport-0\00"
@.str.5 = [6 x i8] c".txt \00"
@.str.6 = [52 x i8] c"%s: Updating ClamAV virus database. Please wait...\0A\00"
@.str.7 = [30 x i8] c"sleep 1 && freshclam --quiet \00"
@.str.8 = [6 x i8] c"Done\0A\00"
@.str.9 = [7 x i8] c"%s: %s\00"
@.str.10 = [43 x i8] c"Command failed to execute due to error(s).\00"
@.str.11 = [3 x i8] c"/*\00"
@.str.12 = [63 x i8] c"%s: Initiating full scan (might take a while). Please wait...\0A\00"
@.str.13 = [8 x i8] c"$HOME/*\00"
@.str.14 = [59 x i8] c"%s: Scanning home directory (recursively). Please wait...\0A\00"
@.str.15 = [56 x i8] c"%s: Please check the %s folder for any infected files.\0A\00"
@.str.16 = [44 x i8] c"%s: Virus scanning failed due to error(s).\0A\00"
define void @clam_scan_util(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [128 x i8]
store i8* %0, i8** %3
store i32 %1, i32* %4
%8 = load i8*, i8** %3
%9 = call i32 @infc_files_dir(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%11 = call i32 @strcpy(i8* %10, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0))
%12 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%13 = call i32 @strcat(i8* %12, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%14 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%15 = call i32 @strcat(i8* %14, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%16 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%17 = call i32 @strcat(i8* %16, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%18 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%19 = call i32 @strcat(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%20 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%21 = call i32 @strcat(i8* %20, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%22 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%23 = call i8* @randstr(i32 8)
%24 = call i32 @strcat(i8* %22, i8* %23)
%25 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%26 = call i32 @strcat(i8* %25, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%27 = load i8*, i8** %3
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.6, i64 0, i64 0), i8* %27)
%29 = call i32 @system(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0))
store i32 %29, i32* %5
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %2
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
br label %36
33: ; preds = %2
%34 = load i8*, i8** %3
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i8* %34, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.10, i64 0, i64 0))
br label %36
36: ; preds = %33, %31
%37 = call i32 @putchar(i8 signext 10)
%38 = load i32, i32* %4
%39 = icmp sgt i32 %38, 0
br i1 %39, label %40, label %45
40: ; preds = %36
%41 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%42 = call i32 @strcat(i8* %41, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0))
%43 = load i8*, i8** %3
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.12, i64 0, i64 0), i8* %43)
br label %50
45: ; preds = %36
%46 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%47 = call i32 @strcat(i8* %46, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.13, i64 0, i64 0))
%48 = load i8*, i8** %3
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.14, i64 0, i64 0), i8* %48)
br label %50
50: ; preds = %45, %40
%51 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%52 = call i32 @system(i8* %51)
store i32 %52, i32* %6
%53 = icmp eq i32 %52, 0
br i1 %53, label %54, label %57
54: ; preds = %50
%55 = load i8*, i8** %3
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.15, i64 0, i64 0), i8* %55, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %60
57: ; preds = %50
%58 = load i8*, i8** %3
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.16, i64 0, i64 0), i8* %58)
br label %60
60: ; preds = %57, %54
%61 = call i32 @putchar(i8 signext 10)
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"SCQuarantine\00"
@.str.1 = [46 x i8] c"sleep 1 && clamscan -vir --bell --move=$HOME/\00"
@.str.2 = [14 x i8] c" --log=$HOME/\00"
@.str.3 = [2 x i8] c"/\00"
@.str.4 = [11 x i8] c"SCReport-0\00"
@.str.5 = [6 x i8] c".txt \00"
@.str.6 = [52 x i8] c"%s: Updating ClamAV virus database. Please wait...\0A\00"
@.str.7 = [30 x i8] c"sleep 1 && freshclam --quiet \00"
@.str.9 = [7 x i8] c"%s: %s\00"
@.str.10 = [43 x i8] c"Command failed to execute due to error(s).\00"
@.str.11 = [3 x i8] c"/*\00"
@.str.12 = [63 x i8] c"%s: Initiating full scan (might take a while). Please wait...\0A\00"
@.str.13 = [8 x i8] c"$HOME/*\00"
@.str.14 = [59 x i8] c"%s: Scanning home directory (recursively). Please wait...\0A\00"
@.str.15 = [56 x i8] c"%s: Please check the %s folder for any infected files.\0A\00"
@.str.16 = [44 x i8] c"%s: Virus scanning failed due to error(s).\0A\00"
@str = [5 x i8] c"Done\00"
define void @clam_scan_util(i8* %0, i32 %1) {
%3 = alloca [128 x i8]
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @infc_files_dir(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %0)
%6 = call i32 @strcpy(i8* %4, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%12 = call i8* @randstr(i32 8)
%13 = call i32 @strcat(i8* %4, i8* %12)
%14 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.6, i64 0, i64 0), i8* %0)
%16 = call i32 @system(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0))
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %2
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
br label %22
20: ; preds = %2
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.10, i64 0, i64 0))
br label %22
22: ; preds = %20, %18
%23 = call i32 @putchar(i8 signext 10)
%24 = icmp sgt i32 %1, 0
%25 = select i1 %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.13, i64 0, i64 0)
%26 = select i1 %24, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.14, i64 0, i64 0)
%27 = call i32 @strcat(i8* %4, i8* %25)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %26, i8* %0)
%29 = call i32 @system(i8* %4)
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %22
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.15, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %35
33: ; preds = %22
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.16, i64 0, i64 0), i8* %0)
br label %35
35: ; preds = %33, %31
%36 = call i32 @putchar(i8 signext 10)
ret void
}