#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 */
scalar_t__ isascii(char);
scalar_t__ isupper(char);
char tolower(char);
char *strlwr(char *c) {
  char *p;
  if (!c)
    return NULL;
  for (p = c; *p; p++)
    if (isascii(*p) && isupper(*p))
      *p = tolower(*p);
  return c;
}


x86 assembly (clang, -O0):
<strlwr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1154 <strlwr+0x24>
movq   $0x0,-0x8(%rbp)
jmp    11c7 <strlwr+0x97>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     11bf <strlwr+0x8f>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1050 <isascii@plt>
cmp    $0x0,%rax
je     11a9 <strlwr+0x79>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isupper@plt>
cmp    $0x0,%rax
je     11a9 <strlwr+0x79>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <tolower@plt>
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
jmp    11ae <strlwr+0x7e>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    115c <strlwr+0x2c>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strlwr>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
test   %rdi,%rdi
je     1182 <strlwr+0x52>
mov    (%r14),%al
test   %al,%al
je     1182 <strlwr+0x52>
mov    %r14,%rbx
jmp    115c <strlwr+0x2c>
nopl   0x0(%rax,%rax,1)
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1182 <strlwr+0x52>
movsbl %al,%edi
call   1050 <isascii@plt>
test   %rax,%rax
je     1150 <strlwr+0x20>
movsbl (%rbx),%edi
call   1040 <isupper@plt>
test   %rax,%rax
je     1150 <strlwr+0x20>
movsbl (%rbx),%edi
call   1030 <tolower@plt>
mov    %al,(%rbx)
jmp    1150 <strlwr+0x20>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @strlwr(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
br i1 %6, label %8, label %7
7: ; preds = %1
store i8* null, i8** %2
br label %35
8: ; preds = %1
%9 = load i8*, i8** %3
store i8* %9, i8** %4
br label %10
10: ; preds = %30, %8
%11 = load i8*, i8** %4
%12 = load i8, i8* %11
%13 = icmp ne i8 %12, 0
br i1 %13, label %14, label %33
14: ; preds = %10
%15 = load i8*, i8** %4
%16 = load i8, i8* %15
%17 = call i64 @isascii(i8 signext %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %29
19: ; preds = %14
%20 = load i8*, i8** %4
%21 = load i8, i8* %20
%22 = call i64 @isupper(i8 signext %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %29
24: ; preds = %19
%25 = load i8*, i8** %4
%26 = load i8, i8* %25
%27 = call signext i8 @tolower(i8 signext %26)
%28 = load i8*, i8** %4
store i8 %27, i8* %28
br label %29
29: ; preds = %24, %19, %14
br label %30
30: ; preds = %29
%31 = load i8*, i8** %4
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %4
br label %10
33: ; preds = %10
%34 = load i8*, i8** %3
store i8* %34, i8** %2
br label %35
35: ; preds = %33, %7
%36 = load i8*, i8** %2
ret i8* %36
}

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