#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 len(char *);
char *makeCopy(char *);
int /*<<< orphan*/ printf(char *, ...);
char *replaceBetween(char *, int, int, char *);
char *slice(char *, int, int, int /*<<< orphan*/);
char *strip(char *);
char *toLowerCase(char *);
char *toUpperCase(char *);
int main(void) {
  printf("Unit testing has begun\n");
  char *testy = "BUNZ! ";
  printf("The string \"%s\" is %d characters long.\n", testy, len(testy));
  if (len(testy) == 6)
    printf("TEST PASSED.\n");
  char buffer2[60] = "       NARC!      ";
  char *testy2 = buffer2;
  printf("The stripped string: \"%s\"\n", strip(testy2));
  char buffer3[60] = "STUFFY!";
  char *testy3 = buffer3;
  printf("The sliced string: \"%s\"\n", slice(testy3, 1, 4, 0));
  char buffer4[60] = "I AM THE walrus.";
  char *testy4 = buffer4;
  printf("A copy of the string: \"%s\"\n", makeCopy(testy4));
  char buffer5[60] = "I AM THE walrus.";
  char *testy5 = buffer5;
  printf("A uppercase version of the string: \"%s\"\n", toUpperCase(testy5));
  char buffer6[60] = "I AM THE walrus.";
  char *testy6 = buffer6;
  printf("A lowercase version of the string: \"%s\"\n", toLowerCase(testy6));
  char buffer7[60] = "The Hello World Code!";
  char *testy7 = replaceBetween(buffer7, 5, 8, "jjj");
  printf("replaceBetween() test: \"%s\"\n", testy7);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1f0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe61(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x1f0(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <len@plt>
mov    -0x1f0(%rbp),%rsi
mov    %eax,%edx
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <len@plt>
cmp    $0x6,%eax
jne    1206 <main+0x76>
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x50(%rbp),%rdi
lea    0xf0f(%rip),%rsi
mov    $0x3c,%edx
call   1080 <memcpy@plt>
lea    -0x50(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rdi
call   1070 <strip@plt>
mov    %rax,%rsi
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0xa0(%rbp),%rdi
lea    0xf15(%rip),%rsi
mov    $0x3c,%edx
call   1080 <memcpy@plt>
lea    -0xa0(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0xa8(%rbp),%rdi
mov    $0x1,%esi
mov    $0x4,%edx
xor    %ecx,%ecx
call   1050 <slice@plt>
mov    %rax,%rsi
lea    0xdeb(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0xf0(%rbp),%rdi
lea    0xf06(%rip),%rsi
mov    $0x3c,%edx
call   1080 <memcpy@plt>
lea    -0xf0(%rbp),%rax
mov    %rax,-0xf8(%rbp)
mov    -0xf8(%rbp),%rdi
call   1040 <makeCopy@plt>
mov    %rax,%rsi
lea    0xdc1(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x140(%rbp),%rdi
lea    0xf03(%rip),%rsi
mov    $0x3c,%edx
call   1080 <memcpy@plt>
lea    -0x140(%rbp),%rax
mov    %rax,-0x148(%rbp)
mov    -0x148(%rbp),%rdi
call   10a0 <toUpperCase@plt>
mov    %rax,%rsi
lea    0xd9a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x190(%rbp),%rdi
lea    0xf00(%rip),%rsi
mov    $0x3c,%edx
call   1080 <memcpy@plt>
lea    -0x190(%rbp),%rax
mov    %rax,-0x198(%rbp)
mov    -0x198(%rbp),%rdi
call   1090 <toLowerCase@plt>
mov    %rax,%rsi
lea    0xd80(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x1e0(%rbp),%rdi
lea    0xefd(%rip),%rsi
mov    $0x3c,%edx
call   1080 <memcpy@plt>
lea    -0x1e0(%rbp),%rdi
mov    $0x5,%esi
mov    $0x8,%edx
lea    0xd72(%rip),%rcx
call   10b0 <replaceBetween@plt>
mov    %rax,-0x1e8(%rbp)
mov    -0x1e8(%rbp),%rsi
lea    0xd5c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x1f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x180,%rsp
lea    0xf53(%rip),%rdi
call   1040 <puts@plt>
lea    0xe55(%rip),%rbx
mov    %rbx,%rdi
call   1030 <len@plt>
lea    0xe4d(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
call   1030 <len@plt>
cmp    $0x6,%eax
jne    11df <main+0x4f>
lea    0xf2f(%rip),%rdi
call   1040 <puts@plt>
movups 0xf66(%rip),%xmm0
movups %xmm0,0x16c(%rsp)
movaps 0xf4b(%rip),%xmm0
movaps %xmm0,0x160(%rsp)
movaps 0xf2c(%rip),%xmm0
movaps %xmm0,0x150(%rsp)
movaps 0xf0d(%rip),%xmm0
movaps %xmm0,0x140(%rsp)
lea    0x140(%rsp),%rdi
call   1080 <strip@plt>
lea    0xe00(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
movups 0xf4c(%rip),%xmm0
movups %xmm0,0x12c(%rsp)
movaps 0xf31(%rip),%xmm0
movaps %xmm0,0x120(%rsp)
movaps 0xf12(%rip),%xmm0
movaps %xmm0,0x110(%rsp)
movaps 0xef3(%rip),%xmm0
movaps %xmm0,0x100(%rsp)
lea    0x100(%rsp),%rdi
mov    $0x1,%esi
mov    $0x4,%edx
xor    %ecx,%ecx
call   1060 <slice@plt>
lea    0xdb5(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
movups 0xf26(%rip),%xmm0
movups %xmm0,0xec(%rsp)
movaps 0xf0b(%rip),%xmm0
movaps %xmm0,0xe0(%rsp)
movaps 0xeec(%rip),%xmm0
movaps %xmm0,0xd0(%rsp)
movaps 0xecd(%rip),%xmm0
movaps %xmm0,0xc0(%rsp)
lea    0xc0(%rsp),%rdi
call   1050 <makeCopy@plt>
lea    0xd74(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
movups 0xecc(%rip),%xmm0
movups %xmm0,0xac(%rsp)
movaps 0xeb1(%rip),%xmm0
movaps %xmm0,0xa0(%rsp)
movaps 0xe92(%rip),%xmm0
movaps %xmm0,0x90(%rsp)
movaps 0xe73(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
lea    0x80(%rsp),%rdi
call   10a0 <toUpperCase@plt>
lea    0xd36(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
movups 0xe72(%rip),%xmm0
movups %xmm0,0x6c(%rsp)
movaps 0xe5a(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xe3e(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xe22(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
lea    0x40(%rsp),%rdi
call   1090 <toLowerCase@plt>
lea    0xd14(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
movups 0xe67(%rip),%xmm0
movups %xmm0,0x2c(%rsp)
movaps 0xe4f(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe33(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe17(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xcfd(%rip),%rcx
mov    %rsp,%rdi
mov    $0x5,%esi
mov    $0x8,%edx
call   10b0 <replaceBetween@plt>
lea    0xce8(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %eax,%eax
add    $0x180,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [24 x i8] c"Unit testing has begun\0A\00"
@.str.1 = [7 x i8] c"BUNZ! \00"
@.str.2 = [40 x i8] c"The string \22%s\22 is %d characters long.\0A\00"
@.str.3 = [14 x i8] c"TEST PASSED.\0A\00"
@__const.main.buffer2 = [60 x i8] c" NARC! \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str.4 = [27 x i8] c"The stripped string: \22%s\22\0A\00"
@__const.main.buffer3 = [60 x i8] c"STUFFY!\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str.5 = [25 x i8] c"The sliced string: \22%s\22\0A\00"
@__const.main.buffer4 = [60 x i8] c"I AM THE walrus.\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str.6 = [28 x i8] c"A copy of the string: \22%s\22\0A\00"
@__const.main.buffer5 = [60 x i8] c"I AM THE walrus.\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str.7 = [41 x i8] c"A uppercase version of the string: \22%s\22\0A\00"
@__const.main.buffer6 = [60 x i8] c"I AM THE walrus.\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str.8 = [41 x i8] c"A lowercase version of the string: \22%s\22\0A\00"
@__const.main.buffer7 = [60 x i8] c"The Hello World Code!\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str.9 = [4 x i8] c"jjj\00"
@.str.10 = [29 x i8] c"replaceBetween() test: \22%s\22\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca [60 x i8]
%4 = alloca i8*
%5 = alloca [60 x i8]
%6 = alloca i8*
%7 = alloca [60 x i8]
%8 = alloca i8*
%9 = alloca [60 x i8]
%10 = alloca i8*
%11 = alloca [60 x i8]
%12 = alloca i8*
%13 = alloca [60 x i8]
%14 = alloca i8*
store i32 0, i32* %1
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8** %2
%16 = load i8*, i8** %2
%17 = load i8*, i8** %2
%18 = call i32 @len(i8* %17)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i8* %16, i32 %18)
%20 = load i8*, i8** %2
%21 = call i32 @len(i8* %20)
%22 = icmp eq i32 %21, 6
br i1 %22, label %23, label %25
23: ; preds = %0
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %25
25: ; preds = %23, %0
%26 = bitcast [60 x i8]* %3 to i8*
%27 = getelementptr inbounds [60 x i8], [60 x i8]* %3, i64 0, i64 0
store i8* %27, i8** %4
%28 = load i8*, i8** %4
%29 = call i8* @strip(i8* %28)
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8* %29)
%31 = bitcast [60 x i8]* %5 to i8*
%32 = getelementptr inbounds [60 x i8], [60 x i8]* %5, i64 0, i64 0
store i8* %32, i8** %6
%33 = load i8*, i8** %6
%34 = call i8* @slice(i8* %33, i32 1, i32 4, i32 0)
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i8* %34)
%36 = bitcast [60 x i8]* %7 to i8*
%37 = getelementptr inbounds [60 x i8], [60 x i8]* %7, i64 0, i64 0
store i8* %37, i8** %8
%38 = load i8*, i8** %8
%39 = call i8* @makeCopy(i8* %38)
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i8* %39)
%41 = bitcast [60 x i8]* %9 to i8*
%42 = getelementptr inbounds [60 x i8], [60 x i8]* %9, i64 0, i64 0
store i8* %42, i8** %10
%43 = load i8*, i8** %10
%44 = call i8* @toUpperCase(i8* %43)
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.7, i64 0, i64 0), i8* %44)
%46 = bitcast [60 x i8]* %11 to i8*
%47 = getelementptr inbounds [60 x i8], [60 x i8]* %11, i64 0, i64 0
store i8* %47, i8** %12
%48 = load i8*, i8** %12
%49 = call i8* @toLowerCase(i8* %48)
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.8, i64 0, i64 0), i8* %49)
%51 = bitcast [60 x i8]* %13 to i8*
%52 = getelementptr inbounds [60 x i8], [60 x i8]* %13, i64 0, i64 0
%53 = call i8* @replaceBetween(i8* %52, i32 5, i32 8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
store i8* %53, i8** %14
%54 = load i8*, i8** %14
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0), i8* %54)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [7 x i8] c"BUNZ! \00"
@.str.2 = [40 x i8] c"The string \22%s\22 is %d characters long.\0A\00"
@__const.main.buffer2 = [60 x i8] c" NARC! \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str.4 = [27 x i8] c"The stripped string: \22%s\22\0A\00"
@__const.main.buffer3 = [60 x i8] c"STUFFY!\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str.5 = [25 x i8] c"The sliced string: \22%s\22\0A\00"
@.str.6 = [28 x i8] c"A copy of the string: \22%s\22\0A\00"
@.str.7 = [41 x i8] c"A uppercase version of the string: \22%s\22\0A\00"
@__const.main.buffer6 = [60 x i8] c"I AM THE walrus.\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str.8 = [41 x i8] c"A lowercase version of the string: \22%s\22\0A\00"
@__const.main.buffer7 = [60 x i8] c"The Hello World Code!\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str.9 = [4 x i8] c"jjj\00"
@.str.10 = [29 x i8] c"replaceBetween() test: \22%s\22\0A\00"
@str = [23 x i8] c"Unit testing has begun\00"
@str.11 = [13 x i8] c"TEST PASSED.\00"
define i32 @main() {
%1 = alloca [60 x i8]
%2 = alloca [60 x i8]
%3 = alloca [60 x i8]
%4 = alloca [60 x i8]
%5 = alloca [60 x i8]
%6 = alloca [60 x i8]
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @len(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = tail call i32 @len(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32 %10, 6
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.11, i64 0, i64 0))
br label %14
14: ; preds = %12, %0
%15 = getelementptr inbounds [60 x i8], [60 x i8]* %1, i64 0, i64 0
%16 = call i8* @strip(i8* %15)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8* %16)
%18 = getelementptr inbounds [60 x i8], [60 x i8]* %2, i64 0, i64 0
%19 = call i8* @slice(i8* %18, i32 1, i32 4, i32 0)
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i8* %19)
%21 = getelementptr inbounds [60 x i8], [60 x i8]* %3, i64 0, i64 0
%22 = call i8* @makeCopy(i8* %21)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i8* %22)
%24 = getelementptr inbounds [60 x i8], [60 x i8]* %4, i64 0, i64 0
%25 = call i8* @toUpperCase(i8* %24)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.7, i64 0, i64 0), i8* %25)
%27 = getelementptr inbounds [60 x i8], [60 x i8]* %5, i64 0, i64 0
%28 = call i8* @toLowerCase(i8* %27)
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.8, i64 0, i64 0), i8* %28)
%30 = getelementptr inbounds [60 x i8], [60 x i8]* %6, i64 0, i64 0
%31 = call i8* @replaceBetween(i8* %30, i32 5, i32 8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0), i8* %31)
ret i32 0
}