#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__ get_extension(char *, char *);
int /*<<< orphan*/ strcmp(char *, char *);
int is_image_file(char *filename) {
  char extension[10];
  if (get_extension(extension, filename) != 0)
    return 0;
  if (!strcmp(extension, "jpg") || !strcmp(extension, "jpeg") ||
      !strcmp(extension, "png") || !strcmp(extension, "gif")) {
    return 1;
  } else {
    return 0;
  }
  return 0;
}


x86 assembly (clang, -O0):
<is_image_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x1a(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <get_extension@plt>
cmp    $0x0,%rax
je     114f <is_image_file+0x2f>
movl   $0x0,-0x4(%rbp)
jmp    11c6 <is_image_file+0xa6>
lea    -0x1a(%rbp),%rdi
lea    0xea6(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
je     11b3 <is_image_file+0x93>
lea    -0x1a(%rbp),%rdi
lea    0xe91(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
je     11b3 <is_image_file+0x93>
lea    -0x1a(%rbp),%rdi
lea    0xe7d(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
je     11b3 <is_image_file+0x93>
lea    -0x1a(%rbp),%rdi
lea    0xe68(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11bf <is_image_file+0x9f>
movl   $0x1,-0x4(%rbp)
jmp    11c6 <is_image_file+0xa6>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_image_file>:
sub    $0x18,%rsp
mov    %rdi,%rsi
lea    0xe(%rsp),%rdi
call   1030 <get_extension@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
je     1130 <is_image_file+0x20>
add    $0x18,%rsp
ret
mov    $0x1,%eax
cmpl   $0x67706a,0xe(%rsp)
je     112b <is_image_file+0x1b>
mov    $0x6765706a,%ecx
xor    0xe(%rsp),%ecx
movzbl 0x12(%rsp),%edx
or     %ecx,%edx
je     112b <is_image_file+0x1b>
cmpl   $0x676e70,0xe(%rsp)
je     112b <is_image_file+0x1b>
xor    %eax,%eax
cmpl   $0x666967,0xe(%rsp)
sete   %al
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"jpg\00"
@.str.1 = [5 x i8] c"jpeg\00"
@.str.2 = [4 x i8] c"png\00"
@.str.3 = [4 x i8] c"gif\00"
define i32 @is_image_file(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [10 x i8]
store i8* %0, i8** %3
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%6 = load i8*, i8** %3
%7 = call i64 @get_extension(i8* %5, i8* %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %1
store i32 0, i32* %2
br label %28
10: ; preds = %1
%11 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%12 = call i32 @strcmp(i8* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %26
14: ; preds = %10
%15 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%16 = call i32 @strcmp(i8* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %26
18: ; preds = %14
%19 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%20 = call i32 @strcmp(i8* %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %18
%23 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%24 = call i32 @strcmp(i8* %23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%25 = icmp ne i32 %24, 0
br i1 %25, label %27, label %26
26: ; preds = %22, %18, %14, %10
store i32 1, i32* %2
br label %28
27: ; preds = %22
store i32 0, i32* %2
br label %28
28: ; preds = %27, %26, %9
%29 = load i32, i32* %2
ret i32 %29
}

LLVM IR (-O2):
@.str = [4 x i8] c"jpg\00"
@.str.1 = [5 x i8] c"jpeg\00"
@.str.2 = [4 x i8] c"png\00"
@.str.3 = [4 x i8] c"gif\00"
define i32 @is_image_file(i8* %0) {
%2 = alloca [10 x i8]
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%4 = call i64 @get_extension(i8* %3, i8* %0)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %19
6: ; preds = %1
%7 = call i32 @bcmp(i8* dereferenceable(4) %3, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 4)
%8 = icmp eq i32 %7, 0
br i1 %8, label %19, label %9
9: ; preds = %6
%10 = call i32 @bcmp(i8* dereferenceable(5) %3, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 5)
%11 = icmp eq i32 %10, 0
br i1 %11, label %19, label %12
12: ; preds = %9
%13 = call i32 @bcmp(i8* dereferenceable(4) %3, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64 4)
%14 = icmp eq i32 %13, 0
br i1 %14, label %19, label %15
15: ; preds = %12
%16 = call i32 @bcmp(i8* dereferenceable(4) %3, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64 4)
%17 = icmp eq i32 %16, 0
%18 = zext i1 %17 to i32
br label %19
19: ; preds = %15, %6, %9, %12, %1
%20 = phi i32 [ 0, %1 ], [ 1, %12 ], [ 1, %9 ], [ 1, %6 ], [ %18, %15 ]
ret i32 %20
}