#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);
char *deepCopyStr(char *, int);
int /*<<< orphan*/ printf(char *);
void deepCopyStrTestA() {
  char *result = deepCopyStr("test string", 2);
  assert(result && result[0] == 't' && result[1] == 'e' && result[2] == '\0');
  printf("Test successful.\n");
}


x86 assembly (clang, -O0):
<deepCopyStrTestA>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
mov    $0x2,%esi
call   1050 <deepCopyStr@plt>
mov    %rax,-0x8(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x8(%rbp)
mov    %al,-0x9(%rbp)
je     1199 <deepCopyStrTestA+0x69>
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x74,%ecx
mov    %al,-0x9(%rbp)
jne    1199 <deepCopyStrTestA+0x69>
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%ecx
xor    %eax,%eax
cmp    $0x65,%ecx
mov    %al,-0x9(%rbp)
jne    1199 <deepCopyStrTestA+0x69>
mov    -0x8(%rbp),%rax
movsbl 0x2(%rax),%eax
cmp    $0x0,%eax
sete   %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    0xe5f(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<deepCopyStrTestA>:
push   %rax
lea    0xec8(%rip),%rdi
mov    $0x2,%esi
call   1050 <deepCopyStr@plt>
xor    %edi,%edi
test   %rax,%rax
je     115e <deepCopyStrTestA+0x2e>
cmpb   $0x74,(%rax)
jne    115e <deepCopyStrTestA+0x2e>
cmpb   $0x65,0x1(%rax)
jne    115e <deepCopyStrTestA+0x2e>
xor    %edi,%edi
cmpb   $0x0,0x2(%rax)
sete   %dil
call   1040 <assert@plt>
lea    0xea2(%rip),%rdi
pop    %rax
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"test string\00"
@.str.1 = [18 x i8] c"Test successful.\0A\00"
define void @deepCopyStrTestA() {
%1 = alloca i8*
%2 = call i8* @deepCopyStr(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 2)
store i8* %2, i8** %1
%3 = load i8*, i8** %1
%4 = icmp ne i8* %3, null
br i1 %4, label %5, label %23
5: ; preds = %0
%6 = load i8*, i8** %1
%7 = getelementptr inbounds i8, i8* %6, i64 0
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 116
br i1 %10, label %11, label %23
11: ; preds = %5
%12 = load i8*, i8** %1
%13 = getelementptr inbounds i8, i8* %12, i64 1
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 101
br i1 %16, label %17, label %23
17: ; preds = %11
%18 = load i8*, i8** %1
%19 = getelementptr inbounds i8, i8* %18, i64 2
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 0
br label %23
23: ; preds = %17, %11, %5, %0
%24 = phi i1 [ false, %11 ], [ false, %5 ], [ false, %0 ], [ %22, %17 ]
%25 = zext i1 %24 to i32
%26 = call i32 @assert(i32 %25)
%27 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"test string\00"
@str = [17 x i8] c"Test successful.\00"
define void @deepCopyStrTestA() {
%1 = tail call i8* @deepCopyStr(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 2)
%2 = icmp eq i8* %1, null
br i1 %2, label %15, label %3
3: ; preds = %0
%4 = load i8, i8* %1
%5 = icmp eq i8 %4, 116
br i1 %5, label %6, label %15
6: ; preds = %3
%7 = getelementptr inbounds i8, i8* %1, i64 1
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 101
br i1 %9, label %10, label %15
10: ; preds = %6
%11 = getelementptr inbounds i8, i8* %1, i64 2
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 0
%14 = zext i1 %13 to i32
br label %15
15: ; preds = %10, %6, %3, %0
%16 = phi i32 [ 0, %6 ], [ 0, %3 ], [ 0, %0 ], [ %14, %10 ]
%17 = tail call i32 @assert(i32 %16)
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
ret void
}