#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 lower(char);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
int main(void) {
  char test_word[] = "HeLlO wOrLd!";
  int i;
  printf("Original word:   %s\n", test_word);
  printf("Lowercased word: ");
  i = 0;
  while (test_word[i] != '\0')
    putchar(lower(test_word[i++]));
  putchar('\n');
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeba(%rip),%rax
mov    %rax,-0x11(%rbp)
mov    0xeb8(%rip),%eax
mov    %eax,-0x9(%rbp)
mov    0xeb3(%rip),%al
mov    %al,-0x5(%rbp)
lea    -0x11(%rbp),%rsi
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x18(%rbp)
movslq -0x18(%rbp),%rax
movsbl -0x11(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     11b9 <main+0x89>
mov    -0x18(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x18(%rbp)
cltq
movsbl -0x11(%rbp,%rax,1),%edi
call   1050 <lower@plt>
movsbl %al,%edi
call   1030 <putchar@plt>
jmp    1183 <main+0x53>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movabs $0x21644c724f7720,%rax
mov    %rax,0x5(%rsp)
movabs $0x4f77204f6c4c6548,%rax
20 77 4f
mov    %rax,(%rsp)
lea    0xeb4(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp),%al
test   %al,%al
je     119b <main+0x6b>
lea    0x1(%rsp),%rbx
nopl   (%rax)
movsbl %al,%edi
call   1050 <lower@plt>
movsbl %al,%edi
call   1030 <putchar@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1180 <main+0x50>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@__const.main.test_word = [13 x i8] c"HeLlO wOrLd!\00"
@.str = [21 x i8] c"Original word: %s\0A\00"
@.str.1 = [18 x i8] c"Lowercased word: \00"
define i32 @main() {
%1 = alloca [13 x i8]
%2 = getelementptr inbounds [13 x i8], [13 x i8]* %1, i64 0, i64 0
%3 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %2)
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%5 = load i8, i8* %2
%6 = icmp eq i8 %5, 0
br i1 %6, label %16, label %7
7: ; preds = %0, %7
%8 = phi i64 [ %10, %7 ], [ 0, %0 ]
%9 = phi i8 [ %14, %7 ], [ %5, %0 ]
%10 = add nuw i64 %8, 1
%11 = call signext i8 @lower(i8 signext %9)
%12 = call i32 @putchar(i8 signext %11)
%13 = getelementptr inbounds [13 x i8], [13 x i8]* %1, i64 0, i64 %10
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 0
br i1 %15, label %16, label %7
16: ; preds = %7, %0
%17 = call i32 @putchar(i8 signext 10)
ret i32 0
}