#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*/ strcmp(char *, char *);
int strlen(char *);
scalar_t__ toupper(int);
char WasHelpCalled(char *input) {
  char ans = 0;
  if (strlen(input) == 1 && (char)toupper((int)input[0]) == 'H')
    ans = 1;
  else if (!strcmp(input, "help"))
    ans = 1;
  else if (!strcmp(input, "HELP"))
    ans = 1;
  return ans;
}


x86 assembly (clang, -O0):
<WasHelpCalled>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movb   $0x0,-0x9(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x1,%eax
jne    1173 <WasHelpCalled+0x43>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
movsbl %al,%eax
cmp    $0x48,%eax
jne    1173 <WasHelpCalled+0x43>
movb   $0x1,-0x9(%rbp)
jmp    11bc <WasHelpCalled+0x8c>
mov    -0x8(%rbp),%rdi
lea    0xe82(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1195 <WasHelpCalled+0x65>
movb   $0x1,-0x9(%rbp)
jmp    11b7 <WasHelpCalled+0x87>
mov    -0x8(%rbp),%rdi
lea    0xe65(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11b2 <WasHelpCalled+0x82>
movb   $0x1,-0x9(%rbp)
jmp    11b7 <WasHelpCalled+0x87>
jmp    11bc <WasHelpCalled+0x8c>
movsbl -0x9(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<WasHelpCalled>:
push   %rbx
mov    %rdi,%rbx
call   1040 <strlen@plt>
cmp    $0x1,%eax
jne    1150 <WasHelpCalled+0x20>
movsbl (%rbx),%edi
call   1030 <toupper@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x48,%cl
je     1177 <WasHelpCalled+0x47>
lea    0xea9(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1179 <WasHelpCalled+0x49>
lea    0xe9b(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
sete   %al
pop    %rbx
ret
mov    $0x1,%al
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"help\00"
@.str.1 = [5 x i8] c"HELP\00"
define signext i8 @WasHelpCalled(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp eq i32 %2, 1
br i1 %3, label %4, label %10
4: ; preds = %1
%5 = load i8, i8* %0
%6 = sext i8 %5 to i32
%7 = tail call i64 @toupper(i32 %6)
%8 = and i64 %7, 255
%9 = icmp eq i64 %8, 72
br i1 %9, label %17, label %10
10: ; preds = %4, %1
%11 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i32 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %10
%14 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32 %14, 0
%16 = zext i1 %15 to i8
br label %17
17: ; preds = %13, %10, %4
%18 = phi i8 [ 1, %4 ], [ 1, %10 ], [ %16, %13 ]
ret i8 %18
}