#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*/ strcat(char *, char const *);
char *strdup(char const *);
int strlen(char const *);
int /*<<< orphan*/ strncpy(char *, char const *, int);
scalar_t__ vrna_alloc(int);
char *vrna_cut_point_insert(const char *string, int cp) {
  char *ctmp;
  int len;
  if (cp > 0) {
    len = strlen(string);
    ctmp = (char *)vrna_alloc((len + 2) * sizeof(char));
    (void)strncpy(ctmp, string, cp - 1);
    ctmp[cp - 1] = '&';
    (void)strcat(ctmp, string + cp - 1);
  } else {
    ctmp = strdup(string);
  }
  return ctmp;
}


x86 assembly (clang, -O0):
<vrna_cut_point_insert>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    11cd <vrna_cut_point_insert+0x7d>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x2,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1050 <vrna_alloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
sub    $0x1,%edx
call   1030 <strncpy@plt>
mov    -0x18(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x26,(%rax,%rcx,1)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
movslq -0xc(%rbp),%rax
add    %rax,%rsi
add    $0xffffffffffffffff,%rsi
call   1060 <strcat@plt>
jmp    11da <vrna_cut_point_insert+0x8a>
mov    -0x8(%rbp),%rdi
call   1070 <strdup@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vrna_cut_point_insert>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
test   %esi,%esi
jle    11ae <vrna_cut_point_insert+0x5e>
mov    %esi,%r15d
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    0x2(%rax),%edi
call   1050 <vrna_alloc@plt>
mov    %rax,%rbx
lea    -0x1(%r15),%r12d
mov    %rax,%rdi
mov    %r14,%rsi
mov    %r12d,%edx
call   1030 <strncpy@plt>
movb   $0x26,(%rbx,%r12,1)
mov    %r15d,%eax
lea    (%r14,%rax,1),%rsi
add    $0xffffffffffffffff,%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1070 <strdup@plt>

LLVM IR (-O0):
define i8* @vrna_cut_point_insert(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %36
9: ; preds = %2
%10 = load i8*, i8** %3
%11 = call i32 @strlen(i8* %10)
store i32 %11, i32* %6
%12 = load i32, i32* %6
%13 = add nsw i32 %12, 2
%14 = sext i32 %13 to i64
%15 = mul i64 %14, 1
%16 = trunc i64 %15 to i32
%17 = call i64 @vrna_alloc(i32 %16)
%18 = inttoptr i64 %17 to i8*
store i8* %18, i8** %5
%19 = load i8*, i8** %5
%20 = load i8*, i8** %3
%21 = load i32, i32* %4
%22 = sub nsw i32 %21, 1
%23 = call i32 @strncpy(i8* %19, i8* %20, i32 %22)
%24 = load i8*, i8** %5
%25 = load i32, i32* %4
%26 = sub nsw i32 %25, 1
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %24, i64 %27
store i8 38, i8* %28
%29 = load i8*, i8** %5
%30 = load i8*, i8** %3
%31 = load i32, i32* %4
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
%34 = getelementptr inbounds i8, i8* %33, i64 -1
%35 = call i32 @strcat(i8* %29, i8* %34)
br label %39
36: ; preds = %2
%37 = load i8*, i8** %3
%38 = call i8* @strdup(i8* %37)
store i8* %38, i8** %5
br label %39
39: ; preds = %36, %9
%40 = load i8*, i8** %5
ret i8* %40
}

LLVM IR (-O2):
define i8* @vrna_cut_point_insert(i8* %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %17
4: ; preds = %2
%5 = tail call i32 @strlen(i8* %0)
%6 = add nsw i32 %5, 2
%7 = tail call i64 @vrna_alloc(i32 %6)
%8 = inttoptr i64 %7 to i8*
%9 = add nsw i32 %1, -1
%10 = tail call i32 @strncpy(i8* %8, i8* %0, i32 %9)
%11 = zext i32 %9 to i64
%12 = getelementptr inbounds i8, i8* %8, i64 %11
store i8 38, i8* %12
%13 = zext i32 %1 to i64
%14 = getelementptr inbounds i8, i8* %0, i64 %13
%15 = getelementptr inbounds i8, i8* %14, i64 -1
%16 = tail call i32 @strcat(i8* %8, i8* %15)
br label %19
17: ; preds = %2
%18 = tail call i8* @strdup(i8* %0)
br label %19
19: ; preds = %17, %4
%20 = phi i8* [ %8, %4 ], [ %18, %17 ]
ret i8* %20
}