#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*/ assert(int /*<<< orphan*/);
scalar_t__ isupper(int);
scalar_t__ tolower(int);
char *mprStrLower(char *str) {
  char *cp;
  assert(str != NULL);
  if (str == 0) {
    return 0;
  }
  for (cp = str; *cp; cp++) {
    if (isupper((int)*cp)) {
      *cp = (char)tolower((int)*cp);
    }
  }
  return str;
}


x86 assembly (clang, -O0):
<mprStrLower>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpq   $0x0,-0x10(%rbp)
jne    1166 <mprStrLower+0x36>
movq   $0x0,-0x8(%rbp)
jmp    11c3 <mprStrLower+0x93>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     11bb <mprStrLower+0x8b>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1050 <isupper@plt>
cmp    $0x0,%rax
je     11a5 <mprStrLower+0x75>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1040 <tolower@plt>
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
jmp    11aa <mprStrLower+0x7a>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    116e <mprStrLower+0x3e>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mprStrLower>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %edi,%edi
test   %r14,%r14
setne  %dil
call   1030 <assert@plt>
test   %r14,%r14
je     1185 <mprStrLower+0x55>
mov    (%r14),%al
test   %al,%al
je     1185 <mprStrLower+0x55>
mov    %r14,%rbx
jmp    116c <mprStrLower+0x3c>
cs nopw 0x0(%rax,%rax,1)
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1185 <mprStrLower+0x55>
movsbl %al,%edi
call   1050 <isupper@plt>
test   %rax,%rax
je     1160 <mprStrLower+0x30>
movsbl (%rbx),%edi
call   1040 <tolower@plt>
mov    %al,(%rbx)
jmp    1160 <mprStrLower+0x30>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i8* @mprStrLower(i8* %0) {
%2 = icmp ne i8* %0, null
%3 = zext i1 %2 to i32
%4 = tail call i32 @assert(i32 %3)
%5 = icmp eq i8* %0, null
br i1 %5, label %24, label %6
6: ; preds = %1
%7 = load i8, i8* %0
%8 = icmp eq i8 %7, 0
br i1 %8, label %24, label %9
9: ; preds = %6, %20
%10 = phi i8 [ %22, %20 ], [ %7, %6 ]
%11 = phi i8* [ %21, %20 ], [ %0, %6 ]
%12 = sext i8 %10 to i32
%13 = tail call i64 @isupper(i32 %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %20, label %15
15: ; preds = %9
%16 = load i8, i8* %11
%17 = sext i8 %16 to i32
%18 = tail call i64 @tolower(i32 %17)
%19 = trunc i64 %18 to i8
store i8 %19, i8* %11
br label %20
20: ; preds = %9, %15
%21 = getelementptr inbounds i8, i8* %11, i64 1
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 0
br i1 %23, label %24, label %9
24: ; preds = %20, %6, %1
ret i8* %0
}