#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__ streq(char *, char *);
int strlen(char *);
int is_valid_script_filename(char *filename) {
  int n = strlen(filename);
  if ((n > 2) &&
      (streq(filename + n - 2, ".C") || streq(filename + n - 2, ".c")) &&
      (filename[0] != '.') && (filename[0] != '_'))
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<is_valid_script_filename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x2,-0x14(%rbp)
jle    11b8 <is_valid_script_filename+0x98>
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rax
add    %rax,%rdi
add    $0xfffffffffffffffe,%rdi
lea    0xea8(%rip),%rsi
call   1040 <streq@plt>
cmp    $0x0,%rax
jne    118c <is_valid_script_filename+0x6c>
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rax
add    %rax,%rdi
add    $0xfffffffffffffffe,%rdi
lea    0xe86(%rip),%rsi
call   1040 <streq@plt>
cmp    $0x0,%rax
je     11b8 <is_valid_script_filename+0x98>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
je     11b8 <is_valid_script_filename+0x98>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5f,%eax
je     11b8 <is_valid_script_filename+0x98>
movl   $0x1,-0x4(%rbp)
jmp    11bf <is_valid_script_filename+0x9f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_valid_script_filename>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
xor    %ebp,%ebp
cmp    $0x3,%eax
jl     1176 <is_valid_script_filename+0x56>
mov    %eax,%eax
lea    (%rbx,%rax,1),%r14
add    $0xfffffffffffffffe,%r14
lea    0xebc(%rip),%rsi
mov    %r14,%rdi
call   1040 <streq@plt>
test   %rax,%rax
jne    1165 <is_valid_script_filename+0x45>
lea    0xeab(%rip),%rsi
mov    %r14,%rdi
call   1040 <streq@plt>
test   %rax,%rax
je     1176 <is_valid_script_filename+0x56>
mov    (%rbx),%al
cmp    $0x2e,%al
setne  %cl
cmp    $0x5f,%al
setne  %al
and    %cl,%al
movzbl %al,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c".C\00"
@.str.1 = [3 x i8] c".c\00"
define i32 @is_valid_script_filename(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i32 @strlen(i8* %5)
store i32 %6, i32* %4
%7 = load i32, i32* %4
%8 = icmp sgt i32 %7, 2
br i1 %8, label %9, label %38
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = load i32, i32* %4
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %10, i64 %12
%14 = getelementptr inbounds i8, i8* %13, i64 -2
%15 = call i64 @streq(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%16 = icmp ne i64 %15, 0
br i1 %16, label %25, label %17
17: ; preds = %9
%18 = load i8*, i8** %3
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
%22 = getelementptr inbounds i8, i8* %21, i64 -2
%23 = call i64 @streq(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %38
25: ; preds = %17, %9
%26 = load i8*, i8** %3
%27 = getelementptr inbounds i8, i8* %26, i64 0
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp ne i32 %29, 46
br i1 %30, label %31, label %38
31: ; preds = %25
%32 = load i8*, i8** %3
%33 = getelementptr inbounds i8, i8* %32, i64 0
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp ne i32 %35, 95
br i1 %36, label %37, label %38
37: ; preds = %31
store i32 1, i32* %2
br label %39
38: ; preds = %31, %25, %17, %1
store i32 0, i32* %2
br label %39
39: ; preds = %38, %37
%40 = load i32, i32* %2
ret i32 %40
}

LLVM IR (-O2):
@.str = [3 x i8] c".C\00"
@.str.1 = [3 x i8] c".c\00"
define i32 @is_valid_script_filename(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp sgt i32 %2, 2
br i1 %3, label %4, label %19
4: ; preds = %1
%5 = zext i32 %2 to i64
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = getelementptr inbounds i8, i8* %6, i64 -2
%8 = tail call i64 @streq(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %4
%11 = tail call i64 @streq(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %19, label %13
13: ; preds = %10, %4
%14 = load i8, i8* %0
%15 = icmp ne i8 %14, 46
%16 = icmp ne i8 %14, 95
%17 = and i1 %15, %16
%18 = zext i1 %17 to i32
br label %19
19: ; preds = %1, %10, %13
%20 = phi i32 [ %18, %13 ], [ 0, %10 ], [ 0, %1 ]
ret i32 %20
}