#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__ isupper(char);
char tolower(char);
char *Lowercase(char *str) {
  register char *ptr;
  static char area[1024];
  ptr = area;
  while (*str) {
    *(ptr++) = (isupper(*str) ? tolower(*str) : (*str));
    str++;
  }
  *ptr = '\0';
  return (area);
}


x86 assembly (clang, -O0):
<Lowercase>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0x2f0d(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     11a2 <Lowercase+0x82>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isupper@plt>
cmp    $0x0,%rax
je     1171 <Lowercase+0x51>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <tolower@plt>
movsbl %al,%eax
mov    %eax,-0x14(%rbp)
jmp    117b <Lowercase+0x5b>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1137 <Lowercase+0x17>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
lea    0x2e90(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Lowercase>:
push   %r14
push   %rbx
push   %rax
mov    (%rdi),%al
test   %al,%al
je     1170 <Lowercase+0x50>
mov    %rdi,%rbx
add    $0x1,%rbx
lea    0x2f08(%rip),%r14
jmp    1152 <Lowercase+0x32>
nopw   0x0(%rax,%rax,1)
mov    %al,(%r14)
add    $0x1,%r14
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1177 <Lowercase+0x57>
movsbl %al,%edi
call   1040 <isupper@plt>
mov    %rax,%rcx
movzbl -0x1(%rbx),%eax
test   %rcx,%rcx
je     1140 <Lowercase+0x20>
movsbl %al,%edi
call   1030 <tolower@plt>
jmp    1140 <Lowercase+0x20>
lea    0x2ec9(%rip),%r14
movb   $0x0,(%r14)
lea    0x2ebe(%rip),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@Lowercase.area = internal global [1024 x i8] zeroinitializer
define i8* @Lowercase(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
store i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @Lowercase.area, i64 0, i64 0), i8** %3
br label %4
4: ; preds = %22, %1
%5 = load i8*, i8** %2
%6 = load i8, i8* %5
%7 = icmp ne i8 %6, 0
br i1 %7, label %8, label %29
8: ; preds = %4
%9 = load i8*, i8** %2
%10 = load i8, i8* %9
%11 = call i64 @isupper(i8 signext %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %8
%14 = load i8*, i8** %2
%15 = load i8, i8* %14
%16 = call signext i8 @tolower(i8 signext %15)
%17 = sext i8 %16 to i32
br label %22
18: ; preds = %8
%19 = load i8*, i8** %2
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
br label %22
22: ; preds = %18, %13
%23 = phi i32 [ %17, %13 ], [ %21, %18 ]
%24 = trunc i32 %23 to i8
%25 = load i8*, i8** %3
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %3
store i8 %24, i8* %25
%27 = load i8*, i8** %2
%28 = getelementptr inbounds i8, i8* %27, i32 1
store i8* %28, i8** %2
br label %4
29: ; preds = %4
%30 = load i8*, i8** %3
store i8 0, i8* %30
ret i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @Lowercase.area, i64 0, i64 0)
}

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