#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 *);
int strlen(char *);
int IsPicture(char *filename) {
  int i, size;
  char *PicExt[] = {".jpg", ".jpeg", ".gif", ""};
  for (i = 0; PicExt[i][0] != '\0'; i++) {
    size = strlen(filename) - strlen(PicExt[i]);
    if (size < 0)
      continue;
    if (strcasecmp(filename + size, PicExt[i]) == 0) {
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<IsPicture>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    0x2ccd(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0x2cca(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0x2cc7(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2cc4(%rip),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x14(%rbp)
movslq -0x14(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11e9 <IsPicture+0xc9>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x44(%rbp)
movslq -0x14(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x44(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    11a7 <IsPicture+0x87>
jmp    11db <IsPicture+0xbb>
mov    -0x10(%rbp),%rdi
movslq -0x18(%rbp),%rax
add    %rax,%rdi
movslq -0x14(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    11d6 <IsPicture+0xb6>
movl   $0x1,-0x4(%rbp)
jmp    11f0 <IsPicture+0xd0>
jmp    11db <IsPicture+0xbb>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115f <IsPicture+0x3f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<IsPicture>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1040 <strlen@plt>
mov    %eax,%ebp
lea    0xecc(%rip),%rdi
call   1040 <strlen@plt>
sub    %eax,%ebp
js     1153 <IsPicture+0x33>
mov    %ebp,%edi
add    %rbx,%rdi
lea    0xeb7(%rip),%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11ba <IsPicture+0x9a>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
lea    0xea1(%rip),%rdi
call   1040 <strlen@plt>
sub    %eax,%ebp
js     1183 <IsPicture+0x63>
mov    %ebp,%edi
add    %rbx,%rdi
lea    0xe8c(%rip),%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11ba <IsPicture+0x9a>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
lea    0xe77(%rip),%rdi
call   1040 <strlen@plt>
sub    %eax,%ebp
js     11b6 <IsPicture+0x96>
mov    %ebp,%eax
add    %rax,%rbx
lea    0xe62(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11ba <IsPicture+0x9a>
xor    %eax,%eax
jmp    11bf <IsPicture+0x9f>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c".jpg\00"
@.str.1 = [6 x i8] c".jpeg\00"
@.str.2 = [5 x i8] c".gif\00"
@.str.3 = [1 x i8] zeroinitializer
@__const.IsPicture.PicExt = [4 x i8*] [i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 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 ([1 x i8], [1 x i8]* @.str.3, i32 0, i32 0)]
define i32 @IsPicture(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca [4 x i8*]
store i8* %0, i8** %3
%7 = bitcast [4 x i8*]* %6 to i8*
store i32 0, i32* %4
br label %8
8: ; preds = %42, %1
%9 = load i32, i32* %4
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [4 x i8*], [4 x i8*]* %6, i64 0, i64 %10
%12 = load i8*, i8** %11
%13 = getelementptr inbounds i8, i8* %12, i64 0
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %45
17: ; preds = %8
%18 = load i8*, i8** %3
%19 = call i32 @strlen(i8* %18)
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [4 x i8*], [4 x i8*]* %6, i64 0, i64 %21
%23 = load i8*, i8** %22
%24 = call i32 @strlen(i8* %23)
%25 = sub nsw i32 %19, %24
store i32 %25, i32* %5
%26 = load i32, i32* %5
%27 = icmp slt i32 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %17
br label %42
29: ; preds = %17
%30 = load i8*, i8** %3
%31 = load i32, i32* %5
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
%34 = load i32, i32* %4
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [4 x i8*], [4 x i8*]* %6, i64 0, i64 %35
%37 = load i8*, i8** %36
%38 = call i64 @strcasecmp(i8* %33, i8* %37)
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %41
40: ; preds = %29
store i32 1, i32* %2
br label %46
41: ; preds = %29
br label %42
42: ; preds = %41, %28
%43 = load i32, i32* %4
%44 = add nsw i32 %43, 1
store i32 %44, i32* %4
br label %8
45: ; preds = %8
store i32 0, i32* %2
br label %46
46: ; preds = %45, %40
%47 = load i32, i32* %2
ret i32 %47
}

LLVM IR (-O2):
@.str = [5 x i8] c".jpg\00"
@.str.1 = [6 x i8] c".jpeg\00"
@.str.2 = [5 x i8] c".gif\00"
define i32 @IsPicture(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = tail call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%4 = sub nsw i32 %2, %3
%5 = icmp slt i32 %4, 0
br i1 %5, label %11, label %6
6: ; preds = %1
%7 = zext i32 %4 to i64
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = tail call i64 @strcasecmp(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %32, label %11
11: ; preds = %6, %1
%12 = tail call i32 @strlen(i8* %0)
%13 = tail call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%14 = sub nsw i32 %12, %13
%15 = icmp slt i32 %14, 0
br i1 %15, label %21, label %16
16: ; preds = %11
%17 = zext i32 %14 to i64
%18 = getelementptr inbounds i8, i8* %0, i64 %17
%19 = tail call i64 @strcasecmp(i8* %18, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %32, label %21
21: ; preds = %16, %11
%22 = tail call i32 @strlen(i8* %0)
%23 = tail call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%24 = sub nsw i32 %22, %23
%25 = icmp slt i32 %24, 0
br i1 %25, label %31, label %26
26: ; preds = %21
%27 = zext i32 %24 to i64
%28 = getelementptr inbounds i8, i8* %0, i64 %27
%29 = tail call i64 @strcasecmp(i8* %28, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %32, label %31
31: ; preds = %26, %21
br label %32
32: ; preds = %31, %26, %16, %6
%33 = phi i32 [ 1, %6 ], [ 1, %16 ], [ 1, %26 ], [ 0, %31 ]
ret i32 %33
}