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

/* Variables and functions */
scalar_t__ strstr(char *, char *);
int injection_check(int argc, char *argv[]) {
  char *inject_char[] = {";", "|", "`", "$(", "&&", "||", ">", "<"};
  int char_count = sizeof(inject_char) / sizeof(char *);
  int i = 0;
  int j = 0;
  for (i = 0; i < argc; i++) {
    for (j = 0; j < char_count; j++) {
      if (strstr(argv[i], inject_char[j])) {
        return -1;
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<injection_check>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x50(%rbp),%rdi
lea    0x2ca6(%rip),%rsi
mov    $0x40,%edx
call   1030 <memcpy@plt>
movl   $0x8,-0x54(%rbp)
movl   $0x0,-0x58(%rbp)
movl   $0x0,-0x5c(%rbp)
movl   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11d5 <injection_check+0xb5>
movl   $0x0,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
cmp    -0x54(%rbp),%eax
jge    11c2 <injection_check+0xa2>
mov    -0x10(%rbp),%rax
movslq -0x58(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
movslq -0x5c(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     11af <injection_check+0x8f>
movl   $0xffffffff,-0x4(%rbp)
jmp    11dc <injection_check+0xbc>
jmp    11b4 <injection_check+0x94>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    1173 <injection_check+0x53>
jmp    11c7 <injection_check+0xa7>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    1160 <injection_check+0x40>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<injection_check>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
jle    11f4 <injection_check+0xe4>
mov    %rsi,%rbx
mov    %edi,%r13d
xor    %r12d,%r12d
lea    0xecd(%rip),%r14
lea    0xed1(%rip),%r15
mov    $0xffffffff,%ebp
mov    (%rbx,%r12,8),%rdi
mov    %r14,%rsi
call   1030 <strstr@plt>
test   %rax,%rax
jne    11f6 <injection_check+0xe6>
mov    (%rbx,%r12,8),%rdi
mov    %r15,%rsi
call   1030 <strstr@plt>
test   %rax,%rax
jne    11f6 <injection_check+0xe6>
mov    (%rbx,%r12,8),%rdi
lea    0xe8e(%rip),%rsi
call   1030 <strstr@plt>
test   %rax,%rax
jne    11f6 <injection_check+0xe6>
mov    (%rbx,%r12,8),%rdi
lea    0xe7b(%rip),%rsi
call   1030 <strstr@plt>
test   %rax,%rax
jne    11f6 <injection_check+0xe6>
mov    (%rbx,%r12,8),%rdi
lea    0xe69(%rip),%rsi
call   1030 <strstr@plt>
test   %rax,%rax
jne    11f6 <injection_check+0xe6>
mov    (%rbx,%r12,8),%rdi
lea    0xe57(%rip),%rsi
call   1030 <strstr@plt>
test   %rax,%rax
jne    11f6 <injection_check+0xe6>
mov    (%rbx,%r12,8),%rdi
lea    0xe45(%rip),%rsi
call   1030 <strstr@plt>
test   %rax,%rax
jne    11f6 <injection_check+0xe6>
mov    (%rbx,%r12,8),%rdi
lea    0xe32(%rip),%rsi
call   1030 <strstr@plt>
test   %rax,%rax
jne    11f6 <injection_check+0xe6>
add    $0x1,%r12
cmp    %r12,%r13
jne    113f <injection_check+0x2f>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c";\00"
@.str.1 = [2 x i8] c"|\00"
@.str.2 = [2 x i8] c"`\00"
@.str.3 = [3 x i8] c"$(\00"
@.str.4 = [3 x i8] c"&&\00"
@.str.5 = [3 x i8] c"||\00"
@.str.6 = [2 x i8] c">\00"
@.str.7 = [2 x i8] c"<\00"
@__const.injection_check.inject_char = [8 x i8*] [i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i32 0, i32 0)]
define i32 @injection_check(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [8 x i8*]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = bitcast [8 x i8*]* %6 to i8*
store i32 8, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %8
br label %11
11: ; preds = %38, %2
%12 = load i32, i32* %8
%13 = load i32, i32* %4
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %41
15: ; preds = %11
store i32 0, i32* %9
br label %16
16: ; preds = %34, %15
%17 = load i32, i32* %9
%18 = load i32, i32* %7
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %37
20: ; preds = %16
%21 = load i8**, i8*** %5
%22 = load i32, i32* %8
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8*, i8** %21, i64 %23
%25 = load i8*, i8** %24
%26 = load i32, i32* %9
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [8 x i8*], [8 x i8*]* %6, i64 0, i64 %27
%29 = load i8*, i8** %28
%30 = call i64 @strstr(i8* %25, i8* %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %20
store i32 -1, i32* %3
br label %42
33: ; preds = %20
br label %34
34: ; preds = %33
%35 = load i32, i32* %9
%36 = add nsw i32 %35, 1
store i32 %36, i32* %9
br label %16
37: ; preds = %16
br label %38
38: ; preds = %37
%39 = load i32, i32* %8
%40 = add nsw i32 %39, 1
store i32 %40, i32* %8
br label %11
41: ; preds = %11
store i32 0, i32* %3
br label %42
42: ; preds = %41, %32
%43 = load i32, i32* %3
ret i32 %43
}

LLVM IR (-O2):
@.str = [2 x i8] c";\00"
@.str.1 = [2 x i8] c"|\00"
@.str.2 = [2 x i8] c"`\00"
@.str.3 = [3 x i8] c"$(\00"
@.str.4 = [3 x i8] c"&&\00"
@.str.5 = [3 x i8] c"||\00"
@.str.6 = [2 x i8] c">\00"
@.str.7 = [2 x i8] c"<\00"
define i32 @injection_check(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 0
br i1 %3, label %4, label %43
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %6
6: ; preds = %4, %40
%7 = phi i64 [ 0, %4 ], [ %41, %40 ]
%8 = getelementptr inbounds i8*, i8** %1, i64 %7
%9 = load i8*, i8** %8
%10 = tail call i64 @strstr(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %43
12: ; preds = %6
%13 = load i8*, i8** %8
%14 = tail call i64 @strstr(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %43
16: ; preds = %12
%17 = load i8*, i8** %8
%18 = tail call i64 @strstr(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %43
20: ; preds = %16
%21 = load i8*, i8** %8
%22 = tail call i64 @strstr(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %43
24: ; preds = %20
%25 = load i8*, i8** %8
%26 = tail call i64 @strstr(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %43
28: ; preds = %24
%29 = load i8*, i8** %8
%30 = tail call i64 @strstr(i8* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %43
32: ; preds = %28
%33 = load i8*, i8** %8
%34 = tail call i64 @strstr(i8* %33, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %43
36: ; preds = %32
%37 = load i8*, i8** %8
%38 = tail call i64 @strstr(i8* %37, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %43
40: ; preds = %36
%41 = add nuw nsw i64 %7, 1
%42 = icmp eq i64 %41, %5
br i1 %42, label %43, label %6
43: ; preds = %40, %6, %12, %16, %20, %24, %28, %32, %36, %2
%44 = phi i32 [ 0, %2 ], [ 0, %40 ], [ -1, %6 ], [ -1, %12 ], [ -1, %16 ], [ -1, %20 ], [ -1, %24 ], [ -1, %28 ], [ -1, %32 ], [ -1, %36 ]
ret i32 %44
}