#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 */
scalar_t__ strcasecmp(char *, char *);
scalar_t__ strncasecmp(char *, char *, int);
int filter_type_url(char *str, size_t n) {
  static char *type[] = {".css", ".ico", ".xml", ".gif", ".jpg",
                         ".png", ".exe", ".chm", NULL};
  if (strncasecmp(str, "http://", 7) || (strcasecmp(str, "http://") == 0)) {
    return -1;
  }
  char **p = type;
  if (n >= 3) {
    if (!strncasecmp(str + n - 3, ".js", 3))
      return -1;
  }
  if (n >= 4) {
    for (; *p; p++) {
      if (!strncasecmp(str + n - 4, *p, 4))
        return -1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<filter_type_url>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeed(%rip),%rsi
mov    $0x7,%edx
call   1040 <strncasecmp@plt>
cmp    $0x0,%rax
jne    1169 <filter_type_url+0x49>
mov    -0x10(%rbp),%rdi
lea    0xece(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1175 <filter_type_url+0x55>
movl   $0xffffffff,-0x4(%rbp)
jmp    1236 <filter_type_url+0x116>
lea    0x2ec4(%rip),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x3,-0x18(%rbp)
jb     11c3 <filter_type_url+0xa3>
mov    -0x10(%rbp),%rdi
add    -0x18(%rbp),%rdi
add    $0xfffffffffffffffd,%rdi
lea    0xe92(%rip),%rsi
mov    $0x3,%edx
call   1040 <strncasecmp@plt>
cmp    $0x0,%rax
jne    11be <filter_type_url+0x9e>
movl   $0xffffffff,-0x4(%rbp)
jmp    1236 <filter_type_url+0x116>
jmp    11c3 <filter_type_url+0xa3>
cmpq   $0x4,-0x18(%rbp)
jb     122f <filter_type_url+0x10f>
jmp    11d3 <filter_type_url+0xb3>
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
je     122a <filter_type_url+0x10a>
mov    -0x10(%rbp),%rdi
add    -0x18(%rbp),%rdi
add    $0xfffffffffffffffc,%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%rsi
mov    $0x4,%edx
call   1040 <strncasecmp@plt>
cmp    $0x0,%rax
jne    1214 <filter_type_url+0xf4>
movl   $0xffffffff,-0x4(%rbp)
jmp    1236 <filter_type_url+0x116>
jmp    1219 <filter_type_url+0xf9>
mov    -0x20(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x20(%rbp)
jmp    11d3 <filter_type_url+0xb3>
jmp    122f <filter_type_url+0x10f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<filter_type_url>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xef7(%rip),%rsi
mov    $0x7,%edx
call   1040 <strncasecmp@plt>
test   %rax,%rax
je     114c <filter_type_url+0x2c>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xed5(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1140 <filter_type_url+0x20>
xor    %ebp,%ebp
cmp    $0x3,%rbx
jb     1145 <filter_type_url+0x25>
lea    (%r14,%rbx,1),%rdi
add    $0xfffffffffffffffd,%rdi
lea    0xeb9(%rip),%rsi
mov    $0x3,%edx
call   1040 <strncasecmp@plt>
test   %rax,%rax
je     1140 <filter_type_url+0x20>
cmp    $0x4,%rbx
jb     1145 <filter_type_url+0x25>
add    %rbx,%r14
add    $0xfffffffffffffffc,%r14
lea    0xe66(%rip),%rsi
mov    %r14,%rdi
mov    $0x4,%edx
call   1040 <strncasecmp@plt>
test   %rax,%rax
je     1140 <filter_type_url+0x20>
lea    0xe52(%rip),%rsi
mov    %r14,%rdi
mov    $0x4,%edx
call   1040 <strncasecmp@plt>
test   %rax,%rax
je     1140 <filter_type_url+0x20>
lea    0xe3a(%rip),%rsi
mov    %r14,%rdi
mov    $0x4,%edx
call   1040 <strncasecmp@plt>
test   %rax,%rax
je     1140 <filter_type_url+0x20>
lea    0xe22(%rip),%rsi
mov    %r14,%rdi
mov    $0x4,%edx
call   1040 <strncasecmp@plt>
test   %rax,%rax
je     1140 <filter_type_url+0x20>
lea    0xe0a(%rip),%rsi
mov    %r14,%rdi
mov    $0x4,%edx
call   1040 <strncasecmp@plt>
test   %rax,%rax
je     1140 <filter_type_url+0x20>
lea    0xdf2(%rip),%rsi
mov    %r14,%rdi
mov    $0x4,%edx
call   1040 <strncasecmp@plt>
test   %rax,%rax
je     1140 <filter_type_url+0x20>
lea    0xdda(%rip),%rsi
mov    %r14,%rdi
mov    $0x4,%edx
call   1040 <strncasecmp@plt>
mov    $0xffffffff,%ebp
test   %rax,%rax
je     1145 <filter_type_url+0x25>
lea    0xdbd(%rip),%rsi
mov    %r14,%rdi
mov    $0x4,%edx
call   1040 <strncasecmp@plt>
cmp    $0x1,%rax
sbb    %ebp,%ebp
jmp    1145 <filter_type_url+0x25>

LLVM IR (-O0):
@filter_type_url.type = internal global [9 x i8*] [i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i32 0, i32 0), i8* null]
@.str = [5 x i8] c".css\00"
@.str.1 = [5 x i8] c".ico\00"
@.str.2 = [5 x i8] c".xml\00"
@.str.3 = [5 x i8] c".gif\00"
@.str.4 = [5 x i8] c".jpg\00"
@.str.5 = [5 x i8] c".png\00"
@.str.6 = [5 x i8] c".exe\00"
@.str.7 = [5 x i8] c".chm\00"
@.str.8 = [8 x i8] c"http://\00"
@.str.9 = [4 x i8] c".js\00"
define i32 @filter_type_url(i8* %0, i64 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i8**
store i8* %0, i8** %4
store i64 %1, i64* %5
%7 = load i8*, i8** %4
%8 = call i64 @strncasecmp(i8* %7, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i32 7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %2
%11 = load i8*, i8** %4
%12 = call i64 @strcasecmp(i8* %11, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %10, %2
store i32 -1, i32* %3
br label %51
15: ; preds = %10
store i8** getelementptr inbounds ([9 x i8*], [9 x i8*]* @filter_type_url.type, i64 0, i64 0), i8*** %6
%16 = load i64, i64* %5
%17 = icmp uge i64 %16, 3
br i1 %17, label %18, label %27
18: ; preds = %15
%19 = load i8*, i8** %4
%20 = load i64, i64* %5
%21 = getelementptr inbounds i8, i8* %19, i64 %20
%22 = getelementptr inbounds i8, i8* %21, i64 -3
%23 = call i64 @strncasecmp(i8* %22, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i32 3)
%24 = icmp ne i64 %23, 0
br i1 %24, label %26, label %25
25: ; preds = %18
store i32 -1, i32* %3
br label %51
26: ; preds = %18
br label %27
27: ; preds = %26, %15
%28 = load i64, i64* %5
%29 = icmp uge i64 %28, 4
br i1 %29, label %30, label %50
30: ; preds = %27
br label %31
31: ; preds = %46, %30
%32 = load i8**, i8*** %6
%33 = load i8*, i8** %32
%34 = icmp ne i8* %33, null
br i1 %34, label %35, label %49
35: ; preds = %31
%36 = load i8*, i8** %4
%37 = load i64, i64* %5
%38 = getelementptr inbounds i8, i8* %36, i64 %37
%39 = getelementptr inbounds i8, i8* %38, i64 -4
%40 = load i8**, i8*** %6
%41 = load i8*, i8** %40
%42 = call i64 @strncasecmp(i8* %39, i8* %41, i32 4)
%43 = icmp ne i64 %42, 0
br i1 %43, label %45, label %44
44: ; preds = %35
store i32 -1, i32* %3
br label %51
45: ; preds = %35
br label %46
46: ; preds = %45
%47 = load i8**, i8*** %6
%48 = getelementptr inbounds i8*, i8** %47, i32 1
store i8** %48, i8*** %6
br label %31
49: ; preds = %31
br label %50
50: ; preds = %49, %27
store i32 0, i32* %3
br label %51
51: ; preds = %50, %44, %25, %14
%52 = load i32, i32* %3
ret i32 %52
}

LLVM IR (-O2):
@.str = [5 x i8] c".css\00"
@.str.1 = [5 x i8] c".ico\00"
@.str.2 = [5 x i8] c".xml\00"
@.str.3 = [5 x i8] c".gif\00"
@.str.4 = [5 x i8] c".jpg\00"
@.str.5 = [5 x i8] c".png\00"
@.str.6 = [5 x i8] c".exe\00"
@.str.7 = [5 x i8] c".chm\00"
@.str.8 = [8 x i8] c"http://\00"
@.str.9 = [4 x i8] c".js\00"
define i32 @filter_type_url(i8* nocapture %0, i64 %1) {
%3 = tail call i64 @strncasecmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i32 7)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %43
5: ; preds = %2
%6 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %43, label %8
8: ; preds = %5
%9 = icmp ugt i64 %1, 2
br i1 %9, label %10, label %43
10: ; preds = %8
%11 = getelementptr inbounds i8, i8* %0, i64 %1
%12 = getelementptr inbounds i8, i8* %11, i64 -3
%13 = tail call i64 @strncasecmp(i8* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i32 3)
%14 = icmp eq i64 %13, 0
br i1 %14, label %43, label %15
15: ; preds = %10
%16 = icmp ugt i64 %1, 3
br i1 %16, label %17, label %43
17: ; preds = %15
%18 = getelementptr inbounds i8, i8* %11, i64 -4
%19 = tail call i64 @strncasecmp(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%20 = icmp eq i64 %19, 0
br i1 %20, label %43, label %21
21: ; preds = %17
%22 = tail call i64 @strncasecmp(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%23 = icmp eq i64 %22, 0
br i1 %23, label %43, label %24
24: ; preds = %21
%25 = tail call i64 @strncasecmp(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 4)
%26 = icmp eq i64 %25, 0
br i1 %26, label %43, label %27
27: ; preds = %24
%28 = tail call i64 @strncasecmp(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 4)
%29 = icmp eq i64 %28, 0
br i1 %29, label %43, label %30
30: ; preds = %27
%31 = tail call i64 @strncasecmp(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 4)
%32 = icmp eq i64 %31, 0
br i1 %32, label %43, label %33
33: ; preds = %30
%34 = tail call i64 @strncasecmp(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 4)
%35 = icmp eq i64 %34, 0
br i1 %35, label %43, label %36
36: ; preds = %33
%37 = tail call i64 @strncasecmp(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 4)
%38 = icmp eq i64 %37, 0
br i1 %38, label %43, label %39
39: ; preds = %36
%40 = tail call i64 @strncasecmp(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 4)
%41 = icmp eq i64 %40, 0
%42 = sext i1 %41 to i32
br label %43
43: ; preds = %39, %17, %21, %24, %27, %30, %33, %36, %8, %10, %15, %2, %5
%44 = phi i32 [ -1, %5 ], [ -1, %2 ], [ -1, %10 ], [ 0, %15 ], [ 0, %8 ], [ -1, %17 ], [ -1, %21 ], [ -1, %24 ], [ -1, %27 ], [ -1, %30 ], [ -1, %33 ], [ -1, %36 ], [ %42, %39 ]
ret i32 %44
}