#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 */
typedef int /*<<< orphan*/ exit_words;

/* Variables and functions */
scalar_t__ strcmp(char const *, char const *);
scalar_t__ strlen(char const *);
int is_exit(const char *p) {
  const char *exit_words[] = {
      "",
      "exit",
      "quit",
      "bye",
  };
  int len = (int)(sizeof(exit_words) / sizeof(char *));
  int i;
  if (strlen(p) == 0) {
    return (1);
  }
  for (i = 0; i < len; i++) {
    if (strcmp(p, exit_words[i]) == 0) {
      return (1);
    }
  }
  return (0);
}


x86 assembly (clang, -O0):
<is_exit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    0x2ccd(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2cca(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0x2cc7(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2cc4(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x4,-0x34(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%rax
jne    117e <is_exit+0x5e>
movl   $0x1,-0x4(%rbp)
jmp    11d3 <is_exit+0xb3>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    11cc <is_exit+0xac>
mov    -0x10(%rbp),%rdi
movslq -0x38(%rbp),%rax
mov    -0x30(%rbp,%rax,8),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11b9 <is_exit+0x99>
movl   $0x1,-0x4(%rbp)
jmp    11d3 <is_exit+0xb3>
jmp    11be <is_exit+0x9e>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1185 <is_exit+0x65>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_exit>:
push   %rbp
push   %rbx
push   %rax
mov    $0x1,%ebp
cmpb   $0x0,(%rdi)
je     1171 <is_exit+0x61>
mov    %rdi,%rbx
lea    0xee6(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1171 <is_exit+0x61>
lea    0xec8(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1171 <is_exit+0x61>
lea    0xeb9(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1171 <is_exit+0x61>
lea    0xeaa(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
sete   %bpl
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [5 x i8] c"exit\00"
@.str.2 = [5 x i8] c"quit\00"
@.str.3 = [4 x i8] c"bye\00"
@__const.is_exit.exit_words = [4 x i8*] [i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i32 0, i32 0)]
define i32 @is_exit(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [4 x i8*]
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
%7 = bitcast [4 x i8*]* %4 to i8*
store i32 4, i32* %5
%8 = load i8*, i8** %3
%9 = call i64 @strlen(i8* %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %1
store i32 1, i32* %2
br label %31
12: ; preds = %1
store i32 0, i32* %6
br label %13
13: ; preds = %27, %12
%14 = load i32, i32* %6
%15 = load i32, i32* %5
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %30
17: ; preds = %13
%18 = load i8*, i8** %3
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [4 x i8*], [4 x i8*]* %4, i64 0, i64 %20
%22 = load i8*, i8** %21
%23 = call i64 @strcmp(i8* %18, i8* %22)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %17
store i32 1, i32* %2
br label %31
26: ; preds = %17
br label %27
27: ; preds = %26
%28 = load i32, i32* %6
%29 = add nsw i32 %28, 1
store i32 %29, i32* %6
br label %13
30: ; preds = %13
store i32 0, i32* %2
br label %31
31: ; preds = %30, %25, %11
%32 = load i32, i32* %2
ret i32 %32
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [5 x i8] c"exit\00"
@.str.2 = [5 x i8] c"quit\00"
@.str.3 = [4 x i8] c"bye\00"
define i32 @is_exit(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %17, label %4
4: ; preds = %1
%5 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %17, label %7
7: ; preds = %4
%8 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %17, label %10
10: ; preds = %7
%11 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %10
%14 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
%16 = zext i1 %15 to i32
br label %17
17: ; preds = %13, %4, %7, %10, %1
%18 = phi i32 [ 1, %1 ], [ 1, %4 ], [ 1, %7 ], [ 1, %10 ], [ %16, %13 ]
ret i32 %18
}