#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 *);
char *strrchr(char *, char);
int checkextension(char *filename) {
  char *extension = 0;
  if ((extension = strrchr(filename, '.')) != 0)
    ++extension;
  if (extension) {
    if ((strcasecmp(extension, "jpg")) == 0 ||
        (strcasecmp(extension, "png")) == 0 ||
        (strcasecmp(extension, "gif")) == 0)
      return (0);
  }
  return (1);
}


x86 assembly (clang, -O0):
<checkextension>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2e,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     115c <checkextension+0x3c>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11c6 <checkextension+0xa6>
mov    -0x18(%rbp),%rdi
lea    0xe8e(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
je     11b5 <checkextension+0x95>
mov    -0x18(%rbp),%rdi
lea    0xe78(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
je     11b5 <checkextension+0x95>
mov    -0x18(%rbp),%rdi
lea    0xe62(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    11c1 <checkextension+0xa1>
movl   $0x0,-0x4(%rbp)
jmp    11cd <checkextension+0xad>
jmp    11c6 <checkextension+0xa6>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkextension>:
push   %rbp
push   %rbx
push   %rax
mov    $0x2e,%esi
call   1040 <strrchr@plt>
lea    0x1(%rax),%rbx
test   %rax,%rax
cmove  %rax,%rbx
je     1178 <checkextension+0x58>
lea    0xebf(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     117d <checkextension+0x5d>
lea    0xead(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     117d <checkextension+0x5d>
lea    0xe9d(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     117d <checkextension+0x5d>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"jpg\00"
@.str.1 = [4 x i8] c"png\00"
@.str.2 = [4 x i8] c"gif\00"
define i32 @checkextension(i8* %0) {
%2 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 46)
%3 = icmp eq i8* %2, null
%4 = getelementptr inbounds i8, i8* %2, i64 1
%5 = select i1 %3, i8* null, i8* %4
br i1 %3, label %15, label %6
6: ; preds = %1
%7 = tail call i64 @strcasecmp(i8* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %16, label %9
9: ; preds = %6
%10 = tail call i64 @strcasecmp(i8* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %9
%13 = tail call i64 @strcasecmp(i8* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %16, label %15
15: ; preds = %12, %1
br label %16
16: ; preds = %6, %9, %12, %15
%17 = phi i32 [ 1, %15 ], [ 0, %12 ], [ 0, %9 ], [ 0, %6 ]
ret i32 %17
}