#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 */
char tolower(char);
char *strlwr(char *sOrig) {
  char *s = sOrig;
  if (s && *s) {
    do {
      *s = tolower(*s);
    } while (*s++);
  }
  return sOrig;
}


x86 assembly (clang, -O0):
<strlwr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1175 <strlwr+0x65>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1175 <strlwr+0x65>
jmp    1144 <strlwr+0x34>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <tolower@plt>
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
cmpb   $0x0,(%rax)
jne    1144 <strlwr+0x34>
jmp    1175 <strlwr+0x65>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strlwr>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
test   %rdi,%rdi
je     1152 <strlwr+0x42>
mov    (%r14),%al
test   %al,%al
je     1152 <strlwr+0x42>
movsbl %al,%edi
call   1030 <tolower@plt>
mov    %al,(%r14)
test   %al,%al
je     1152 <strlwr+0x42>
lea    0x1(%r14),%rbx
cs nopw 0x0(%rax,%rax,1)
movsbl (%rbx),%edi
call   1030 <tolower@plt>
mov    %al,(%rbx)
add    $0x1,%rbx
test   %al,%al
jne    1140 <strlwr+0x30>
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*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
store i8* %4, i8** %3
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %24
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %24
12: ; preds = %7
br label %13
13: ; preds = %18, %12
%14 = load i8*, i8** %3
%15 = load i8, i8* %14
%16 = call signext i8 @tolower(i8 signext %15)
%17 = load i8*, i8** %3
store i8 %16, i8* %17
br label %18
18: ; preds = %13
%19 = load i8*, i8** %3
%20 = getelementptr inbounds i8, i8* %19, i32 1
store i8* %20, i8** %3
%21 = load i8, i8* %19
%22 = icmp ne i8 %21, 0
br i1 %22, label %13, label %23
23: ; preds = %18
br label %24
24: ; preds = %23, %7, %1
%25 = load i8*, i8** %2
ret i8* %25
}

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