#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*/ sscanf(char const *, char *, char *);
char *strchr(char *, char);
int strlen(char const *);
scalar_t__ vrna_alloc(int);
int /*<<< orphan*/ vrna_message_error(char *);
char *vrna_cut_point_remove(const char *string, int *cp) {
  char *pos, *copy = NULL;
  *cp = -1;
  if (string) {
    copy = (char *)vrna_alloc(strlen(string) + 1);
    (void)sscanf(string, "%s", copy);
    pos = strchr(copy, '&');
    if (pos) {
      *cp = (int)(pos - copy) + 1;
      if (*cp >= strlen(copy))
        *cp = -1;
      if (strchr(pos + 1, '&'))
        vrna_message_error("more than one cut-point in input");
      for (; *pos; pos++)
        *pos = *(pos + 1);
    }
  }
  return copy;
}


x86 assembly (clang, -O0):
<vrna_cut_point_remove>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movl   $0xffffffff,(%rax)
cmpq   $0x0,-0x8(%rbp)
je     1266 <vrna_cut_point_remove+0x116>
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%edi
add    $0x1,%edi
call   1070 <vrna_alloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xe5d(%rip),%rsi
call   1060 <sscanf@plt>
mov    -0x20(%rbp),%rdi
mov    $0x26,%esi
call   1040 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1261 <vrna_cut_point_remove+0x111>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%ecx
add    $0x1,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cmp    %ecx,%eax
jl     1204 <vrna_cut_point_remove+0xb4>
mov    -0x10(%rbp),%rax
movl   $0xffffffff,(%rax)
mov    -0x18(%rbp),%rdi
add    $0x1,%rdi
mov    $0x26,%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
je     122c <vrna_cut_point_remove+0xdc>
lea    0xddc(%rip),%rdi
call   1050 <vrna_message_error@plt>
jmp    1231 <vrna_cut_point_remove+0xe1>
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     125c <vrna_cut_point_remove+0x10c>
mov    -0x18(%rbp),%rax
mov    0x1(%rax),%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1231 <vrna_cut_point_remove+0xe1>
jmp    1261 <vrna_cut_point_remove+0x111>
jmp    1266 <vrna_cut_point_remove+0x116>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vrna_cut_point_remove>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
movl   $0xffffffff,(%rsi)
test   %rdi,%rdi
je     1200 <vrna_cut_point_remove+0xb0>
mov    %rsi,%r15
mov    %rdi,%rbx
call   1030 <strlen@plt>
lea    0x1(%rax),%edi
call   1070 <vrna_alloc@plt>
mov    %rax,%r14
lea    0xe7c(%rip),%rsi
mov    %rbx,%rdi
mov    %rax,%rdx
call   1060 <sscanf@plt>
mov    %r14,%rdi
mov    $0x26,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1203 <vrna_cut_point_remove+0xb3>
mov    %rax,%rbx
mov    %rax,%r12
mov    %r12d,%ebp
sub    %r14d,%ebp
add    $0x1,%ebp
mov    %ebp,(%r15)
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    %eax,%ebp
jl     11c6 <vrna_cut_point_remove+0x76>
movl   $0xffffffff,(%r15)
add    $0x1,%rbx
mov    %rbx,%rdi
mov    $0x26,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     11e8 <vrna_cut_point_remove+0x98>
lea    0xe20(%rip),%rdi
call   1050 <vrna_message_error@plt>
cmpb   $0x0,(%r12)
je     1203 <vrna_cut_point_remove+0xb3>
nop
movzbl (%rbx),%eax
mov    %al,-0x1(%rbx)
add    $0x1,%rbx
test   %al,%al
jne    11f0 <vrna_cut_point_remove+0xa0>
jmp    1203 <vrna_cut_point_remove+0xb3>
xor    %r14d,%r14d
mov    %r14,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [33 x i8] c"more than one cut-point in input\00"
define i8* @vrna_cut_point_remove(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %3
store i32* %1, i32** %4
store i8* null, i8** %6
%7 = load i32*, i32** %4
store i32 -1, i32* %7
%8 = load i8*, i8** %3
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %61
10: ; preds = %2
%11 = load i8*, i8** %3
%12 = call i32 @strlen(i8* %11)
%13 = add nsw i32 %12, 1
%14 = call i64 @vrna_alloc(i32 %13)
%15 = inttoptr i64 %14 to i8*
store i8* %15, i8** %6
%16 = load i8*, i8** %3
%17 = load i8*, i8** %6
%18 = call i32 @sscanf(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = load i8*, i8** %6
%20 = call i8* @strchr(i8* %19, i8 signext 38)
store i8* %20, i8** %5
%21 = load i8*, i8** %5
%22 = icmp ne i8* %21, null
br i1 %22, label %23, label %60
23: ; preds = %10
%24 = load i8*, i8** %5
%25 = load i8*, i8** %6
%26 = ptrtoint i8* %24 to i64
%27 = ptrtoint i8* %25 to i64
%28 = sub i64 %26, %27
%29 = trunc i64 %28 to i32
%30 = add nsw i32 %29, 1
%31 = load i32*, i32** %4
store i32 %30, i32* %31
%32 = load i32*, i32** %4
%33 = load i32, i32* %32
%34 = load i8*, i8** %6
%35 = call i32 @strlen(i8* %34)
%36 = icmp sge i32 %33, %35
br i1 %36, label %37, label %39
37: ; preds = %23
%38 = load i32*, i32** %4
store i32 -1, i32* %38
br label %39
39: ; preds = %37, %23
%40 = load i8*, i8** %5
%41 = getelementptr inbounds i8, i8* %40, i64 1
%42 = call i8* @strchr(i8* %41, i8 signext 38)
%43 = icmp ne i8* %42, null
br i1 %43, label %44, label %46
44: ; preds = %39
%45 = call i32 @vrna_message_error(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
br label %46
46: ; preds = %44, %39
br label %47
47: ; preds = %56, %46
%48 = load i8*, i8** %5
%49 = load i8, i8* %48
%50 = icmp ne i8 %49, 0
br i1 %50, label %51, label %59
51: ; preds = %47
%52 = load i8*, i8** %5
%53 = getelementptr inbounds i8, i8* %52, i64 1
%54 = load i8, i8* %53
%55 = load i8*, i8** %5
store i8 %54, i8* %55
br label %56
56: ; preds = %51
%57 = load i8*, i8** %5
%58 = getelementptr inbounds i8, i8* %57, i32 1
store i8* %58, i8** %5
br label %47
59: ; preds = %47
br label %60
60: ; preds = %59, %10
br label %61
61: ; preds = %60, %2
%62 = load i8*, i8** %6
ret i8* %62
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [33 x i8] c"more than one cut-point in input\00"
define i8* @vrna_cut_point_remove(i8* %0, i32* nocapture writeonly %1) {
store i32 -1, i32* %1
%3 = icmp eq i8* %0, null
br i1 %3, label %34, label %4
4: ; preds = %2
%5 = tail call i32 @strlen(i8* %0)
%6 = add nsw i32 %5, 1
%7 = tail call i64 @vrna_alloc(i32 %6)
%8 = inttoptr i64 %7 to i8*
%9 = tail call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = tail call i8* @strchr(i8* dereferenceable(1) %8, i8 signext 38)
%11 = icmp eq i8* %10, null
br i1 %11, label %34, label %12
12: ; preds = %4
%13 = ptrtoint i8* %10 to i64
%14 = sub i64 %13, %7
%15 = trunc i64 %14 to i32
%16 = add nsw i32 %15, 1
store i32 %16, i32* %1
%17 = tail call i32 @strlen(i8* %8)
%18 = icmp slt i32 %16, %17
br i1 %18, label %20, label %19
19: ; preds = %12
store i32 -1, i32* %1
br label %20
20: ; preds = %19, %12
%21 = getelementptr inbounds i8, i8* %10, i64 1
%22 = tail call i8* @strchr(i8* %21, i8 signext 38)
%23 = icmp eq i8* %22, null
br i1 %23, label %26, label %24
24: ; preds = %20
%25 = tail call i32 @vrna_message_error(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
br label %26
26: ; preds = %24, %20
%27 = load i8, i8* %10
%28 = icmp eq i8 %27, 0
br i1 %28, label %34, label %29
29: ; preds = %26, %29
%30 = phi i8* [ %31, %29 ], [ %10, %26 ]
%31 = getelementptr inbounds i8, i8* %30, i64 1
%32 = load i8, i8* %31
store i8 %32, i8* %30
%33 = icmp eq i8 %32, 0
br i1 %33, label %34, label %29
34: ; preds = %29, %26, %4, %2
%35 = phi i8* [ %8, %4 ], [ null, %2 ], [ %8, %26 ], [ %8, %29 ]
ret i8* %35
}