#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(unsigned char);
unsigned char tolower(unsigned char);
int strToLower(unsigned char *aString) {
  short i = 0;
  while (aString[i]) {
    if (isupper(aString[i])) {
      aString[i] = tolower(aString[i]);
    }
    i++;
  }
  return 1;
}


x86 assembly (clang, -O0):
<strToLower>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movw   $0x0,-0xa(%rbp)
mov    -0x8(%rbp),%rax
movswq -0xa(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     1192 <strToLower+0x72>
mov    -0x8(%rbp),%rax
movswq -0xa(%rbp),%rcx
movzbl (%rax,%rcx,1),%edi
call   1040 <isupper@plt>
cmp    $0x0,%rax
je     1181 <strToLower+0x61>
mov    -0x8(%rbp),%rax
movswq -0xa(%rbp),%rcx
movzbl (%rax,%rcx,1),%edi
call   1030 <tolower@plt>
mov    %al,%dl
mov    -0x8(%rbp),%rax
movswq -0xa(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0xa(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0xa(%rbp)
jmp    1132 <strToLower+0x12>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strToLower>:
push   %r15
push   %r14
push   %rbx
mov    (%rdi),%al
test   %al,%al
je     116f <strToLower+0x4f>
mov    %rdi,%r14
mov    $0x1,%bx
mov    %rdi,%r15
jmp    1154 <strToLower+0x34>
nopw   0x0(%rax,%rax,1)
movswq %bx,%rax
lea    (%r14,%rax,1),%r15
movzbl (%r14,%rax,1),%eax
add    $0x1,%ebx
test   %al,%al
je     116f <strToLower+0x4f>
movzbl %al,%edi
call   1040 <isupper@plt>
test   %rax,%rax
je     1140 <strToLower+0x20>
movzbl (%r15),%edi
call   1030 <tolower@plt>
mov    %al,(%r15)
jmp    1140 <strToLower+0x20>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @strToLower(i8* %0) {
%2 = alloca i8*
%3 = alloca i16
store i8* %0, i8** %2
store i16 0, i16* %3
br label %4
4: ; preds = %30, %1
%5 = load i8*, i8** %2
%6 = load i16, i16* %3
%7 = sext i16 %6 to i64
%8 = getelementptr inbounds i8, i8* %5, i64 %7
%9 = load i8, i8* %8
%10 = icmp ne i8 %9, 0
br i1 %10, label %11, label %33
11: ; preds = %4
%12 = load i8*, i8** %2
%13 = load i16, i16* %3
%14 = sext i16 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8, i8* %15
%17 = call i64 @isupper(i8 zeroext %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %30
19: ; preds = %11
%20 = load i8*, i8** %2
%21 = load i16, i16* %3
%22 = sext i16 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
%24 = load i8, i8* %23
%25 = call zeroext i8 @tolower(i8 zeroext %24)
%26 = load i8*, i8** %2
%27 = load i16, i16* %3
%28 = sext i16 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
store i8 %25, i8* %29
br label %30
30: ; preds = %19, %11
%31 = load i16, i16* %3
%32 = add i16 %31, 1
store i16 %32, i16* %3
br label %4
33: ; preds = %4
ret i32 1
}

LLVM IR (-O2):
define i32 @strToLower(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* [ %16, %13 ], [ %0, %1 ]
%7 = phi i16 [ %14, %13 ], [ 0, %1 ]
%8 = tail call i64 @isupper(i8 zeroext %5)
%9 = icmp eq i64 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %4
%11 = load i8, i8* %6
%12 = tail call zeroext i8 @tolower(i8 zeroext %11)
store i8 %12, i8* %6
br label %13
13: ; preds = %10, %4
%14 = add i16 %7, 1
%15 = sext i16 %14 to i64
%16 = getelementptr inbounds i8, i8* %0, i64 %15
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 0
br i1 %18, label %19, label %4
19: ; preds = %13, %1
ret i32 1
}