#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 charLastPosition(char, char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *getNegativeModelName(char *positiveModelName) {
  int pos = charLastPosition('/', positiveModelName);
  char *negName =
      (char *)malloc(sizeof(char) * (strlen(positiveModelName) + 5));
  strncpy(negName, positiveModelName, pos + 1);
  negName[pos + 1] = 0;
  strcat(negName, "NOT_");
  strcat(negName, positiveModelName + pos + 1);
  return negName;
}


x86 assembly (clang, -O0):
<getNegativeModelName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
mov    $0x2f,%edi
call   1070 <charLastPosition@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
add    $0x5,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
add    $0x1,%edx
call   1030 <strncpy@plt>
mov    -0x18(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rdi
lea    0xe47(%rip),%rsi
call   1060 <strcat@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
movslq -0xc(%rbp),%rax
add    %rax,%rsi
add    $0x1,%rsi
call   1060 <strcat@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getNegativeModelName>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r15
mov    $0x2f,%edi
mov    %r15,%rsi
call   1070 <charLastPosition@plt>
mov    %eax,%r14d
mov    %r15,%rdi
call   1040 <strlen@plt>
lea    0x5(%rax),%edi
call   1050 <malloc@plt>
mov    %rax,%rbp
movslq %r14d,%rbx
lea    0x1(%rbx),%rdx
mov    %rax,%rdi
mov    %r15,%rsi
call   1030 <strncpy@plt>
movb   $0x0,0x1(%rbp,%rbx,1)
lea    0xe65(%rip),%rsi
mov    %rbp,%rdi
call   1060 <strcat@plt>
lea    (%r15,%rbx,1),%rsi
add    $0x1,%rsi
mov    %rbp,%rdi
call   1060 <strcat@plt>
mov    %rbp,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"NOT_\00"
define i8* @getNegativeModelName(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @charLastPosition(i8 signext 47, i8* %5)
store i32 %6, i32* %3
%7 = load i8*, i8** %2
%8 = call i32 @strlen(i8* %7)
%9 = add nsw i32 %8, 5
%10 = sext i32 %9 to i64
%11 = mul i64 1, %10
%12 = trunc i64 %11 to i32
%13 = call i64 @malloc(i32 %12)
%14 = inttoptr i64 %13 to i8*
store i8* %14, i8** %4
%15 = load i8*, i8** %4
%16 = load i8*, i8** %2
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 1
%19 = call i32 @strncpy(i8* %15, i8* %16, i32 %18)
%20 = load i8*, i8** %4
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %20, i64 %23
store i8 0, i8* %24
%25 = load i8*, i8** %4
%26 = call i32 @strcat(i8* %25, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%27 = load i8*, i8** %4
%28 = load i8*, i8** %2
%29 = load i32, i32* %3
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
%32 = getelementptr inbounds i8, i8* %31, i64 1
%33 = call i32 @strcat(i8* %27, i8* %32)
%34 = load i8*, i8** %4
ret i8* %34
}

LLVM IR (-O2):
@.str = [5 x i8] c"NOT_\00"
define i8* @getNegativeModelName(i8* %0) {
%2 = tail call i32 @charLastPosition(i8 signext 47, i8* %0)
%3 = tail call i32 @strlen(i8* %0)
%4 = add nsw i32 %3, 5
%5 = tail call i64 @malloc(i32 %4)
%6 = inttoptr i64 %5 to i8*
%7 = add nsw i32 %2, 1
%8 = tail call i32 @strncpy(i8* %6, i8* %0, i32 %7)
%9 = sext i32 %7 to i64
%10 = getelementptr inbounds i8, i8* %6, i64 %9
store i8 0, i8* %10
%11 = tail call i32 @strcat(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%12 = sext i32 %2 to i64
%13 = getelementptr inbounds i8, i8* %0, i64 %12
%14 = getelementptr inbounds i8, i8* %13, i64 1
%15 = tail call i32 @strcat(i8* %6, i8* %14)
ret i8* %6
}