#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 */
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ strncmp(char *, char *, int /*<<< orphan*/);
int is_image(char *tok) {
  if (!strncmp(&tok[0], "image/jpeg", strlen("image/jpeg"))) {
    return 1;
  }
  if (!strncmp(&tok[0], "image/jpg", strlen("image/jpg"))) {
    return 1;
  }
  if (!strncmp(&tok[1], "image/jpeg", strlen("image/jpeg"))) {
    return 1;
  }
  if (!strncmp(&tok[1], "image/jpg", strlen("image/jpg"))) {
    return 1;
  }
  if (!strncmp(&tok[0], "image/png", strlen("image/png"))) {
    return 1;
  }
  if (!strncmp(&tok[1], "image/png", strlen("image/png"))) {
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<is_image>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    0xec5(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x18(%rbp),%rdi
mov    %eax,%edx
lea    0xeb3(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1167 <is_image+0x47>
movl   $0x1,-0x4(%rbp)
jmp    12a1 <is_image+0x181>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    0xe95(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%edx
lea    0xe83(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    11a2 <is_image+0x82>
movl   $0x1,-0x4(%rbp)
jmp    12a1 <is_image+0x181>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
lea    0xe4b(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%edx
lea    0xe39(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    11e1 <is_image+0xc1>
movl   $0x1,-0x4(%rbp)
jmp    12a1 <is_image+0x181>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
lea    0xe17(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    %eax,%edx
lea    0xe05(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1220 <is_image+0x100>
movl   $0x1,-0x4(%rbp)
jmp    12a1 <is_image+0x181>
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    0xde6(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x38(%rbp),%rdi
mov    %eax,%edx
lea    0xdd4(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    125b <is_image+0x13b>
movl   $0x1,-0x4(%rbp)
jmp    12a1 <is_image+0x181>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
lea    0xda7(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x40(%rbp),%rdi
mov    %eax,%edx
lea    0xd95(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    129a <is_image+0x17a>
movl   $0x1,-0x4(%rbp)
jmp    12a1 <is_image+0x181>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_image>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xecf(%rip),%rbp
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
mov    $0x1,%r15d
test   %eax,%eax
je     1201 <is_image+0xe1>
lea    0xeb0(%rip),%rbp
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1201 <is_image+0xe1>
lea    0x1(%rbx),%r14
lea    0xe7d(%rip),%rbp
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1201 <is_image+0xe1>
lea    0xe68(%rip),%rbp
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1201 <is_image+0xe1>
lea    0xe52(%rip),%rbp
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1201 <is_image+0xe1>
lea    0xe32(%rip),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
xor    %r15d,%r15d
test   %eax,%eax
sete   %r15b
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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