#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 */
typedef int /*<<< orphan*/ s;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *);
char tolower(char);
int main() {
  char s[] = "aBcDefg";
  int i;
  printf("before tolower():%s\n", s);
  for (i = 0; i < sizeof(s); i++) {
    s[i] = tolower(s[i]);
  }
  printf("after tolower():%s\n", s);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0xc(%rbp)
lea    -0xc(%rbp),%rsi
lea    0xec3(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
movslq -0x10(%rbp),%rax
cmp    $0x8,%rax
jae    1185 <main+0x65>
movslq -0x10(%rbp),%rax
movsbl -0xc(%rbp,%rax,1),%edi
call   1040 <tolower@plt>
mov    %al,%cl
movslq -0x10(%rbp),%rax
mov    %cl,-0xc(%rbp,%rax,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1151 <main+0x31>
lea    -0xc(%rbp),%rsi
lea    0xe8d(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movabs $0x67666544634261,%rax
mov    %rax,0x8(%rsp)
lea    0xec5(%rip),%rdi
lea    0x8(%rsp),%rbx
mov    %rbx,%rsi
call   1030 <printf@plt>
movsbl 0x8(%rsp),%edi
call   1040 <tolower@plt>
mov    %al,0x8(%rsp)
movsbl 0x9(%rsp),%edi
call   1040 <tolower@plt>
mov    %al,0x9(%rsp)
movsbl 0xa(%rsp),%edi
call   1040 <tolower@plt>
mov    %al,0xa(%rsp)
movsbl 0xb(%rsp),%edi
call   1040 <tolower@plt>
mov    %al,0xb(%rsp)
movsbl 0xc(%rsp),%edi
call   1040 <tolower@plt>
mov    %al,0xc(%rsp)
movsbl 0xd(%rsp),%edi
call   1040 <tolower@plt>
mov    %al,0xd(%rsp)
movsbl 0xe(%rsp),%edi
call   1040 <tolower@plt>
mov    %al,0xe(%rsp)
movsbl 0xf(%rsp),%edi
call   1040 <tolower@plt>
mov    %al,0xf(%rsp)
lea    0xe56(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.s = [8 x i8] c"aBcDefg\00"
@.str = [21 x i8] c"before tolower():%s\0A\00"
@.str.1 = [20 x i8] c"after tolower():%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [8 x i8]
%3 = alloca i32
store i32 0, i32* %1
%4 = bitcast [8 x i8]* %2 to i8*
%5 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%6 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %5)
store i32 0, i32* %3
br label %7
7: ; preds = %20, %0
%8 = load i32, i32* %3
%9 = sext i32 %8 to i64
%10 = icmp ult i64 %9, 8
br i1 %10, label %11, label %23
11: ; preds = %7
%12 = load i32, i32* %3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = call signext i8 @tolower(i8 signext %15)
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 %18
store i8 %16, i8* %19
br label %20
20: ; preds = %11
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
br label %7
23: ; preds = %7
%24 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%25 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %24)
ret i32 0
}

LLVM IR (-O2):
@.str = [21 x i8] c"before tolower():%s\0A\00"
@.str.1 = [20 x i8] c"after tolower():%s\0A\00"
define i32 @main() {
%1 = alloca i64
%2 = bitcast i64* %1 to [8 x i8]*
%3 = bitcast i64* %1 to i8*
store i64 29104507726283361, i64* %1
%4 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %3)
%5 = bitcast i64* %1 to i8*
%6 = load i8, i8* %5
%7 = call signext i8 @tolower(i8 signext %6)
store i8 %7, i8* %5
%8 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 1
%9 = load i8, i8* %8
%10 = call signext i8 @tolower(i8 signext %9)
store i8 %10, i8* %8
%11 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 2
%12 = load i8, i8* %11
%13 = call signext i8 @tolower(i8 signext %12)
store i8 %13, i8* %11
%14 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 3
%15 = load i8, i8* %14
%16 = call signext i8 @tolower(i8 signext %15)
store i8 %16, i8* %14
%17 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 4
%18 = load i8, i8* %17
%19 = call signext i8 @tolower(i8 signext %18)
store i8 %19, i8* %17
%20 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 5
%21 = load i8, i8* %20
%22 = call signext i8 @tolower(i8 signext %21)
store i8 %22, i8* %20
%23 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 6
%24 = load i8, i8* %23
%25 = call signext i8 @tolower(i8 signext %24)
store i8 %25, i8* %23
%26 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 7
%27 = load i8, i8* %26
%28 = call signext i8 @tolower(i8 signext %27)
store i8 %28, i8* %26
%29 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %3)
ret i32 0
}