#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 */
int lower(char);
int /*<<< orphan*/ printf(char *, char, int);
int strlen(char *);
int main() {
  char test[] = "AabB!@#CCdeZZXx";
  for (int i = 0; i < strlen(test); ++i) {
    printf("%c to lower %c\n", test[i], lower(test[i]));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeba(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeb7(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
lea    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
cmp    %ecx,%eax
jge    11b3 <main+0x83>
movslq -0x24(%rbp),%rax
mov    -0x20(%rbp,%rax,1),%al
mov    %al,-0x29(%rbp)
movslq -0x24(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%edi
call   1050 <lower@plt>
mov    %eax,%edx
mov    -0x29(%rbp),%al
lea    0xe73(%rip),%rdi
movsbl %al,%esi
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    115c <main+0x2c>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
movaps 0xebf(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    118a <main+0x5a>
xor    %ebx,%ebx
lea    0xeb6(%rip),%r14
mov    %rsp,%r15
nopl   (%rax)
movsbl (%rsp,%rbx,1),%ebp
mov    %ebp,%edi
call   1050 <lower@plt>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %eax,%edx
call   1040 <printf@plt>
add    $0x1,%rbx
mov    %r15,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     1160 <main+0x30>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@__const.main.test = [16 x i8] c"AabB!@#CCdeZZXx\00"
@.str = [16 x i8] c"%c to lower %c\0A\00"
define i32 @main() {
%1 = alloca [16 x i8]
%2 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%3 = call i32 @strlen(i8* %2)
%4 = icmp sgt i32 %3, 0
br i1 %4, label %6, label %5
5: ; preds = %6, %0
ret i32 0
6: ; preds = %0, %6
%7 = phi i64 [ %12, %6 ], [ 0, %0 ]
%8 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 %7
%9 = load i8, i8* %8
%10 = call i32 @lower(i8 signext %9)
%11 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8 signext %9, i32 %10)
%12 = add nuw nsw i64 %7, 1
%13 = call i32 @strlen(i8* %2)
%14 = sext i32 %13 to i64
%15 = icmp slt i64 %12, %14
br i1 %15, label %6, label %5
}