#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 scalar_t__ clock_t;

/* Variables and functions */
scalar_t__ CLOCKS_PER_SEC;
scalar_t__ clock();
int /*<<< orphan*/ libinjection_xss(char const *const, size_t);
size_t strlen(char const *const);
int testIsSQL(void) {
  const char *const s[] = {"<script>alert(1);</script>",
                           "><script>alert(1);</script>"
                           "x ><script>alert(1);</script>",
                           "' ><script>alert(1);</script>",
                           "\"><script>alert(1);</script>",
                           "red;</style><script>alert(1);</script>",
                           "red;}</style><script>alert(1);</script>",
                           "red;\"/><script>alert(1);</script>",
                           "');}</style><script>alert(1);</script>",
                           "onerror=alert(1)>",
                           "x onerror=alert(1);>",
                           "x' onerror=alert(1);>",
                           "x\" onerror=alert(1);>",
                           "<a href=\"javascript:alert(1)\">",
                           "<a href='javascript:alert(1)'>",
                           "<a href=javascript:alert(1)>",
                           "<a href  =   javascript:alert(1); >",
                           "<a href=\"  javascript:alert(1);\" >",
                           "<a href=\"JAVASCRIPT:alert(1);\" >",
                           "123 LIKE -1234.5678E+2;",
                           "APPLE 19.123 'FOO' \"BAR\"",
                           "/* BAR */ UNION ALL SELECT (2,3,4)",
                           "1 || COS(+0X04) --FOOBAR",
                           "dog apple @cat banana bar",
                           "dog apple cat \"banana \'bar",
                           "102 TABLE CLOTH",
                           "(1001-'1') union select 1,2,3,4 from credit_cards",
                           NULL};
  const int imax = 1000000;
  int i, j;
  size_t slen;
  clock_t t0, t1;
  double total;
  int tps;
  t0 = clock();
  for (i = imax, j = 0; i != 0; --i, ++j) {
    if (s[j] == NULL) {
      j = 0;
    }
    slen = strlen(s[j]);
    libinjection_xss(s[j], slen);
  }
  t1 = clock();
  total = (double)(t1 - t0) / (double)CLOCKS_PER_SEC;
  tps = (int)((double)imax / total);
  return tps;
}


