#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*/ printf(char *, char const *);
size_t strlen(char const *);
char tolower(char);
char toupper(char);
int main(void) {
  const char *str = "Hello, world.";
  size_t len = strlen(str);
  size_t size = len + 1;
  char upper[size];
  char lower[size];
  for (size_t i = 0; i < len; ++i) {
    char c = str[i];
    upper[i] = toupper(c);
    lower[i] = tolower(c);
  }
  upper[len] = '\0';
  lower[len] = '\0';
  printf("%s\n", str);
  printf("%s\n", upper);
  printf("%s\n", lower);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x58(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x50(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    121b <main+0xdb>
mov    -0x10(%rbp),%rax
mov    -0x40(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x41(%rbp)
movsbl -0x41(%rbp),%edi
call   1030 <toupper@plt>
mov    %al,%dl
mov    -0x58(%rbp),%rax
mov    -0x40(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
movsbl -0x41(%rbp),%edi
call   1060 <tolower@plt>
mov    %al,%dl
mov    -0x50(%rbp),%rax
mov    -0x40(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    11c2 <main+0x82>
mov    -0x50(%rbp),%rax
mov    -0x58(%rbp),%rcx
mov    -0x18(%rbp),%rdx
movb   $0x0,(%rcx,%rdx,1)
mov    -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rsi
lea    0xdd0(%rip),%rdi
call   1050 <printf@plt>
mov    -0x58(%rbp),%rsi
lea    0xdc0(%rip),%rdi
call   1050 <printf@plt>
mov    -0x50(%rbp),%rsi
lea    0xdb0(%rip),%rdi
call   1050 <printf@plt>
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
mov    $0x48,%edi
call   1030 <toupper@plt>
mov    %al,0x10(%rsp)
mov    $0x48,%edi
call   1050 <tolower@plt>
mov    %al,(%rsp)
mov    $0x65,%edi
call   1030 <toupper@plt>
mov    %al,0x11(%rsp)
mov    $0x65,%edi
call   1050 <tolower@plt>
mov    %al,0x1(%rsp)
mov    $0x6c,%edi
call   1030 <toupper@plt>
mov    %al,0x12(%rsp)
mov    $0x6c,%edi
call   1050 <tolower@plt>
mov    %al,0x2(%rsp)
mov    $0x6c,%edi
call   1030 <toupper@plt>
mov    %al,0x13(%rsp)
mov    $0x6c,%edi
call   1050 <tolower@plt>
mov    %al,0x3(%rsp)
mov    $0x6f,%edi
call   1030 <toupper@plt>
mov    %al,0x14(%rsp)
mov    $0x6f,%edi
call   1050 <tolower@plt>
mov    %al,0x4(%rsp)
mov    $0x2c,%edi
call   1030 <toupper@plt>
mov    %al,0x15(%rsp)
mov    $0x2c,%edi
call   1050 <tolower@plt>
mov    %al,0x5(%rsp)
mov    $0x20,%edi
call   1030 <toupper@plt>
mov    %al,0x16(%rsp)
mov    $0x20,%edi
call   1050 <tolower@plt>
mov    %al,0x6(%rsp)
mov    $0x77,%edi
call   1030 <toupper@plt>
mov    %al,0x17(%rsp)
mov    $0x77,%edi
call   1050 <tolower@plt>
mov    %al,0x7(%rsp)
mov    $0x6f,%edi
call   1030 <toupper@plt>
mov    %al,0x18(%rsp)
mov    $0x6f,%edi
call   1050 <tolower@plt>
mov    %al,0x8(%rsp)
mov    $0x72,%edi
call   1030 <toupper@plt>
mov    %al,0x19(%rsp)
mov    $0x72,%edi
call   1050 <tolower@plt>
mov    %al,0x9(%rsp)
mov    $0x6c,%edi
call   1030 <toupper@plt>
mov    %al,0x1a(%rsp)
mov    $0x6c,%edi
call   1050 <tolower@plt>
mov    %al,0xa(%rsp)
mov    $0x64,%edi
call   1030 <toupper@plt>
mov    %al,0x1b(%rsp)
mov    $0x64,%edi
call   1050 <tolower@plt>
mov    %al,0xb(%rsp)
mov    $0x2e,%edi
call   1030 <toupper@plt>
mov    %al,0x1c(%rsp)
mov    $0x2e,%edi
call   1050 <tolower@plt>
mov    %al,0xc(%rsp)
movb   $0x0,0x1d(%rsp)
movb   $0x0,0xd(%rsp)
lea    0xd5d(%rip),%rbx
lea    0xd48(%rip),%rsi
mov    %rbx,%rdi
call   1040 <printf@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <printf@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Hello, world.\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i8
store i32 0, i32* %1
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8** %2
%10 = load i8*, i8** %2
%11 = call i64 @strlen(i8* %10)
store i64 %11, i64* %3
%12 = load i64, i64* %3
%13 = add i64 %12, 1
store i64 %13, i64* %4
%14 = load i64, i64* %4
%15 = call i8* @llvm.stacksave()
store i8* %15, i8** %5
%16 = alloca i8, i64 %14
store i64 %14, i64* %6
%17 = load i64, i64* %4
%18 = alloca i8, i64 %17
store i64 %17, i64* %7
store i64 0, i64* %8
br label %19
19: ; preds = %36, %0
%20 = load i64, i64* %8
%21 = load i64, i64* %3
%22 = icmp ult i64 %20, %21
br i1 %22, label %23, label %39
23: ; preds = %19
%24 = load i8*, i8** %2
%25 = load i64, i64* %8
%26 = getelementptr inbounds i8, i8* %24, i64 %25
%27 = load i8, i8* %26
store i8 %27, i8* %9
%28 = load i8, i8* %9
%29 = call signext i8 @toupper(i8 signext %28)
%30 = load i64, i64* %8
%31 = getelementptr inbounds i8, i8* %16, i64 %30
store i8 %29, i8* %31
%32 = load i8, i8* %9
%33 = call signext i8 @tolower(i8 signext %32)
%34 = load i64, i64* %8
%35 = getelementptr inbounds i8, i8* %18, i64 %34
store i8 %33, i8* %35
br label %36
36: ; preds = %23
%37 = load i64, i64* %8
%38 = add i64 %37, 1
store i64 %38, i64* %8
br label %19
39: ; preds = %19
%40 = load i64, i64* %3
%41 = getelementptr inbounds i8, i8* %16, i64 %40
store i8 0, i8* %41
%42 = load i64, i64* %3
%43 = getelementptr inbounds i8, i8* %18, i64 %42
store i8 0, i8* %43
%44 = load i8*, i8** %2
%45 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %44)
%46 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%47 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%48 = load i8*, i8** %5
%49 = load i32, i32* %1
ret i32 %49
}

LLVM IR (-O2):
@.str = [14 x i8] c"Hello, world.\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca [14 x i8]
%2 = alloca [14 x i8]
%3 = tail call signext i8 @toupper(i8 signext 72)
%4 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 0
store i8 %3, i8* %4
%5 = tail call signext i8 @tolower(i8 signext 72)
%6 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 0
store i8 %5, i8* %6
%7 = tail call signext i8 @toupper(i8 signext 101)
%8 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 1
store i8 %7, i8* %8
%9 = tail call signext i8 @tolower(i8 signext 101)
%10 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 1
store i8 %9, i8* %10
%11 = tail call signext i8 @toupper(i8 signext 108)
%12 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 2
store i8 %11, i8* %12
%13 = tail call signext i8 @tolower(i8 signext 108)
%14 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 2
store i8 %13, i8* %14
%15 = tail call signext i8 @toupper(i8 signext 108)
%16 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 3
store i8 %15, i8* %16
%17 = tail call signext i8 @tolower(i8 signext 108)
%18 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 3
store i8 %17, i8* %18
%19 = tail call signext i8 @toupper(i8 signext 111)
%20 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 4
store i8 %19, i8* %20
%21 = tail call signext i8 @tolower(i8 signext 111)
%22 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 4
store i8 %21, i8* %22
%23 = tail call signext i8 @toupper(i8 signext 44)
%24 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 5
store i8 %23, i8* %24
%25 = tail call signext i8 @tolower(i8 signext 44)
%26 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 5
store i8 %25, i8* %26
%27 = tail call signext i8 @toupper(i8 signext 32)
%28 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 6
store i8 %27, i8* %28
%29 = tail call signext i8 @tolower(i8 signext 32)
%30 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 6
store i8 %29, i8* %30
%31 = tail call signext i8 @toupper(i8 signext 119)
%32 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 7
store i8 %31, i8* %32
%33 = tail call signext i8 @tolower(i8 signext 119)
%34 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 7
store i8 %33, i8* %34
%35 = tail call signext i8 @toupper(i8 signext 111)
%36 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 8
store i8 %35, i8* %36
%37 = tail call signext i8 @tolower(i8 signext 111)
%38 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 8
store i8 %37, i8* %38
%39 = tail call signext i8 @toupper(i8 signext 114)
%40 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 9
store i8 %39, i8* %40
%41 = tail call signext i8 @tolower(i8 signext 114)
%42 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 9
store i8 %41, i8* %42
%43 = tail call signext i8 @toupper(i8 signext 108)
%44 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 10
store i8 %43, i8* %44
%45 = tail call signext i8 @tolower(i8 signext 108)
%46 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 10
store i8 %45, i8* %46
%47 = tail call signext i8 @toupper(i8 signext 100)
%48 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 11
store i8 %47, i8* %48
%49 = tail call signext i8 @tolower(i8 signext 100)
%50 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 11
store i8 %49, i8* %50
%51 = tail call signext i8 @toupper(i8 signext 46)
%52 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 12
store i8 %51, i8* %52
%53 = tail call signext i8 @tolower(i8 signext 46)
%54 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 12
store i8 %53, i8* %54
%55 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 13
store i8 0, i8* %55
%56 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 13
store i8 0, i8* %56
%57 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%58 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%59 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %6)
ret i32 0
}