#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 */
size_t strlen(char *);
char tolower(char);
void word_to_lower(char *word) {
  for (size_t i = 0; i < strlen(word); ++i)
    word[i] = tolower(word[i]);
}


x86 assembly (clang, -O0):
<word_to_lower>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
cmp    %rcx,%rax
jae    1184 <word_to_lower+0x64>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <tolower@plt>
mov    %al,%dl
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1134 <word_to_lower+0x14>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<word_to_lower>:
push   %r14
push   %rbx
push   %rax
mov    (%rdi),%al
test   %al,%al
je     116f <word_to_lower+0x4f>
mov    %rdi,%r14
movsbl %al,%edi
call   1040 <tolower@plt>
mov    %al,(%r14)
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    $0x2,%rax
jb     116f <word_to_lower+0x4f>
mov    $0x1,%ebx
nopl   0x0(%rax,%rax,1)
movsbl (%r14,%rbx,1),%edi
call   1040 <tolower@plt>
mov    %al,(%r14,%rbx,1)
add    $0x1,%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    %rax,%rbx
jb     1150 <word_to_lower+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @word_to_lower(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
store i8* %0, i8** %2
store i64 0, i64* %3
br label %4
4: ; preds = %18, %1
%5 = load i64, i64* %3
%6 = load i8*, i8** %2
%7 = call i64 @strlen(i8* %6)
%8 = icmp ult i64 %5, %7
br i1 %8, label %9, label %21
9: ; preds = %4
%10 = load i8*, i8** %2
%11 = load i64, i64* %3
%12 = getelementptr inbounds i8, i8* %10, i64 %11
%13 = load i8, i8* %12
%14 = call signext i8 @tolower(i8 signext %13)
%15 = load i8*, i8** %2
%16 = load i64, i64* %3
%17 = getelementptr inbounds i8, i8* %15, i64 %16
store i8 %14, i8* %17
br label %18
18: ; preds = %9
%19 = load i64, i64* %3
%20 = add i64 %19, 1
store i64 %20, i64* %3
br label %4
21: ; preds = %4
ret void
}

LLVM IR (-O2):
define void @word_to_lower(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %8, label %4
4: ; preds = %1
%5 = tail call signext i8 @tolower(i8 signext %2)
store i8 %5, i8* %0
%6 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%7 = icmp ugt i64 %6, 1
br i1 %7, label %9, label %8
8: ; preds = %9, %4, %1
ret void
9: ; preds = %4, %9
%10 = phi i64 [ %15, %9 ], [ 1, %4 ]
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = load i8, i8* %11
%13 = getelementptr inbounds i8, i8* %0, i64 %10
%14 = tail call signext i8 @tolower(i8 signext %12)
store i8 %14, i8* %13
%15 = add nuw i64 %10, 1
%16 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%17 = icmp ult i64 %15, %16
br i1 %17, label %9, label %8
}