x86 assembly (clang, -O0):
<testIsSQL>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
lea    -0xe0(%rbp),%rdi
lea    0x2be7(%rip),%rsi
mov    $0xd8,%edx
call   1060 <memcpy@plt>
movl   $0xf4240,-0xe4(%rbp)
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x100(%rbp)
movl   $0xf4240,-0xe8(%rbp)
movl   $0x0,-0xec(%rbp)
cmpl   $0x0,-0xe8(%rbp)
je     1215 <testIsSQL+0xd5>
movslq -0xec(%rbp),%rax
cmpq   $0x0,-0xe0(%rbp,%rax,8)
jne    11bc <testIsSQL+0x7c>
movl   $0x0,-0xec(%rbp)
movslq -0xec(%rbp),%rax
mov    -0xe0(%rbp,%rax,8),%rdi
ff
call   1050 <strlen@plt>
mov    %rax,-0xf8(%rbp)
movslq -0xec(%rbp),%rax
mov    -0xe0(%rbp,%rax,8),%rdi
ff
mov    -0xf8(%rbp),%rsi
call   1030 <libinjection_xss@plt>
mov    -0xe8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xe8(%rbp)
mov    -0xec(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xec(%rbp)
jmp    118f <testIsSQL+0x4f>
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x108(%rbp)
mov    -0x108(%rbp),%rax
sub    -0x100(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    0x2dab(%rip),%rax
cvtsi2sdq (%rax),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x110(%rbp)
ff
movsd  0xdaa(%rip),%xmm0
divsd  -0x110(%rbp),%xmm0
ff
cvttsd2si %xmm0,%eax
mov    %eax,-0x114(%rbp)
mov    -0x114(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testIsSQL>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %r15d,%r15d
xor    %eax,%eax
call   1040 <clock@plt>
mov    %rax,%r14
mov    $0xfff0bdc0,%ebp
lea    0x2bec(%rip),%r12
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
cmp    $0x1a,%ebx
cmove  %r15d,%ebx
movslq %ebx,%rbx
mov    (%r12,%rbx,8),%r13
mov    %r13,%rdi
call   1050 <strlen@plt>
mov    %r13,%rdi
mov    %rax,%rsi
call   1030 <libinjection_xss@plt>
add    $0x1,%ebx
inc    %ebp
jne    1160 <testIsSQL+0x30>
xor    %eax,%eax
call   1040 <clock@plt>
sub    %r14,%rax
cvtsi2sd %rax,%xmm0
mov    0x2e4a(%rip),%rax
cvtsi2sdq (%rax),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe51(%rip),%xmm1
divsd  %xmm0,%xmm1
cvttsd2si %xmm1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [27 x i8] c"<script>alert(1);</script>\00"
@.str.1 = [57 x i8] c"><script>alert(1);</script>x ><script>alert(1);</script>\00"
@.str.2 = [30 x i8] c"' ><script>alert(1);</script>\00"
@.str.3 = [29 x i8] c"\22><script>alert(1);</script>\00"
@.str.4 = [39 x i8] c"red;</style><script>alert(1);</script>\00"
@.str.5 = [40 x i8] c"red;}</style><script>alert(1);</script>\00"
@.str.6 = [34 x i8] c"red;\22/><script>alert(1);</script>\00"
@.str.7 = [39 x i8] c"');}</style><script>alert(1);</script>\00"
@.str.8 = [18 x i8] c"onerror=alert(1)>\00"
@.str.9 = [21 x i8] c"x onerror=alert(1);>\00"
@.str.10 = [22 x i8] c"x' onerror=alert(1);>\00"
@.str.11 = [22 x i8] c"x\22 onerror=alert(1);>\00"
@.str.12 = [31 x i8] c"<a href=\22javascript:alert(1)\22>\00"
@.str.13 = [31 x i8] c"<a href='javascript:alert(1)'>\00"
@.str.14 = [29 x i8] c"<a href=javascript:alert(1)>\00"
@.str.15 = [36 x i8] c"<a href = javascript:alert(1); >\00"
@.str.16 = [35 x i8] c"<a href=\22 javascript:alert(1);\22 >\00"
@.str.17 = [33 x i8] c"<a href=\22JAVASCRIPT:alert(1);\22 >\00"
@.str.18 = [24 x i8] c"123 LIKE -1234.5678E+2;\00"
@.str.19 = [25 x i8] c"APPLE 19.123 'FOO' \22BAR\22\00"
@.str.20 = [35 x i8] c"/* BAR */ UNION ALL SELECT (2,3,4)\00"
@.str.21 = [25 x i8] c"1 || COS(+0X04) --FOOBAR\00"
@.str.22 = [26 x i8] c"dog apple @cat banana bar\00"
@.str.23 = [27 x i8] c"dog apple cat \22banana 'bar\00"
@.str.24 = [16 x i8] c"102 TABLE CLOTH\00"
@.str.25 = [50 x i8] c"(1001-'1') union select 1,2,3,4 from credit_cards\00"
@__const.testIsSQL.s = [27 x i8*] [i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.15, i32 0, i32 0), i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.16, i32 0, i32 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.17, i32 0, i32 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.18, i32 0, i32 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.19, i32 0, i32 0), i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.20, i32 0, i32 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.21, i32 0, i32 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.22, i32 0, i32 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.23, i32 0, i32 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.24, i32 0, i32 0), i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.25, i32 0, i32 0), i8* null]
@CLOCKS_PER_SEC = global i64 0
define i32 @testIsSQL() {
%1 = alloca [27 x i8*]
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca double
%9 = alloca i32
%10 = bitcast [27 x i8*]* %1 to i8*
store i32 1000000, i32* %2
%11 = call i64 (...) @clock()
store i64 %11, i64* %6
store i32 1000000, i32* %3
store i32 0, i32* %4
br label %12
12: ; preds = %34, %0
%13 = load i32, i32* %3
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %39
15: ; preds = %12
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [27 x i8*], [27 x i8*]* %1, i64 0, i64 %17
%19 = load i8*, i8** %18
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %22
21: ; preds = %15
store i32 0, i32* %4
br label %22
22: ; preds = %21, %15
%23 = load i32, i32* %4
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [27 x i8*], [27 x i8*]* %1, i64 0, i64 %24
%26 = load i8*, i8** %25
%27 = call i64 @strlen(i8* %26)
store i64 %27, i64* %5
%28 = load i32, i32* %4
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [27 x i8*], [27 x i8*]* %1, i64 0, i64 %29
%31 = load i8*, i8** %30
%32 = load i64, i64* %5
%33 = call i32 @libinjection_xss(i8* %31, i64 %32)
br label %34
34: ; preds = %22
%35 = load i32, i32* %3
%36 = add nsw i32 %35, -1
store i32 %36, i32* %3
%37 = load i32, i32* %4
%38 = add nsw i32 %37, 1
store i32 %38, i32* %4
br label %12
39: ; preds = %12
%40 = call i64 (...) @clock()
store i64 %40, i64* %7
%41 = load i64, i64* %7
%42 = load i64, i64* %6
%43 = sub nsw i64 %41, %42
%44 = sitofp i64 %43 to double
%45 = load i64, i64* @CLOCKS_PER_SEC
%46 = sitofp i64 %45 to double
%47 = fdiv double %44, %46
store double %47, double* %8
%48 = load double, double* %8
%49 = fdiv double 1.000000e+06, %48
%50 = fptosi double %49 to i32
store i32 %50, i32* %9
%51 = load i32, i32* %9
ret i32 %51
}

