#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*/ sprintf(char *, char *, char const *);
scalar_t__ strlen(char const *);
scalar_t__ strncmp(char *, char *, scalar_t__);
char toupper(char);
int valid_description(char *description) {
  int i;
  const int no_of_articles = 4;
  const char *article[] = {"A", "An", "This", "The"};
  char str[512];
  if (strlen(description) == 0)
    return -1;
  description[0] = toupper(description[0]);
  for (i = 0; i < no_of_articles; i++) {
    if (strlen(description) > strlen(article[i]) + 1) {
      sprintf(str, "%s ", article[i]);
      if (strncmp(description, str, strlen(str)) == 0)
        return -2;
    }
  }
  if ((description[0] == ' ') || (description[0] == '\t')) {
    return -3;
  }
  return 1;
}


x86 assembly (clang, -O0):
<valid_description>:
push   %rbp
mov    %rsp,%rbp
sub    $0x260,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x4,-0x18(%rbp)
mov    0x2ca3(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0x2ca0(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0x2c9d(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2c9a(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x0,%rax
jne    11a1 <valid_description+0x61>
movl   $0xffffffff,-0x4(%rbp)
jmp    12b3 <valid_description+0x173>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <toupper@plt>
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
movl   $0x0,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jge    1280 <valid_description+0x140>
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x248(%rbp)
movslq -0x14(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rdi
call   1050 <strlen@plt>
mov    %rax,%rcx
mov    -0x248(%rbp),%rax
add    $0x1,%rcx
cmp    %rcx,%rax
jle    126d <valid_description+0x12d>
lea    -0x240(%rbp),%rdi
movslq -0x14(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rdx
lea    0xdfc(%rip),%rsi
call   1060 <sprintf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x258(%rbp)
lea    -0x240(%rbp),%rax
mov    %rax,-0x250(%rbp)
lea    -0x240(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x258(%rbp),%rdi
mov    -0x250(%rbp),%rsi
mov    %rax,%rdx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1268 <valid_description+0x128>
movl   $0xfffffffe,-0x4(%rbp)
jmp    12b3 <valid_description+0x173>
jmp    126d <valid_description+0x12d>
jmp    1272 <valid_description+0x132>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11bc <valid_description+0x7c>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
je     12a0 <valid_description+0x160>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
jne    12ac <valid_description+0x16c>
movl   $0xfffffffd,-0x4(%rbp)
jmp    12b3 <valid_description+0x173>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x260,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<valid_description>:
push   %r14
push   %rbx
sub    $0x208,%rsp
mov    (%rdi),%al
test   %al,%al
je     128d <valid_description+0x14d>
mov    %rdi,%rbx
movsbl %al,%edi
call   1040 <toupper@plt>
mov    %al,(%rbx)
mov    %rbx,%rdi
call   1050 <strlen@plt>
cmp    $0x3,%rax
jl     11a7 <valid_description+0x67>
lea    0xe98(%rip),%rsi
lea    0xe83(%rip),%rdx
mov    %rsp,%r14
mov    %r14,%rdi
call   1060 <sprintf@plt>
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %rax,%rdx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1294 <valid_description+0x154>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cmp    $0x4,%rax
jl     11ed <valid_description+0xad>
lea    0xe52(%rip),%rsi
lea    0xe3f(%rip),%rdx
mov    %rsp,%r14
mov    %r14,%rdi
call   1060 <sprintf@plt>
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %rax,%rdx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1294 <valid_description+0x154>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cmp    $0x6,%rax
jl     122f <valid_description+0xef>
lea    0xe0c(%rip),%rsi
lea    0xdfc(%rip),%rdx
mov    %rsp,%r14
mov    %r14,%rdi
call   1060 <sprintf@plt>
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %rax,%rdx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1294 <valid_description+0x154>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cmp    $0x5,%rax
jl     1271 <valid_description+0x131>
lea    0xdca(%rip),%rsi
lea    0xdbf(%rip),%rdx
mov    %rsp,%r14
mov    %r14,%rdi
call   1060 <sprintf@plt>
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %rax,%rdx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1294 <valid_description+0x154>
mov    (%rbx),%al
xor    %ecx,%ecx
cmp    $0x9,%al
setne  %cl
cmp    $0x20,%al
lea    -0x3(,%rcx,4),%ecx
mov    $0xfffffffd,%eax
cmovne %ecx,%eax
jmp    1299 <valid_description+0x159>
mov    $0xffffffff,%eax
jmp    1299 <valid_description+0x159>
mov    $0xfffffffe,%eax
add    $0x208,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c"A\00"
@.str.1 = [3 x i8] c"An\00"
@.str.2 = [5 x i8] c"This\00"
@.str.3 = [4 x i8] c"The\00"
@__const.valid_description.article = [4 x i8*] [i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 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)]
@.str.4 = [4 x i8] c"%s \00"
define i32 @valid_description(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca [4 x i8*]
%7 = alloca [512 x i8]
store i8* %0, i8** %3
store i32 4, i32* %5
%8 = bitcast [4 x i8*]* %6 to i8*
%9 = load i8*, i8** %3
%10 = call i64 @strlen(i8* %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %1
store i32 -1, i32* %2
br label %66
13: ; preds = %1
%14 = load i8*, i8** %3
%15 = getelementptr inbounds i8, i8* %14, i64 0
%16 = load i8, i8* %15
%17 = call signext i8 @toupper(i8 signext %16)
%18 = load i8*, i8** %3
%19 = getelementptr inbounds i8, i8* %18, i64 0
store i8 %17, i8* %19
store i32 0, i32* %4
br label %20
20: ; preds = %49, %13
%21 = load i32, i32* %4
%22 = icmp slt i32 %21, 4
br i1 %22, label %23, label %52
23: ; preds = %20
%24 = load i8*, i8** %3
%25 = call i64 @strlen(i8* %24)
%26 = load i32, i32* %4
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [4 x i8*], [4 x i8*]* %6, i64 0, i64 %27
%29 = load i8*, i8** %28
%30 = call i64 @strlen(i8* %29)
%31 = add nsw i64 %30, 1
%32 = icmp sgt i64 %25, %31
br i1 %32, label %33, label %48
33: ; preds = %23
%34 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%35 = load i32, i32* %4
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [4 x i8*], [4 x i8*]* %6, i64 0, i64 %36
%38 = load i8*, i8** %37
%39 = call i32 @sprintf(i8* %34, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %38)
%40 = load i8*, i8** %3
%41 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%42 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%43 = call i64 @strlen(i8* %42)
%44 = call i64 @strncmp(i8* %40, i8* %41, i64 %43)
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %47
46: ; preds = %33
store i32 -2, i32* %2
br label %66
47: ; preds = %33
br label %48
48: ; preds = %47, %23
br label %49
49: ; preds = %48
%50 = load i32, i32* %4
%51 = add nsw i32 %50, 1
store i32 %51, i32* %4
br label %20
52: ; preds = %20
%53 = load i8*, i8** %3
%54 = getelementptr inbounds i8, i8* %53, i64 0
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = icmp eq i32 %56, 32
br i1 %57, label %64, label %58
58: ; preds = %52
%59 = load i8*, i8** %3
%60 = getelementptr inbounds i8, i8* %59, i64 0
%61 = load i8, i8* %60
%62 = sext i8 %61 to i32
%63 = icmp eq i32 %62, 9
br i1 %63, label %64, label %65
64: ; preds = %58, %52
store i32 -3, i32* %2
br label %66
65: ; preds = %58
store i32 1, i32* %2
br label %66
66: ; preds = %65, %64, %46, %12
%67 = load i32, i32* %2
ret i32 %67
}

LLVM IR (-O2):
@.str = [2 x i8] c"A\00"
@.str.1 = [3 x i8] c"An\00"
@.str.2 = [5 x i8] c"This\00"
@.str.3 = [4 x i8] c"The\00"
@.str.4 = [4 x i8] c"%s \00"
define i32 @valid_description(i8* %0) {
%2 = alloca [512 x i8]
%3 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %45, label %6
6: ; preds = %1
%7 = tail call signext i8 @toupper(i8 signext %4)
store i8 %7, i8* %0
%8 = call i64 @strlen(i8* %0)
%9 = icmp sgt i64 %8, 2
br i1 %9, label %10, label %15
10: ; preds = %6
%11 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = call i64 @strlen(i8* %3)
%13 = call i64 @strncmp(i8* %0, i8* %3, i64 %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %45, label %15
15: ; preds = %6, %10
%16 = call i64 @strlen(i8* %0)
%17 = icmp sgt i64 %16, 3
br i1 %17, label %18, label %23
18: ; preds = %15
%19 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%20 = call i64 @strlen(i8* %3)
%21 = call i64 @strncmp(i8* %0, i8* %3, i64 %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %45, label %23
23: ; preds = %18, %15
%24 = call i64 @strlen(i8* %0)
%25 = icmp sgt i64 %24, 5
br i1 %25, label %26, label %31
26: ; preds = %23
%27 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%28 = call i64 @strlen(i8* %3)
%29 = call i64 @strncmp(i8* %0, i8* %3, i64 %28)
%30 = icmp eq i64 %29, 0
br i1 %30, label %45, label %31
31: ; preds = %26, %23
%32 = call i64 @strlen(i8* %0)
%33 = icmp sgt i64 %32, 4
br i1 %33, label %34, label %39
34: ; preds = %31
%35 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%36 = call i64 @strlen(i8* %3)
%37 = call i64 @strncmp(i8* %0, i8* %3, i64 %36)
%38 = icmp eq i64 %37, 0
br i1 %38, label %45, label %39
39: ; preds = %34, %31
%40 = load i8, i8* %0
%41 = icmp eq i8 %40, 32
%42 = icmp eq i8 %40, 9
%43 = or i1 %41, %42
%44 = select i1 %43, i32 -3, i32 1
br label %45
45: ; preds = %10, %18, %26, %34, %39, %1
%46 = phi i32 [ -1, %1 ], [ %44, %39 ], [ -2, %34 ], [ -2, %26 ], [ -2, %18 ], [ -2, %10 ]
ret i32 %46
}