#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*/ errAbort(char *);
int /*<<< orphan*/ memmove(char *, char *, int);
scalar_t__ startsWith(char *, char *);
int strlen(char *);
void trimIpv4MappingPrefix(char *ipStr) {
  if (!ipStr)
    errAbort("unexpected NULL ipStr in trimIpv4-mappingPrefix");
  if (startsWith("::ffff:", ipStr)) {
    int size = strlen(ipStr);
    int prefixSize = strlen("::ffff:");
    memmove(ipStr, ipStr + prefixSize, size - prefixSize + 1);
  }
}


x86 assembly (clang, -O0):
<trimIpv4MappingPrefix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1163 <trimIpv4MappingPrefix+0x23>
lea    0xea2(%rip),%rdi
call   1050 <errAbort@plt>
mov    -0x8(%rbp),%rsi
lea    0xec2(%rip),%rdi
call   1030 <startsWith@plt>
cmp    $0x0,%rax
je     11b5 <trimIpv4MappingPrefix+0x75>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0xc(%rbp)
lea    0xea0(%rip),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
movslq -0x10(%rbp),%rax
add    %rax,%rsi
mov    -0xc(%rbp),%edx
sub    -0x10(%rbp),%edx
add    $0x1,%edx
call   1060 <memmove@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<trimIpv4MappingPrefix>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
test   %rdi,%rdi
jne    1157 <trimIpv4MappingPrefix+0x17>
lea    0xeae(%rip),%rdi
call   1050 <errAbort@plt>
lea    0xed2(%rip),%rdi
mov    %rbx,%rsi
call   1030 <startsWith@plt>
test   %rax,%rax
je     119c <trimIpv4MappingPrefix+0x5c>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
lea    0xeb4(%rip),%rdi
call   1040 <strlen@plt>
cltq
lea    (%rbx,%rax,1),%rsi
sub    %eax,%ebp
add    $0x1,%ebp
mov    %rbx,%rdi
mov    %ebp,%edx
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1060 <memmove@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [48 x i8] c"unexpected NULL ipStr in trimIpv4-mappingPrefix\00"
@.str.1 = [8 x i8] c"::ffff:\00"
define void @trimIpv4MappingPrefix(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = icmp ne i8* %5, null
br i1 %6, label %9, label %7
7: ; preds = %1
%8 = call i32 @errAbort(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %7, %1
%10 = load i8*, i8** %2
%11 = call i64 @startsWith(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %27
13: ; preds = %9
%14 = load i8*, i8** %2
%15 = call i32 @strlen(i8* %14)
store i32 %15, i32* %3
%16 = call i32 @strlen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
store i32 %16, i32* %4
%17 = load i8*, i8** %2
%18 = load i8*, i8** %2
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
%22 = load i32, i32* %3
%23 = load i32, i32* %4
%24 = sub nsw i32 %22, %23
%25 = add nsw i32 %24, 1
%26 = call i32 @memmove(i8* %17, i8* %21, i32 %25)
br label %27
27: ; preds = %13, %9
ret void
}

LLVM IR (-O2):
@.str = [48 x i8] c"unexpected NULL ipStr in trimIpv4-mappingPrefix\00"
@.str.1 = [8 x i8] c"::ffff:\00"
define void @trimIpv4MappingPrefix(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 @errAbort(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %3, %1
%6 = tail call i64 @startsWith(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%7 = icmp eq i64 %6, 0
br i1 %7, label %16, label %8
8: ; preds = %5
%9 = tail call i32 @strlen(i8* %0)
%10 = tail call i32 @strlen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = add i32 %9, 1
%14 = sub i32 %13, %10
%15 = tail call i32 @memmove(i8* %0, i8* %12, i32 %14)
br label %16
16: ; preds = %8, %5
ret void
}