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

/* Variables and functions */
scalar_t__ strcmp(char const *, char const *);
size_t strlen(char const *);
int isSourceFile(const char *path) {
  const char *suffixes[] = {
      ".l", ".y", ".h", ".c", ".cpp",
  };
  size_t num_suffixes = sizeof(suffixes) / sizeof(suffixes[0]);
  size_t n = strlen(path);
  size_t i;
  for (i = 0; i < num_suffixes; i++) {
    size_t m = strlen(suffixes[i]);
    if (n >= m && strcmp(path + n - m, suffixes[i]) == 0) {
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<isSourceFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1040 <memset@plt>
lea    0xead(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xea5(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    0xe9d(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xe95(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xe8d(%rip),%rax
mov    %rax,-0x20(%rbp)
movq   $0x5,-0x48(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x50(%rbp)
movq   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%rax
cmp    -0x48(%rbp),%rax
jae    1219 <isSourceFile+0xe9>
mov    -0x58(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x60(%rbp)
mov    -0x50(%rbp),%rax
cmp    -0x60(%rbp),%rax
jb     1203 <isSourceFile+0xd3>
mov    -0x10(%rbp),%rdi
add    -0x50(%rbp),%rdi
xor    %eax,%eax
sub    -0x60(%rbp),%rax
add    %rax,%rdi
mov    -0x58(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1203 <isSourceFile+0xd3>
movl   $0x1,-0x4(%rbp)
jmp    1220 <isSourceFile+0xf0>
jmp    1208 <isSourceFile+0xd8>
mov    -0x58(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x58(%rbp)
jmp    11a0 <isSourceFile+0x70>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isSourceFile>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <strlen@plt>
cmp    $0x2,%rax
jae    113d <isSourceFile+0x1d>
xor    %r14d,%r14d
jmp    11bf <isSourceFile+0x9f>
mov    %rax,%rbp
add    %rax,%rbx
lea    -0x2(%rbx),%r15
lea    0xeb2(%rip),%rsi
mov    %r15,%rdi
call   1040 <strcmp@plt>
mov    $0x1,%r14d
test   %rax,%rax
je     11bf <isSourceFile+0x9f>
lea    0xe9b(%rip),%rsi
mov    %r15,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11bf <isSourceFile+0x9f>
lea    0xe8a(%rip),%rsi
mov    %r15,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11bf <isSourceFile+0x9f>
lea    0xe79(%rip),%rsi
mov    %r15,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11bf <isSourceFile+0x9f>
cmp    $0x4,%rbp
jb     1135 <isSourceFile+0x15>
add    $0xfffffffffffffffc,%rbx
lea    0xe5e(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1135 <isSourceFile+0x15>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c".l\00"
@.str.1 = [3 x i8] c".y\00"
@.str.2 = [3 x i8] c".h\00"
@.str.3 = [3 x i8] c".c\00"
@.str.4 = [5 x i8] c".cpp\00"
define i32 @isSourceFile(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [5 x i8*]
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
store i8* %0, i8** %3
%9 = bitcast [5 x i8*]* %4 to i8*
%10 = bitcast i8* %9 to [5 x i8*]*
%11 = getelementptr inbounds [5 x i8*], [5 x i8*]* %10, i32 0, i32 0
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8** %11
%12 = getelementptr inbounds [5 x i8*], [5 x i8*]* %10, i32 0, i32 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i32 0, i32 0), i8** %12
%13 = getelementptr inbounds [5 x i8*], [5 x i8*]* %10, i32 0, i32 2
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i8** %13
%14 = getelementptr inbounds [5 x i8*], [5 x i8*]* %10, i32 0, i32 3
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i32 0, i32 0), i8** %14
%15 = getelementptr inbounds [5 x i8*], [5 x i8*]* %10, i32 0, i32 4
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i32 0, i32 0), i8** %15
store i64 5, i64* %5
%16 = load i8*, i8** %3
%17 = call i64 @strlen(i8* %16)
store i64 %17, i64* %6
store i64 0, i64* %7
br label %18
18: ; preds = %44, %1
%19 = load i64, i64* %7
%20 = load i64, i64* %5
%21 = icmp ult i64 %19, %20
br i1 %21, label %22, label %47
22: ; preds = %18
%23 = load i64, i64* %7
%24 = getelementptr inbounds [5 x i8*], [5 x i8*]* %4, i64 0, i64 %23
%25 = load i8*, i8** %24
%26 = call i64 @strlen(i8* %25)
store i64 %26, i64* %8
%27 = load i64, i64* %6
%28 = load i64, i64* %8
%29 = icmp uge i64 %27, %28
br i1 %29, label %30, label %43
30: ; preds = %22
%31 = load i8*, i8** %3
%32 = load i64, i64* %6
%33 = getelementptr inbounds i8, i8* %31, i64 %32
%34 = load i64, i64* %8
%35 = sub i64 0, %34
%36 = getelementptr inbounds i8, i8* %33, i64 %35
%37 = load i64, i64* %7
%38 = getelementptr inbounds [5 x i8*], [5 x i8*]* %4, i64 0, i64 %37
%39 = load i8*, i8** %38
%40 = call i64 @strcmp(i8* %36, i8* %39)
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %43
42: ; preds = %30
store i32 1, i32* %2
br label %48
43: ; preds = %30, %22
br label %44
44: ; preds = %43
%45 = load i64, i64* %7
%46 = add i64 %45, 1
store i64 %46, i64* %7
br label %18
47: ; preds = %18
store i32 0, i32* %2
br label %48
48: ; preds = %47, %42
%49 = load i32, i32* %2
ret i32 %49
}

LLVM IR (-O2):
@.str = [3 x i8] c".l\00"
@.str.1 = [3 x i8] c".y\00"
@.str.2 = [3 x i8] c".h\00"
@.str.3 = [3 x i8] c".c\00"
@.str.4 = [5 x i8] c".cpp\00"
define i32 @isSourceFile(i8* %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = getelementptr inbounds i8, i8* %0, i64 %2
%4 = icmp ult i64 %2, 2
br i1 %4, label %27, label %5
5: ; preds = %1
%6 = getelementptr inbounds i8, i8* %3, i64 -2
%7 = tail call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %28, label %9
9: ; preds = %5
%10 = getelementptr inbounds i8, i8* %3, i64 -2
%11 = tail call i64 @strcmp(i8* %10, 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 %28, label %13
13: ; preds = %9
%14 = getelementptr inbounds i8, i8* %3, i64 -2
%15 = tail call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %28, label %17
17: ; preds = %13
%18 = getelementptr inbounds i8, i8* %3, i64 -2
%19 = tail call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %28, label %21
21: ; preds = %17
%22 = icmp ult i64 %2, 4
br i1 %22, label %27, label %23
23: ; preds = %21
%24 = getelementptr inbounds i8, i8* %3, i64 -4
%25 = tail call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %28, label %27
27: ; preds = %1, %23, %21
br label %28
28: ; preds = %27, %23, %17, %13, %9, %5
%29 = phi i32 [ 1, %5 ], [ 1, %9 ], [ 1, %13 ], [ 1, %17 ], [ 1, %23 ], [ 0, %27 ]
ret i32 %29
}