#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*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncat(char *, char *, int);
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ strncpy(char *, char *, int);
int main() {
  char str1[10] = "Hello";
  char str2[10] = "World";
  char *ptr1 = (char *)malloc(10);
  char *ptr2 = (char *)malloc(10);
  strcpy(ptr1, "CSC240");
  strncpy(ptr2, "Summer '17 THIS GETS TRUNCATED", 10);
  printf("Initial Strings: \n");
  printf("  str1 : %s, length=%d\n", str1, strlen(str1));
  printf("  str2 : %s, length=%d\n", str2, strlen(str2));
  printf("  ptr1 : %s, length=%d\n", ptr1, strlen(ptr1));
  printf("  ptr2 : %s, length=%d\n", ptr2, strlen(ptr2));
  printf("\nComparing strings: \n");
  if (strcmp(str1, "Hello") == 0)
    printf("%s and \"Hello\" are the same\n", str1);
  else
    printf("%s and \"Hello\" are different\n", str1);
  if (strncmp(str1, "Hello", 10) == 0)
    printf("%s and \"Hello\" are the same through 5 characters\n", str1);
  else
    printf("  %s and \"Hello\" are different through 5 characters\n", str1);
  if (strncmp(str1, "Hello, World!", 5) == 0)
    printf("  %s and \"Hello World!\" are the same through 5 characters\n",
           str1);
  else
    printf("  %s and \"Hello World!\" are different through 5 characters\n",
           str1);
  if (strncmp(str1, "Hello, World!", 100) == 0)
    printf("  %s and \"Hello World!\" are the same through 100 characters\n",
           str1);
  else
    printf("  %s and \"Hello World!\" are different through 100 characters\n",
           str1);
  if (strncmp(str1, str2, 10) < 0)
    printf("  %s is before %s\n", str1, str2);
  else if (strncmp(str1, str2, 10) > 0)
    printf("  %s is before %s\n", str2, str1);
  else
    printf("  %s and %s are the same\n", str1, str2);
  if (strncmp(str2, str1, 10) < 0)
    printf("  %s is before %s\n", str2, str1);
  else if (strncmp(str2, str1, 10) > 0)
    printf("  %s is before %s\n", str1, str2);
  else
    printf("  %s and %s are the same\n", str1, str2);
  printf("\nCocatenating strings: \n");
  printf("  Before: str2 : %s\n", str2);
  printf("  Before: ptr1 : %s\n", ptr1);
  strncat(str2, "!!!", 3);
  strncat(ptr1, " 2017", 3);
  printf("  After: str2 : %s\n", str2);
  printf("  AFter: ptr1 : %s\n", ptr1);
  free(ptr1);
  free(ptr2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe5a(%rip),%rax
mov    %rax,-0xe(%rbp)
mov    0xe57(%rip),%ax
mov    %ax,-0x6(%rbp)
mov    0xe4e(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xe4b(%rip),%ax
mov    %ax,-0x10(%rbp)
mov    $0xa,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    $0xa,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe22(%rip),%rsi
call   1060 <strcpy@plt>
mov    -0x28(%rbp),%rdi
lea    0xe19(%rip),%rsi
mov    $0xa,%edx
call   1040 <strncpy@plt>
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0xe(%rbp),%rax
mov    %rax,-0x48(%rbp)
lea    -0xe(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x48(%rbp),%rsi
mov    %eax,%edx
lea    0xe15(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
lea    -0x18(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x40(%rbp),%rsi
mov    %eax,%edx
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x38(%rbp),%rsi
mov    %eax,%edx
lea    0xdfb(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x30(%rbp),%rsi
mov    %eax,%edx
lea    0xdee(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0xe(%rbp),%rdi
lea    0xdfc(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
jne    12ed <main+0x15d>
lea    -0xe(%rbp),%rsi
lea    0xde8(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    12ff <main+0x16f>
lea    -0xe(%rbp),%rsi
lea    0xdee(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0xe(%rbp),%rdi
lea    0xdb9(%rip),%rsi
mov    $0xa,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%rax
jne    1335 <main+0x1a5>
lea    -0xe(%rbp),%rsi
lea    0xddb(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    1347 <main+0x1b7>
lea    -0xe(%rbp),%rsi
lea    0xdf6(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0xe(%rbp),%rdi
lea    0xe19(%rip),%rsi
mov    $0x5,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%rax
jne    137d <main+0x1ed>
lea    -0xe(%rbp),%rsi
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    138f <main+0x1ff>
lea    -0xe(%rbp),%rsi
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0xe(%rbp),%rdi
lea    0xdd1(%rip),%rsi
mov    $0x64,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%rax
jne    13c5 <main+0x235>
lea    -0xe(%rbp),%rsi
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    13d7 <main+0x247>
lea    -0xe(%rbp),%rsi
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0xe(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    $0xa,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%rax
jge    140e <main+0x27e>
lea    -0xe(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    1460 <main+0x2d0>
lea    -0xe(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    $0xa,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%rax
jle    1445 <main+0x2b5>
lea    -0x18(%rbp),%rsi
lea    -0xe(%rbp),%rdx
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    145b <main+0x2cb>
lea    -0xe(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    1460 <main+0x2d0>
lea    -0x18(%rbp),%rdi
lea    -0xe(%rbp),%rsi
mov    $0xa,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%rax
jge    1497 <main+0x307>
lea    -0x18(%rbp),%rsi
lea    -0xe(%rbp),%rdx
lea    0xde0(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    14e9 <main+0x359>
lea    -0x18(%rbp),%rdi
lea    -0xe(%rbp),%rsi
mov    $0xa,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%rax
jle    14ce <main+0x33e>
lea    -0xe(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    0xda9(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    14e4 <main+0x354>
lea    -0xe(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    0xda1(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    14e9 <main+0x359>
lea    0xda8(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0x18(%rbp),%rsi
lea    0xdaf(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xdb2(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0x18(%rbp),%rdi
lea    0xdb5(%rip),%rsi
mov    $0x3,%edx
call   1090 <strncat@plt>
mov    -0x20(%rbp),%rdi
lea    0xda4(%rip),%rsi
mov    $0x3,%edx
call   1090 <strncat@plt>
lea    -0x18(%rbp),%rsi
lea    0xd95(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xd97(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
movabs $0x6f6c6c6548,%rax
mov    %rax,0x10(%rsp)
movw   $0x0,0x18(%rsp)
movabs $0x646c726f57,%rax
mov    %rax,(%rsp)
movw   $0x0,0x8(%rsp)
mov    $0xa,%edi
call   10c0 <malloc@plt>
mov    %rax,%r15
mov    $0xa,%edi
call   10c0 <malloc@plt>
mov    %rax,%r14
lea    0xe1b(%rip),%rsi
mov    %r15,%rdi
call   1060 <strcpy@plt>
lea    0xe13(%rip),%rsi
mov    %r14,%rdi
mov    $0xa,%edx
call   1040 <strncpy@plt>
lea    0x10af(%rip),%rdi
call   1070 <puts@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1080 <strlen@plt>
lea    0xe05(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1090 <printf@plt>
mov    %rsp,%r12
mov    %r12,%rdi
call   1080 <strlen@plt>
lea    0xdff(%rip),%rdi
mov    %r12,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1090 <printf@plt>
mov    %r15,%rdi
call   1080 <strlen@plt>
lea    0xdfc(%rip),%rdi
mov    %r15,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1090 <printf@plt>
mov    %r14,%rdi
call   1080 <strlen@plt>
lea    0xdf9(%rip),%rdi
mov    %r14,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1090 <printf@plt>
lea    0x1041(%rip),%rdi
call   1070 <puts@plt>
lea    0xdf2(%rip),%r13
mov    %rbx,%rdi
mov    %r13,%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
lea    0xde3(%rip),%rax
lea    0xdf9(%rip),%rdi
cmove  %rax,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    $0xa,%edx
call   1050 <strncmp@plt>
test   %rax,%rax
lea    0xdef(%rip),%rax
lea    0xe1a(%rip),%rdi
cmove  %rax,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xe3a(%rip),%r13
mov    %rbx,%rdi
mov    %r13,%rsi
mov    $0x5,%edx
call   1050 <strncmp@plt>
test   %rax,%rax
lea    0xe2e(%rip),%rax
lea    0xe62(%rip),%rdi
cmove  %rax,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    $0x64,%edx
call   1050 <strncmp@plt>
test   %rax,%rax
lea    0xe76(%rip),%rax
lea    0xeac(%rip),%rdi
cmove  %rax,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0xa,%edx
call   1050 <strncmp@plt>
test   %rax,%rax
jns    1384 <main+0x1e4>
lea    0xec0(%rip),%rdi
jmp    13b3 <main+0x213>
lea    0x10(%rsp),%rdi
mov    %rsp,%rsi
mov    $0xa,%edx
call   1050 <strncmp@plt>
test   %rax,%rax
jle    13ac <main+0x20c>
lea    0xea0(%rip),%rdi
mov    %rsp,%rsi
lea    0x10(%rsp),%rdx
jmp    13bb <main+0x21b>
lea    0xea2(%rip),%rdi
lea    0x10(%rsp),%rsi
mov    %rsp,%rdx
xor    %eax,%eax
call   1090 <printf@plt>
mov    %rsp,%rdi
lea    0x10(%rsp),%rsi
mov    $0xa,%edx
call   1050 <strncmp@plt>
test   %rax,%rax
jns    13ea <main+0x24a>
lea    0xe62(%rip),%rdi
mov    %rsp,%rsi
lea    0x10(%rsp),%rdx
jmp    1419 <main+0x279>
mov    %rsp,%rdi
lea    0x10(%rsp),%rsi
mov    $0xa,%edx
call   1050 <strncmp@plt>
test   %rax,%rax
jle    140a <main+0x26a>
lea    0xe3a(%rip),%rdi
jmp    1411 <main+0x271>
lea    0xe44(%rip),%rdi
lea    0x10(%rsp),%rsi
mov    %rsp,%rdx
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xecb(%rip),%rdi
call   1070 <puts@plt>
lea    0xe3c(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xe3d(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xe41(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   10a0 <strncat@plt>
lea    0xe31(%rip),%rsi
mov    %r15,%rdi
mov    $0x3,%edx
call   10a0 <strncat@plt>
lea    0xe23(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xe26(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.str1 = [10 x i8] c"Hello\00\00\00\00\00"
@__const.main.str2 = [10 x i8] c"World\00\00\00\00\00"
@.str = [7 x i8] c"CSC240\00"
@.str.1 = [31 x i8] c"Summer '17 THIS GETS TRUNCATED\00"
@.str.2 = [19 x i8] c"Initial Strings: \0A\00"
@.str.3 = [24 x i8] c" str1 : %s, length=%d\0A\00"
@.str.4 = [24 x i8] c" str2 : %s, length=%d\0A\00"
@.str.5 = [24 x i8] c" ptr1 : %s, length=%d\0A\00"
@.str.6 = [24 x i8] c" ptr2 : %s, length=%d\0A\00"
@.str.7 = [22 x i8] c"\0AComparing strings: \0A\00"
@.str.8 = [6 x i8] c"Hello\00"
@.str.9 = [29 x i8] c"%s and \22Hello\22 are the same\0A\00"
@.str.10 = [30 x i8] c"%s and \22Hello\22 are different\0A\00"
@.str.11 = [50 x i8] c"%s and \22Hello\22 are the same through 5 characters\0A\00"
@.str.12 = [53 x i8] c" %s and \22Hello\22 are different through 5 characters\0A\00"
@.str.13 = [14 x i8] c"Hello, World!\00"
@.str.14 = [59 x i8] c" %s and \22Hello World!\22 are the same through 5 characters\0A\00"
@.str.15 = [60 x i8] c" %s and \22Hello World!\22 are different through 5 characters\0A\00"
@.str.16 = [61 x i8] c" %s and \22Hello World!\22 are the same through 100 characters\0A\00"
@.str.17 = [62 x i8] c" %s and \22Hello World!\22 are different through 100 characters\0A\00"
@.str.18 = [19 x i8] c" %s is before %s\0A\00"
@.str.19 = [26 x i8] c" %s and %s are the same\0A\00"
@.str.20 = [25 x i8] c"\0ACocatenating strings: \0A\00"
@.str.21 = [21 x i8] c" Before: str2 : %s\0A\00"
@.str.22 = [21 x i8] c" Before: ptr1 : %s\0A\00"
@.str.23 = [4 x i8] c"!!!\00"
@.str.24 = [6 x i8] c" 2017\00"
@.str.25 = [20 x i8] c" After: str2 : %s\0A\00"
@.str.26 = [20 x i8] c" AFter: ptr1 : %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i8]
%3 = alloca [10 x i8]
%4 = alloca i8*
%5 = alloca i8*
store i32 0, i32* %1
%6 = bitcast [10 x i8]* %2 to i8*
%7 = bitcast [10 x i8]* %3 to i8*
%8 = call i64 @malloc(i32 10)
%9 = inttoptr i64 %8 to i8*
store i8* %9, i8** %4
%10 = call i64 @malloc(i32 10)
%11 = inttoptr i64 %10 to i8*
store i8* %11, i8** %5
%12 = load i8*, i8** %4
%13 = call i32 @strcpy(i8* %12, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%14 = load i8*, i8** %5
%15 = call i32 @strncpy(i8* %14, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 10)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%17 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%18 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%19 = call i32 @strlen(i8* %18)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %17, i32 %19)
%21 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%22 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%23 = call i32 @strlen(i8* %22)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %21, i32 %23)
%25 = load i8*, i8** %4
%26 = load i8*, i8** %4
%27 = call i32 @strlen(i8* %26)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i8* %25, i32 %27)
%29 = load i8*, i8** %5
%30 = load i8*, i8** %5
%31 = call i32 @strlen(i8* %30)
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), i8* %29, i32 %31)
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0))
%34 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%35 = call i64 @strcmp(i8* %34, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %0
%38 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0), i8* %38)
br label %43
40: ; preds = %0
%41 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.10, i64 0, i64 0), i8* %41)
br label %43
43: ; preds = %40, %37
%44 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%45 = call i64 @strncmp(i8* %44, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i32 10)
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %50
47: ; preds = %43
%48 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.11, i64 0, i64 0), i8* %48)
br label %53
50: ; preds = %43
%51 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.12, i64 0, i64 0), i8* %51)
br label %53
53: ; preds = %50, %47
%54 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%55 = call i64 @strncmp(i8* %54, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.13, i64 0, i64 0), i32 5)
%56 = icmp eq i64 %55, 0
br i1 %56, label %57, label %60
57: ; preds = %53
%58 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.14, i64 0, i64 0), i8* %58)
br label %63
60: ; preds = %53
%61 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.15, i64 0, i64 0), i8* %61)
br label %63
63: ; preds = %60, %57
%64 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%65 = call i64 @strncmp(i8* %64, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.13, i64 0, i64 0), i32 100)
%66 = icmp eq i64 %65, 0
br i1 %66, label %67, label %70
67: ; preds = %63
%68 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.16, i64 0, i64 0), i8* %68)
br label %73
70: ; preds = %63
%71 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.17, i64 0, i64 0), i8* %71)
br label %73
73: ; preds = %70, %67
%74 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%75 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%76 = call i64 @strncmp(i8* %74, i8* %75, i32 10)
%77 = icmp slt i64 %76, 0
br i1 %77, label %78, label %82
78: ; preds = %73
%79 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%80 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.18, i64 0, i64 0), i8* %79, i8* %80)
br label %96
82: ; preds = %73
%83 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%84 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%85 = call i64 @strncmp(i8* %83, i8* %84, i32 10)
%86 = icmp sgt i64 %85, 0
br i1 %86, label %87, label %91
87: ; preds = %82
%88 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%89 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.18, i64 0, i64 0), i8* %88, i8* %89)
br label %95
91: ; preds = %82
%92 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%93 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.19, i64 0, i64 0), i8* %92, i8* %93)
br label %95
95: ; preds = %91, %87
br label %96
96: ; preds = %95, %78
%97 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%98 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%99 = call i64 @strncmp(i8* %97, i8* %98, i32 10)
%100 = icmp slt i64 %99, 0
br i1 %100, label %101, label %105
101: ; preds = %96
%102 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%103 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%104 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.18, i64 0, i64 0), i8* %102, i8* %103)
br label %119
105: ; preds = %96
%106 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%107 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%108 = call i64 @strncmp(i8* %106, i8* %107, i32 10)
%109 = icmp sgt i64 %108, 0
br i1 %109, label %110, label %114
110: ; preds = %105
%111 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%112 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%113 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.18, i64 0, i64 0), i8* %111, i8* %112)
br label %118
114: ; preds = %105
%115 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%116 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%117 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.19, i64 0, i64 0), i8* %115, i8* %116)
br label %118
118: ; preds = %114, %110
br label %119
119: ; preds = %118, %101
%120 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.20, i64 0, i64 0))
%121 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%122 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.21, i64 0, i64 0), i8* %121)
%123 = load i8*, i8** %4
%124 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.22, i64 0, i64 0), i8* %123)
%125 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%126 = call i32 @strncat(i8* %125, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.23, i64 0, i64 0), i32 3)
%127 = load i8*, i8** %4
%128 = call i32 @strncat(i8* %127, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.24, i64 0, i64 0), i32 3)
%129 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%130 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.25, i64 0, i64 0), i8* %129)
%131 = load i8*, i8** %4
%132 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.26, i64 0, i64 0), i8* %131)
%133 = load i8*, i8** %4
%134 = call i32 @free(i8* %133)
%135 = load i8*, i8** %5
%136 = call i32 @free(i8* %135)
ret i32 0
}

