#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 Always;
int NotUseful;
int WhenMapped;
scalar_t__ isascii(char);
scalar_t__ isupper(char);
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
char tolower(char);
int /*<<< orphan*/ usage();
int parse_backing_store(char *s) {
  int len = strlen(s);
  char *cp;
  for (cp = s; *cp; cp++) {
    if (isascii(*cp) && isupper(*cp))
      *cp = tolower(*cp);
  }
  if (strncmp(s, "notuseful", len) == 0)
    return (NotUseful);
  if (strncmp(s, "whenmapped", len) == 0)
    return (WhenMapped);
  if (strncmp(s, "always", len) == 0)
    return (Always);
  usage();
}


x86 assembly (clang, -O0):
<parse_backing_store>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
je     11e3 <parse_backing_store+0x83>
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1080 <isascii@plt>
cmp    $0x0,%rax
je     11cd <parse_backing_store+0x6d>
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1060 <isupper@plt>
cmp    $0x0,%rax
je     11cd <parse_backing_store+0x6d>
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1050 <tolower@plt>
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %cl,(%rax)
jmp    11d2 <parse_backing_store+0x72>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1180 <parse_backing_store+0x20>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xe0f(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1211 <parse_backing_store+0xb1>
mov    0x2de1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1274 <parse_backing_store+0x114>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xdeb(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    123f <parse_backing_store+0xdf>
mov    0x2dab(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1274 <parse_backing_store+0x114>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xdc8(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    126d <parse_backing_store+0x10d>
mov    0x2d75(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1274 <parse_backing_store+0x114>
mov    $0x0,%al
call   1070 <usage@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_backing_store>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbp
call   1040 <strlen@plt>
mov    %eax,%r14d
mov    0x0(%rbp),%al
test   %al,%al
je     11b2 <parse_backing_store+0x52>
mov    %rbp,%rbx
jmp    118c <parse_backing_store+0x2c>
nopl   0x0(%rax,%rax,1)
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     11b2 <parse_backing_store+0x52>
movsbl %al,%edi
call   1080 <isascii@plt>
test   %rax,%rax
je     1180 <parse_backing_store+0x20>
movsbl (%rbx),%edi
call   1060 <isupper@plt>
test   %rax,%rax
je     1180 <parse_backing_store+0x20>
movsbl (%rbx),%edi
call   1050 <tolower@plt>
mov    %al,(%rbx)
jmp    1180 <parse_backing_store+0x20>
lea    0xe47(%rip),%rsi
mov    %rbp,%rdi
mov    %r14d,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1200 <parse_backing_store+0xa0>
lea    0xe3a(%rip),%rsi
mov    %rbp,%rdi
mov    %r14d,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1209 <parse_backing_store+0xa9>
lea    0xe2e(%rip),%rsi
mov    %rbp,%rdi
mov    %r14d,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1212 <parse_backing_store+0xb2>
xor    %eax,%eax
call   1070 <usage@plt>
jmp    121b <parse_backing_store+0xbb>
mov    0x2de1(%rip),%rax
jmp    1219 <parse_backing_store+0xb9>
mov    0x2dd0(%rip),%rax
jmp    1219 <parse_backing_store+0xb9>
mov    0x2dbf(%rip),%rax
mov    (%rax),%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"notuseful\00"
@NotUseful = global i32 0
@.str.1 = [11 x i8] c"whenmapped\00"
@WhenMapped = global i32 0
@.str.2 = [7 x i8] c"always\00"
@Always = global i32 0
define i32 @parse_backing_store(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i32 @strlen(i8* %6)
store i32 %7, i32* %4
%8 = load i8*, i8** %3
store i8* %8, i8** %5
br label %9
9: ; preds = %29, %1
%10 = load i8*, i8** %5
%11 = load i8, i8* %10
%12 = icmp ne i8 %11, 0
br i1 %12, label %13, label %32
13: ; preds = %9
%14 = load i8*, i8** %5
%15 = load i8, i8* %14
%16 = call i64 @isascii(i8 signext %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %28
18: ; preds = %13
%19 = load i8*, i8** %5
%20 = load i8, i8* %19
%21 = call i64 @isupper(i8 signext %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %28
23: ; preds = %18
%24 = load i8*, i8** %5
%25 = load i8, i8* %24
%26 = call signext i8 @tolower(i8 signext %25)
%27 = load i8*, i8** %5
store i8 %26, i8* %27
br label %28
28: ; preds = %23, %18, %13
br label %29
29: ; preds = %28
%30 = load i8*, i8** %5
%31 = getelementptr inbounds i8, i8* %30, i32 1
store i8* %31, i8** %5
br label %9
32: ; preds = %9
%33 = load i8*, i8** %3
%34 = load i32, i32* %4
%35 = call i64 @strncmp(i8* %33, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %34)
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %32
%38 = load i32, i32* @NotUseful
store i32 %38, i32* %2
br label %55
39: ; preds = %32
%40 = load i8*, i8** %3
%41 = load i32, i32* %4
%42 = call i64 @strncmp(i8* %40, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %41)
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %46
44: ; preds = %39
%45 = load i32, i32* @WhenMapped
store i32 %45, i32* %2
br label %55
46: ; preds = %39
%47 = load i8*, i8** %3
%48 = load i32, i32* %4
%49 = call i64 @strncmp(i8* %47, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %48)
%50 = icmp eq i64 %49, 0
br i1 %50, label %51, label %53
51: ; preds = %46
%52 = load i32, i32* @Always
store i32 %52, i32* %2
br label %55
53: ; preds = %46
%54 = call i32 (...) @usage()
br label %55
55: ; preds = %53, %51, %44, %37
%56 = load i32, i32* %2
ret i32 %56
}

LLVM IR (-O2):
@.str = [10 x i8] c"notuseful\00"
@NotUseful = global i32 0
@.str.1 = [11 x i8] c"whenmapped\00"
@WhenMapped = global i32 0
@.str.2 = [7 x i8] c"always\00"
@Always = global i32 0
define i32 @parse_backing_store(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %21, label %5
5: ; preds = %1, %17
%6 = phi i8 [ %19, %17 ], [ %3, %1 ]
%7 = phi i8* [ %18, %17 ], [ %0, %1 ]
%8 = tail call i64 @isascii(i8 signext %6)
%9 = icmp eq i64 %8, 0
br i1 %9, label %17, label %10
10: ; preds = %5
%11 = load i8, i8* %7
%12 = tail call i64 @isupper(i8 signext %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %10
%15 = load i8, i8* %7
%16 = tail call signext i8 @tolower(i8 signext %15)
store i8 %16, i8* %7
br label %17
17: ; preds = %5, %10, %14
%18 = getelementptr inbounds i8, i8* %7, i64 1
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
br i1 %20, label %21, label %5
21: ; preds = %17, %1
%22 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %2)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = load i32, i32* @NotUseful
br label %38
26: ; preds = %21
%27 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %2)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = load i32, i32* @WhenMapped
br label %38
31: ; preds = %26
%32 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %2)
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %31
%35 = load i32, i32* @Always
br label %38
36: ; preds = %31
%37 = tail call i32 (...) @usage()
br label %38
38: ; preds = %36, %34, %29, %24
%39 = phi i32 [ %25, %24 ], [ %30, %29 ], [ %35, %34 ], [ undef, %36 ]
ret i32 %39
}