#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 strlen(char *);
int isAlphabetic(char *str) {
  if (strlen(str) < 2)
    return 1;
  int i;
  for (i = 1; i < strlen(str); i++) {
    if (str[i] < str[i - 1])
      return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<isAlphabetic>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x2,%eax
jge    113a <isAlphabetic+0x2a>
movl   $0x1,-0x4(%rbp)
jmp    11a8 <isAlphabetic+0x98>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jge    11a1 <isAlphabetic+0x91>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x10(%rbp),%rcx
mov    -0x14(%rbp),%edx
sub    $0x1,%edx
movslq %edx,%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
jge    118e <isAlphabetic+0x7e>
movl   $0x0,-0x4(%rbp)
jmp    11a8 <isAlphabetic+0x98>
jmp    1193 <isAlphabetic+0x83>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1141 <isAlphabetic+0x31>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isAlphabetic>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    $0x1,%r14d
cmp    $0x2,%eax
jl     1162 <isAlphabetic+0x52>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    $0x2,%eax
jl     1162 <isAlphabetic+0x52>
mov    $0x1,%ebp
nopl   0x0(%rax)
movzbl (%rbx,%rbp,1),%eax
cmp    -0x1(%rbx,%rbp,1),%al
jl     115f <isAlphabetic+0x4f>
add    $0x1,%rbp
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbp
jl     1140 <isAlphabetic+0x30>
jmp    1162 <isAlphabetic+0x52>
xor    %r14d,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @isAlphabetic(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i32 @strlen(i8* %5)
%7 = icmp slt i32 %6, 2
br i1 %7, label %8, label %9
8: ; preds = %1
store i32 1, i32* %2
br label %36
9: ; preds = %1
store i32 1, i32* %4
br label %10
10: ; preds = %32, %9
%11 = load i32, i32* %4
%12 = load i8*, i8** %3
%13 = call i32 @strlen(i8* %12)
%14 = icmp slt i32 %11, %13
br i1 %14, label %15, label %35
15: ; preds = %10
%16 = load i8*, i8** %3
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = load i8*, i8** %3
%23 = load i32, i32* %4
%24 = sub nsw i32 %23, 1
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %22, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp slt i32 %21, %28
br i1 %29, label %30, label %31
30: ; preds = %15
store i32 0, i32* %2
br label %36
31: ; preds = %15
br label %32
32: ; preds = %31
%33 = load i32, i32* %4
%34 = add nsw i32 %33, 1
store i32 %34, i32* %4
br label %10
35: ; preds = %10
store i32 1, i32* %2
br label %36
36: ; preds = %35, %30, %8
%37 = load i32, i32* %2
ret i32 %37
}

LLVM IR (-O2):
define i32 @isAlphabetic(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp slt i32 %2, 2
br i1 %3, label %20, label %4
4: ; preds = %1
%5 = tail call i32 @strlen(i8* %0)
%6 = icmp sgt i32 %5, 1
br i1 %6, label %11, label %20
7: ; preds = %11
%8 = tail call i32 @strlen(i8* %0)
%9 = sext i32 %8 to i64
%10 = icmp slt i64 %19, %9
br i1 %10, label %11, label %20
11: ; preds = %4, %7
%12 = phi i64 [ %19, %7 ], [ 1, %4 ]
%13 = getelementptr inbounds i8, i8* %0, i64 %12
%14 = load i8, i8* %13
%15 = add nsw i64 %12, -1
%16 = getelementptr inbounds i8, i8* %0, i64 %15
%17 = load i8, i8* %16
%18 = icmp slt i8 %14, %17
%19 = add nuw nsw i64 %12, 1
br i1 %18, label %20, label %7
20: ; preds = %7, %11, %4, %1
%21 = phi i32 [ 1, %1 ], [ 1, %4 ], [ 1, %7 ], [ 0, %11 ]
ret i32 %21
}