#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*/ memcpy(char *, char *, int);
int /*<<< orphan*/ strcmp(char *, char *);
int strlen(char *);
char tolower(char);
int isAmPmString(char *format) {
  int i = 0, len = strlen(format);
  char buffer[6];
  buffer[5] = 0;
  if (len > 4) {
    memcpy(buffer, &format[i], 5);
    for (i = 0; i < 5; i++)
      buffer[i] = tolower(buffer[i]);
    return !strcmp(buffer, "am/pm");
  }
  return 0;
}


x86 assembly (clang, -O0):
<isAmPmString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x18(%rbp)
movb   $0x0,-0x19(%rbp)
cmpl   $0x4,-0x18(%rbp)
jle    11e2 <isAmPmString+0xa2>
lea    -0x1e(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movslq -0x14(%rbp),%rax
add    %rax,%rsi
mov    $0x5,%edx
call   1050 <memcpy@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x5,-0x14(%rbp)
jge    11bd <isAmPmString+0x7d>
movslq -0x14(%rbp),%rax
movsbl -0x1e(%rbp,%rax,1),%edi
call   1060 <tolower@plt>
mov    %al,%cl
movslq -0x14(%rbp),%rax
mov    %cl,-0x1e(%rbp,%rax,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    118d <isAmPmString+0x4d>
lea    -0x1e(%rbp),%rdi
lea    0xe38(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    11e9 <isAmPmString+0xa9>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isAmPmString>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    %eax,%ecx
movb   $0x0,0xf(%rsp)
xor    %eax,%eax
cmp    $0x5,%ecx
jl     11bb <isAmPmString+0x8b>
lea    0xa(%rsp),%rdi
mov    %rbx,%rsi
mov    $0x5,%edx
call   1040 <memcpy@plt>
movsbl 0xa(%rsp),%edi
call   1050 <tolower@plt>
mov    %al,0xa(%rsp)
movsbl 0xb(%rsp),%edi
call   1050 <tolower@plt>
mov    %al,0xb(%rsp)
movsbl 0xc(%rsp),%edi
call   1050 <tolower@plt>
mov    %al,0xc(%rsp)
movsbl 0xd(%rsp),%edi
call   1050 <tolower@plt>
mov    %al,0xd(%rsp)
movsbl 0xe(%rsp),%edi
call   1050 <tolower@plt>
mov    %al,0xe(%rsp)
mov    $0x702f6d61,%ecx
xor    0xa(%rsp),%ecx
movzwl 0xe(%rsp),%edx
xor    $0x6d,%edx
xor    %eax,%eax
or     %ecx,%edx
sete   %al
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"am/pm\00"
define i32 @isAmPmString(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca [6 x i8]
store i8* %0, i8** %3
store i32 0, i32* %4
%7 = load i8*, i8** %3
%8 = call i32 @strlen(i8* %7)
store i32 %8, i32* %5
%9 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 5
store i8 0, i8* %9
%10 = load i32, i32* %5
%11 = icmp sgt i32 %10, 4
br i1 %11, label %12, label %40
12: ; preds = %1
%13 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 0
%14 = load i8*, i8** %3
%15 = load i32, i32* %4
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = call i32 @memcpy(i8* %13, i8* %17, i32 5)
store i32 0, i32* %4
br label %19
19: ; preds = %31, %12
%20 = load i32, i32* %4
%21 = icmp slt i32 %20, 5
br i1 %21, label %22, label %34
22: ; preds = %19
%23 = load i32, i32* %4
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = call signext i8 @tolower(i8 signext %26)
%28 = load i32, i32* %4
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 %29
store i8 %27, i8* %30
br label %31
31: ; preds = %22
%32 = load i32, i32* %4
%33 = add nsw i32 %32, 1
store i32 %33, i32* %4
br label %19
34: ; preds = %19
%35 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 0
%36 = call i32 @strcmp(i8* %35, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%37 = icmp ne i32 %36, 0
%38 = xor i1 %37, true
%39 = zext i1 %38 to i32
store i32 %39, i32* %2
br label %41
40: ; preds = %1
store i32 0, i32* %2
br label %41
41: ; preds = %40, %34
%42 = load i32, i32* %2
ret i32 %42
}

LLVM IR (-O2):
@.str = [6 x i8] c"am/pm\00"
define i32 @isAmPmString(i8* %0) {
%2 = alloca [6 x i8]
%3 = tail call i32 @strlen(i8* %0)
%4 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 5
store i8 0, i8* %5
%6 = icmp sgt i32 %3, 4
br i1 %6, label %7, label %26
7: ; preds = %1
%8 = call i32 @memcpy(i8* %4, i8* %0, i32 5)
%9 = load i8, i8* %4
%10 = call signext i8 @tolower(i8 signext %9)
store i8 %10, i8* %4
%11 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 1
%12 = load i8, i8* %11
%13 = call signext i8 @tolower(i8 signext %12)
store i8 %13, i8* %11
%14 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 2
%15 = load i8, i8* %14
%16 = call signext i8 @tolower(i8 signext %15)
store i8 %16, i8* %14
%17 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 3
%18 = load i8, i8* %17
%19 = call signext i8 @tolower(i8 signext %18)
store i8 %19, i8* %17
%20 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 4
%21 = load i8, i8* %20
%22 = call signext i8 @tolower(i8 signext %21)
store i8 %22, i8* %20
%23 = call i32 @bcmp(i8* dereferenceable(6) %4, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 6)
%24 = icmp eq i32 %23, 0
%25 = zext i1 %24 to i32
br label %26
26: ; preds = %1, %7
%27 = phi i32 [ %25, %7 ], [ 0, %1 ]
ret i32 %27
}