#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 *PFC_strdup(char const *);
char tolower(char);
char *XML_ToLower(const char *str) {
  char *p = PFC_strdup(str);
  char *result = p;
  if (p != NULL) {
    for (; *p; ++p) {
      *p = tolower(*p);
    }
  }
  return result;
}


x86 assembly (clang, -O0):
<XML_ToLower>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <PFC_strdup@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1188 <XML_ToLower+0x68>
jmp    1151 <XML_ToLower+0x31>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1183 <XML_ToLower+0x63>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <tolower@plt>
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1151 <XML_ToLower+0x31>
jmp    1188 <XML_ToLower+0x68>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<XML_ToLower>:
push   %r14
push   %rbx
push   %rax
call   1030 <PFC_strdup@plt>
mov    %rax,%r14
test   %rax,%rax
je     1156 <XML_ToLower+0x36>
mov    (%r14),%al
test   %al,%al
je     1156 <XML_ToLower+0x36>
mov    %r14,%rbx
add    $0x1,%rbx
nop
movsbl %al,%edi
call   1040 <tolower@plt>
mov    %al,-0x1(%rbx)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1140 <XML_ToLower+0x20>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @XML_ToLower(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i8* @PFC_strdup(i8* %5)
store i8* %6, i8** %3
%7 = load i8*, i8** %3
store i8* %7, i8** %4
%8 = load i8*, i8** %3
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %24
10: ; preds = %1
br label %11
11: ; preds = %20, %10
%12 = load i8*, i8** %3
%13 = load i8, i8* %12
%14 = icmp ne i8 %13, 0
br i1 %14, label %15, label %23
15: ; preds = %11
%16 = load i8*, i8** %3
%17 = load i8, i8* %16
%18 = call signext i8 @tolower(i8 signext %17)
%19 = load i8*, i8** %3
store i8 %18, i8* %19
br label %20
20: ; preds = %15
%21 = load i8*, i8** %3
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %3
br label %11
23: ; preds = %11
br label %24
24: ; preds = %23, %1
%25 = load i8*, i8** %4
ret i8* %25
}

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