#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 /*<<< orphan*/ assert(int /*<<< orphan*/);
char *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ str_lower_case(char *, char *);
int strlen(char *);
int main() {
  char *src1 = "HellO, WoRlD";
  char src2[] = "hElLo";
  char *src3 = "";
  char *dest1, *dest2, *dest3;
  dest1 = malloc(strlen(src1) * sizeof(char) + 1);
  dest2 = malloc(strlen(src2) * sizeof(char) + 1);
  dest3 = malloc(strlen(src3) * sizeof(char) + 1);
  assert(dest1 != NULL);
  assert(dest2 != NULL);
  assert(dest3 != NULL);
  printf("Before lowercase\n");
  printf("================\n");
  printf("src1: %s\n", src1);
  printf("src2: %s\n", src2);
  printf("src3: %s\n", src3);
  str_lower_case(dest1, src1);
  str_lower_case(dest2, src2);
  str_lower_case(dest3, src3);
  printf("\nAfter lowercase\n");
  printf("================\n");
  printf("dest1: %s\n", dest1);
  printf("dest2: %s\n", dest2);
  printf("dest3: %s\n", dest3);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xe9d(%rip),%eax
mov    %eax,-0x16(%rbp)
mov    0xe97(%rip),%ax
mov    %ax,-0x12(%rbp)
lea    0xeb1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
cltq
shl    $0x0,%rax
add    $0x1,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x28(%rbp)
lea    -0x16(%rbp),%rdi
call   1040 <strlen@plt>
cltq
shl    $0x0,%rax
add    $0x1,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
cltq
shl    $0x0,%rax
add    $0x1,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x28(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
cmpq   $0x0,-0x30(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
cmpq   $0x0,-0x38(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    0xdf3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xdf7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xdf7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x16(%rbp),%rsi
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xde7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <str_lower_case@plt>
mov    -0x30(%rbp),%rdi
lea    -0x16(%rbp),%rsi
call   1030 <str_lower_case@plt>
mov    -0x38(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <str_lower_case@plt>
lea    0xdbc(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xd7e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x28(%rbp),%rsi
lea    0xdae(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x30(%rbp),%rsi
lea    0xda7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x38(%rbp),%rsi
lea    0xda0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movw   $0x6f,0x4(%rsp)
movl   $0x4c6c4568,(%rsp)
lea    0xe80(%rip),%r13
mov    %r13,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%edi
call   1080 <malloc@plt>
mov    %rax,%r14
mov    %rsp,%rbp
mov    %rbp,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%edi
call   1080 <malloc@plt>
mov    %rax,%r15
lea    0xe6c(%rip),%r12
mov    %r12,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
xor    %edi,%edi
test   %r14,%r14
setne  %dil
call   1070 <assert@plt>
xor    %edi,%edi
test   %r15,%r15
setne  %dil
call   1070 <assert@plt>
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1070 <assert@plt>
lea    0xe5e(%rip),%rdi
call   1030 <puts@plt>
lea    0xe74(%rip),%rdi
call   1030 <puts@plt>
lea    0xe07(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe00(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xdf9(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14,%rdi
mov    %r13,%rsi
call   1040 <str_lower_case@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
call   1040 <str_lower_case@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <str_lower_case@plt>
lea    0xe03(%rip),%rdi
call   1030 <puts@plt>
lea    0xe08(%rip),%rdi
call   1030 <puts@plt>
lea    0xdb9(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xdb3(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xdad(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"HellO, WoRlD\00"
@__const.main.src2 = [6 x i8] c"hElLo\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [18 x i8] c"Before lowercase\0A\00"
@.str.3 = [18 x i8] c"================\0A\00"
@.str.4 = [10 x i8] c"src1: %s\0A\00"
@.str.5 = [10 x i8] c"src2: %s\0A\00"
@.str.6 = [10 x i8] c"src3: %s\0A\00"
@.str.7 = [18 x i8] c"\0AAfter lowercase\0A\00"
@.str.8 = [11 x i8] c"dest1: %s\0A\00"
@.str.9 = [11 x i8] c"dest2: %s\0A\00"
@.str.10 = [11 x i8] c"dest3: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca [6 x i8]
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i32 0, i32* %1
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8** %2
%8 = bitcast [6 x i8]* %3 to i8*
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8** %4
%9 = load i8*, i8** %2
%10 = call i32 @strlen(i8* %9)
%11 = sext i32 %10 to i64
%12 = mul i64 %11, 1
%13 = add i64 %12, 1
%14 = trunc i64 %13 to i32
%15 = call i8* @malloc(i32 %14)
store i8* %15, i8** %5
%16 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%17 = call i32 @strlen(i8* %16)
%18 = sext i32 %17 to i64
%19 = mul i64 %18, 1
%20 = add i64 %19, 1
%21 = trunc i64 %20 to i32
%22 = call i8* @malloc(i32 %21)
store i8* %22, i8** %6
%23 = load i8*, i8** %4
%24 = call i32 @strlen(i8* %23)
%25 = sext i32 %24 to i64
%26 = mul i64 %25, 1
%27 = add i64 %26, 1
%28 = trunc i64 %27 to i32
%29 = call i8* @malloc(i32 %28)
store i8* %29, i8** %7
%30 = load i8*, i8** %5
%31 = icmp ne i8* %30, null
%32 = zext i1 %31 to i32
%33 = call i32 @assert(i32 %32)
%34 = load i8*, i8** %6
%35 = icmp ne i8* %34, null
%36 = zext i1 %35 to i32
%37 = call i32 @assert(i32 %36)
%38 = load i8*, i8** %7
%39 = icmp ne i8* %38, null
%40 = zext i1 %39 to i32
%41 = call i32 @assert(i32 %40)
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%44 = load i8*, i8** %2
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %44)
%46 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* %46)
%48 = load i8*, i8** %4
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* %48)
%50 = load i8*, i8** %5
%51 = load i8*, i8** %2
%52 = call i32 @str_lower_case(i8* %50, i8* %51)
%53 = load i8*, i8** %6
%54 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%55 = call i32 @str_lower_case(i8* %53, i8* %54)
%56 = load i8*, i8** %7
%57 = load i8*, i8** %4
%58 = call i32 @str_lower_case(i8* %56, i8* %57)
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%61 = load i8*, i8** %5
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i8* %61)
%63 = load i8*, i8** %6
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i8* %63)
%65 = load i8*, i8** %7
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0), i8* %65)
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"HellO, WoRlD\00"
@__const.main.src2 = [6 x i8] c"hElLo\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.4 = [10 x i8] c"src1: %s\0A\00"
@.str.5 = [10 x i8] c"src2: %s\0A\00"
@.str.6 = [10 x i8] c"src3: %s\0A\00"
@.str.8 = [11 x i8] c"dest1: %s\0A\00"
@.str.9 = [11 x i8] c"dest2: %s\0A\00"
@.str.10 = [11 x i8] c"dest3: %s\0A\00"
@str = [17 x i8] c"Before lowercase\00"
@str.12 = [17 x i8] c"\0AAfter lowercase\00"
@str.13 = [17 x i8] c"================\00"
define i32 @main() {
%1 = alloca [6 x i8]
%2 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @strlen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%4 = add i32 %3, 1
%5 = tail call i8* @malloc(i32 %4)
%6 = call i32 @strlen(i8* %2)
%7 = add i32 %6, 1
%8 = call i8* @malloc(i32 %7)
%9 = call i32 @strlen(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%10 = add i32 %9, 1
%11 = call i8* @malloc(i32 %10)
%12 = icmp ne i8* %5, null
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = icmp ne i8* %8, null
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = icmp ne i8* %11, null
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.13, i64 0, i64 0))
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* %2)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%26 = call i32 @str_lower_case(i8* %5, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%27 = call i32 @str_lower_case(i8* %8, i8* %2)
%28 = call i32 @str_lower_case(i8* %11, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.12, i64 0, i64 0))
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.13, i64 0, i64 0))
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i8* %5)
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i8* %8)
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0), i8* %11)
ret i32 0
}