LLVM IR (-O2):
@__const.main.str1 = [10 x i8] c"Hello\00\00\00\00\00"
@__const.main.str2 = [10 x i8] c"World\00\00\00\00\00"
@.str = [7 x i8] c"CSC240\00"
@.str.1 = [31 x i8] c"Summer '17 THIS GETS TRUNCATED\00"
@.str.3 = [24 x i8] c" str1 : %s, length=%d\0A\00"
@.str.4 = [24 x i8] c" str2 : %s, length=%d\0A\00"
@.str.5 = [24 x i8] c" ptr1 : %s, length=%d\0A\00"
@.str.6 = [24 x i8] c" ptr2 : %s, length=%d\0A\00"
@.str.8 = [6 x i8] c"Hello\00"
@.str.9 = [29 x i8] c"%s and \22Hello\22 are the same\0A\00"
@.str.10 = [30 x i8] c"%s and \22Hello\22 are different\0A\00"
@.str.11 = [50 x i8] c"%s and \22Hello\22 are the same through 5 characters\0A\00"
@.str.12 = [53 x i8] c" %s and \22Hello\22 are different through 5 characters\0A\00"
@.str.13 = [14 x i8] c"Hello, World!\00"
@.str.14 = [59 x i8] c" %s and \22Hello World!\22 are the same through 5 characters\0A\00"
@.str.15 = [60 x i8] c" %s and \22Hello World!\22 are different through 5 characters\0A\00"
@.str.16 = [61 x i8] c" %s and \22Hello World!\22 are the same through 100 characters\0A\00"
@.str.17 = [62 x i8] c" %s and \22Hello World!\22 are different through 100 characters\0A\00"
@.str.18 = [19 x i8] c" %s is before %s\0A\00"
@.str.19 = [26 x i8] c" %s and %s are the same\0A\00"
@.str.21 = [21 x i8] c" Before: str2 : %s\0A\00"
@.str.22 = [21 x i8] c" Before: ptr1 : %s\0A\00"
@.str.23 = [4 x i8] c"!!!\00"
@.str.24 = [6 x i8] c" 2017\00"
@.str.25 = [20 x i8] c" After: str2 : %s\0A\00"
@.str.26 = [20 x i8] c" AFter: ptr1 : %s\0A\00"
@str = [18 x i8] c"Initial Strings: \00"
@str.27 = [21 x i8] c"\0AComparing strings: \00"
@str.28 = [24 x i8] c"\0ACocatenating strings: \00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = alloca [10 x i8]
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%5 = tail call i64 @malloc(i32 10)
%6 = inttoptr i64 %5 to i8*
%7 = tail call i64 @malloc(i32 10)
%8 = inttoptr i64 %7 to i8*
%9 = tail call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 @strncpy(i8* %8, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 10)
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%12 = call i32 @strlen(i8* %3)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %3, i32 %12)
%14 = call i32 @strlen(i8* %4)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %4, i32 %14)
%16 = call i32 @strlen(i8* %6)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i8* %6, i32 %16)
%18 = call i32 @strlen(i8* %8)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), i8* %8, i32 %18)
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.27, i64 0, i64 0))
%21 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
%23 = select i1 %22, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.10, i64 0, i64 0)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %23, i8* %3)
%25 = call i64 @strncmp(i8* %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i32 10)
%26 = icmp eq i64 %25, 0
%27 = select i1 %26, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.12, i64 0, i64 0)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %27, i8* %3)
%29 = call i64 @strncmp(i8* %3, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.13, i64 0, i64 0), i32 5)
%30 = icmp eq i64 %29, 0
%31 = select i1 %30, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.15, i64 0, i64 0)
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %31, i8* %3)
%33 = call i64 @strncmp(i8* %3, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.13, i64 0, i64 0), i32 100)
%34 = icmp eq i64 %33, 0
%35 = select i1 %34, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.17, i64 0, i64 0)
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %35, i8* %3)
%37 = call i64 @strncmp(i8* %3, i8* %4, i32 10)
%38 = icmp slt i64 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %0
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.18, i64 0, i64 0), i8* %3, i8* %4)
br label %48
41: ; preds = %0
%42 = call i64 @strncmp(i8* %3, i8* %4, i32 10)
%43 = icmp sgt i64 %42, 0
br i1 %43, label %44, label %46
44: ; preds = %41
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.18, i64 0, i64 0), i8* %4, i8* %3)
br label %48
46: ; preds = %41
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.19, i64 0, i64 0), i8* %3, i8* %4)
br label %48
48: ; preds = %44, %46, %39
%49 = call i64 @strncmp(i8* %4, i8* %3, i32 10)
%50 = icmp slt i64 %49, 0
br i1 %50, label %51, label %53
51: ; preds = %48
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.18, i64 0, i64 0), i8* %4, i8* %3)
br label %60
53: ; preds = %48
%54 = call i64 @strncmp(i8* %4, i8* %3, i32 10)
%55 = icmp sgt i64 %54, 0
br i1 %55, label %56, label %58
56: ; preds = %53
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.18, i64 0, i64 0), i8* %3, i8* %4)
br label %60
58: ; preds = %53
%59 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.19, i64 0, i64 0), i8* %3, i8* %4)
br label %60
60: ; preds = %56, %58, %51
%61 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.28, i64 0, i64 0))
%62 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.21, i64 0, i64 0), i8* %4)
%63 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.22, i64 0, i64 0), i8* %6)
%64 = call i32 @strncat(i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.23, i64 0, i64 0), i32 3)
%65 = call i32 @strncat(i8* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.24, i64 0, i64 0), i32 3)
%66 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.25, i64 0, i64 0), i8* %4)
%67 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.26, i64 0, i64 0), i8* %6)
%68 = call i32 @free(i8* %6)
%69 = call i32 @free(i8* %8)
ret i32 0
}