#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 */
char *GetFileExt(char *);
scalar_t__ strcmp(char *, char const *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int IsImageFile(char *filename) {
  char temp[1024];
  const char *ext = GetFileExt(filename);
  if (strcmp(".png" + 1, ext) == 0) {
    strncpy(temp, filename, strlen(filename) - 4);
    temp[strlen(filename) - 4] = '\0';
    ext = GetFileExt(temp);
    if (strcmp(temp + (strlen(temp) - 5), "depth") == 0 ||
        strcmp("depth", ext) == 0 || strcmp("mask", ext) == 0) {
      return 0;
    }
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<IsImageFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <GetFileExt@plt>
mov    %rax,-0x418(%rbp)
mov    -0x418(%rbp),%rsi
lea    0xe94(%rip),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1270 <IsImageFile+0x130>
lea    -0x410(%rbp),%rax
mov    %rax,-0x430(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x428(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x430(%rbp),%rdi
mov    -0x428(%rbp),%rsi
mov    %eax,%edx
sub    $0x4,%edx
call   1030 <strncpy@plt>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x4,%eax
cltq
movb   $0x0,-0x410(%rbp,%rax,1)
lea    -0x410(%rbp),%rdi
call   1060 <GetFileExt@plt>
mov    %rax,-0x418(%rbp)
lea    -0x410(%rbp),%rax
mov    %rax,-0x420(%rbp)
lea    -0x410(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x420(%rbp),%rdi
sub    $0x5,%eax
cltq
add    %rax,%rdi
lea    0xdf6(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     1258 <IsImageFile+0x118>
mov    -0x418(%rbp),%rsi
lea    0xdd9(%rip),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     1258 <IsImageFile+0x118>
mov    -0x418(%rbp),%rsi
lea    0xdc2(%rip),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1264 <IsImageFile+0x124>
movl   $0x0,-0x4(%rbp)
jmp    1277 <IsImageFile+0x137>
movl   $0x1,-0x4(%rbp)
jmp    1277 <IsImageFile+0x137>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<IsImageFile>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    %rdi,%rbx
call   1060 <GetFileExt@plt>
lea    0xea5(%rip),%rdi
mov    %rax,%rsi
call   1050 <strcmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
jne    11f2 <IsImageFile+0xb2>
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    -0x4(%rax),%edx
mov    %rsp,%r15
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <strncpy@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x4(%rax,%r15,1)
mov    %r15,%rdi
call   1060 <GetFileExt@plt>
mov    %rax,%r14
mov    %r15,%rdi
call   1040 <strlen@plt>
cltq
lea    (%rax,%r15,1),%rdi
add    $0xfffffffffffffffb,%rdi
lea    0xe49(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11f2 <IsImageFile+0xb2>
lea    0xe38(%rip),%rdi
mov    %r14,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11f2 <IsImageFile+0xb2>
lea    0xe2a(%rip),%rdi
mov    %r14,%rsi
call   1050 <strcmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
setne  %bpl
mov    %ebp,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c".png\00"
@.str.1 = [6 x i8] c"depth\00"
@.str.2 = [5 x i8] c"mask\00"
define i32 @IsImageFile(i8* %0) {
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%4 = tail call i8* @GetFileExt(i8* %0)
%5 = tail call i64 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 1), i8* %4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %29
7: ; preds = %1
%8 = tail call i32 @strlen(i8* %0)
%9 = add nsw i32 %8, -4
%10 = call i32 @strncpy(i8* %3, i8* %0, i32 %9)
%11 = call i32 @strlen(i8* %0)
%12 = add nsw i32 %11, -4
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %13
store i8 0, i8* %14
%15 = call i8* @GetFileExt(i8* %3)
%16 = call i32 @strlen(i8* %3)
%17 = add nsw i32 %16, -5
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %18
%20 = call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %29, label %22
22: ; preds = %7
%23 = call i64 @strcmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%24 = icmp eq i64 %23, 0
br i1 %24, label %29, label %25
25: ; preds = %22
%26 = call i64 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %15)
%27 = icmp ne i64 %26, 0
%28 = zext i1 %27 to i32
br label %29
29: ; preds = %25, %1, %7, %22
%30 = phi i32 [ 0, %22 ], [ 0, %7 ], [ 0, %1 ], [ %28, %25 ]
ret i32 %30
}