LLVM IR (-O2):
@.str = [27 x i8] c"<script>alert(1);</script>\00"
@.str.1 = [57 x i8] c"><script>alert(1);</script>x ><script>alert(1);</script>\00"
@.str.2 = [30 x i8] c"' ><script>alert(1);</script>\00"
@.str.3 = [29 x i8] c"\22><script>alert(1);</script>\00"
@.str.4 = [39 x i8] c"red;</style><script>alert(1);</script>\00"
@.str.5 = [40 x i8] c"red;}</style><script>alert(1);</script>\00"
@.str.6 = [34 x i8] c"red;\22/><script>alert(1);</script>\00"
@.str.7 = [39 x i8] c"');}</style><script>alert(1);</script>\00"
@.str.8 = [18 x i8] c"onerror=alert(1)>\00"
@.str.9 = [21 x i8] c"x onerror=alert(1);>\00"
@.str.10 = [22 x i8] c"x' onerror=alert(1);>\00"
@.str.11 = [22 x i8] c"x\22 onerror=alert(1);>\00"
@.str.12 = [31 x i8] c"<a href=\22javascript:alert(1)\22>\00"
@.str.13 = [31 x i8] c"<a href='javascript:alert(1)'>\00"
@.str.14 = [29 x i8] c"<a href=javascript:alert(1)>\00"
@.str.15 = [36 x i8] c"<a href = javascript:alert(1); >\00"
@.str.16 = [35 x i8] c"<a href=\22 javascript:alert(1);\22 >\00"
@.str.17 = [33 x i8] c"<a href=\22JAVASCRIPT:alert(1);\22 >\00"
@.str.18 = [24 x i8] c"123 LIKE -1234.5678E+2;\00"
@.str.19 = [25 x i8] c"APPLE 19.123 'FOO' \22BAR\22\00"
@.str.20 = [35 x i8] c"/* BAR */ UNION ALL SELECT (2,3,4)\00"
@.str.21 = [25 x i8] c"1 || COS(+0X04) --FOOBAR\00"
@.str.22 = [26 x i8] c"dog apple @cat banana bar\00"
@.str.23 = [27 x i8] c"dog apple cat \22banana 'bar\00"
@.str.24 = [16 x i8] c"102 TABLE CLOTH\00"
@.str.25 = [50 x i8] c"(1001-'1') union select 1,2,3,4 from credit_cards\00"
@__const.testIsSQL.s = [27 x i8*] [i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.15, i32 0, i32 0), i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.16, i32 0, i32 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.17, i32 0, i32 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.18, i32 0, i32 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.19, i32 0, i32 0), i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.20, i32 0, i32 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.21, i32 0, i32 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.22, i32 0, i32 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.23, i32 0, i32 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.24, i32 0, i32 0), i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.25, i32 0, i32 0), i8* null]
@CLOCKS_PER_SEC = global i64 0
define i32 @testIsSQL() {
%1 = tail call i64 (...) @clock()
br label %2
2: ; preds = %0, %2
%3 = phi i32 [ 1000000, %0 ], [ %12, %2 ]
%4 = phi i32 [ 0, %0 ], [ %13, %2 ]
%5 = icmp eq i32 %4, 26
%6 = select i1 %5, i32 0, i32 %4
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds [27 x i8*], [27 x i8*]* @__const.testIsSQL.s, i64 0, i64 %7
%9 = load i8*, i8** %8
%10 = tail call i64 @strlen(i8* dereferenceable(1) %9)
%11 = tail call i32 @libinjection_xss(i8* %9, i64 %10)
%12 = add nsw i32 %3, -1
%13 = add nsw i32 %6, 1
%14 = icmp eq i32 %12, 0
br i1 %14, label %15, label %2
15: ; preds = %2
%16 = tail call i64 (...) @clock()
%17 = sub nsw i64 %16, %1
%18 = sitofp i64 %17 to double
%19 = load i64, i64* @CLOCKS_PER_SEC
%20 = sitofp i64 %19 to double
%21 = fdiv double %18, %20
%22 = fdiv double 1.000000e+06, %21
%23 = fptosi double %22 to i32
ret i32 %23
}