#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__ tolower(char);
char *str2lwr(char *String) {
  char *PtrChar;
  if (String != NULL) {
    PtrChar = String;
    while (*PtrChar != '\0') {
      *PtrChar = (char)tolower(*PtrChar);
      PtrChar++;
    }
  }
  if (String != NULL)
    return (String);
  else
    return (NULL);
}


x86 assembly (clang, -O0):
<str2lwr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1169 <str2lwr+0x59>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1164 <str2lwr+0x54>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <tolower@plt>
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    112f <str2lwr+0x1f>
jmp    1169 <str2lwr+0x59>
cmpq   $0x0,-0x10(%rbp)
je     1181 <str2lwr+0x71>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1189 <str2lwr+0x79>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str2lwr>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
test   %rdi,%rdi
je     1146 <str2lwr+0x36>
mov    (%r14),%al
test   %al,%al
je     1146 <str2lwr+0x36>
lea    0x1(%r14),%rbx
nopw   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1030 <tolower@plt>
mov    %al,-0x1(%rbx)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <str2lwr+0x20>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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