#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 */
unsigned char strlen(char *);
unsigned char isPPMImage(char *file) {
  unsigned char size = strlen(file);
  if (file[size - 4] == '.' && file[size - 3] == 'p' && file[size - 2] == 'p' &&
      file[size - 1] == 'm')
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<isPPMImage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %al,-0x11(%rbp)
mov    -0x10(%rbp),%rax
movzbl -0x11(%rbp),%ecx
sub    $0x4,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jne    119d <isPPMImage+0x8d>
mov    -0x10(%rbp),%rax
movzbl -0x11(%rbp),%ecx
sub    $0x3,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x70,%eax
jne    119d <isPPMImage+0x8d>
mov    -0x10(%rbp),%rax
movzbl -0x11(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x70,%eax
jne    119d <isPPMImage+0x8d>
mov    -0x10(%rbp),%rax
movzbl -0x11(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x6d,%eax
jne    119d <isPPMImage+0x8d>
movb   $0x1,-0x1(%rbp)
jmp    11a1 <isPPMImage+0x91>
movb   $0x0,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isPPMImage>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
movzbl %al,%ecx
cmpb   $0x2e,-0x4(%rcx,%rbx,1)
jne    113a <isPPMImage+0x2a>
cmpb   $0x70,-0x3(%rcx,%rbx,1)
jne    113a <isPPMImage+0x2a>
cmpb   $0x70,-0x2(%rcx,%rbx,1)
jne    113a <isPPMImage+0x2a>
mov    $0x1,%al
cmpb   $0x6d,-0x1(%rcx,%rbx,1)
je     113c <isPPMImage+0x2c>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define zeroext i8 @isPPMImage(i8* %0) {
%2 = alloca i8
%3 = alloca i8*
%4 = alloca i8
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call zeroext i8 @strlen(i8* %5)
store i8 %6, i8* %4
%7 = load i8*, i8** %3
%8 = load i8, i8* %4
%9 = zext i8 %8 to i32
%10 = sub nsw i32 %9, 4
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %7, i64 %11
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 46
br i1 %15, label %16, label %47
16: ; preds = %1
%17 = load i8*, i8** %3
%18 = load i8, i8* %4
%19 = zext i8 %18 to i32
%20 = sub nsw i32 %19, 3
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %17, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 112
br i1 %25, label %26, label %47
26: ; preds = %16
%27 = load i8*, i8** %3
%28 = load i8, i8* %4
%29 = zext i8 %28 to i32
%30 = sub nsw i32 %29, 2
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %27, i64 %31
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 112
br i1 %35, label %36, label %47
36: ; preds = %26
%37 = load i8*, i8** %3
%38 = load i8, i8* %4
%39 = zext i8 %38 to i32
%40 = sub nsw i32 %39, 1
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %37, i64 %41
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 109
br i1 %45, label %46, label %47
46: ; preds = %36
store i8 1, i8* %2
br label %48
47: ; preds = %36, %26, %16, %1
store i8 0, i8* %2
br label %48
48: ; preds = %47, %46
%49 = load i8, i8* %2
ret i8 %49
}

LLVM IR (-O2):
define zeroext i8 @isPPMImage(i8* %0) {
%2 = tail call zeroext i8 @strlen(i8* %0)
%3 = zext i8 %2 to i32
%4 = add nsw i32 %3, -4
%5 = sext i32 %4 to i64
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 46
br i1 %8, label %9, label %27
9: ; preds = %1
%10 = add nsw i32 %3, -3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 112
br i1 %14, label %15, label %27
15: ; preds = %9
%16 = add nsw i32 %3, -2
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %0, i64 %17
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 112
br i1 %20, label %21, label %27
21: ; preds = %15
%22 = add nsw i32 %3, -1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %0, i64 %23
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 109
br i1 %26, label %28, label %27
27: ; preds = %21, %15, %9, %1
br label %28
28: ; preds = %21, %27
%29 = phi i8 [ 0, %27 ], [ 1, %21 ]
ret i8 %29
}