#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ memcpy(char *, char const *, int);
int strlen(char const *);
void assignConfigString(char **target, const char *source, const char *filter) {
  int sizeSource = strlen(source);
  int sizeFilter = strlen(filter);
  int sizeNew = sizeSource - sizeFilter;
  *target = (char *)malloc(sizeNew * sizeof(char));
  memcpy(*target, source + sizeFilter, sizeNew);
  (*target)[sizeNew] = '\0';
}


x86 assembly (clang, -O0):
<assignConfigString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
sub    -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
movslq -0x24(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rsi
movslq -0x20(%rbp),%rax
add    %rax,%rsi
mov    -0x24(%rbp),%edx
call   1040 <memcpy@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movslq -0x24(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<assignConfigString>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%r15
mov    %rsi,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebx
sub    %eax,%ebp
movslq %ebp,%rbp
mov    %ebp,%edi
call   1050 <malloc@plt>
mov    %rax,(%r15)
movslq %ebx,%rsi
add    %r12,%rsi
mov    %rax,%rdi
mov    %ebp,%edx
call   1040 <memcpy@plt>
mov    (%r15),%rax
movb   $0x0,(%rax,%rbp,1)
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @assignConfigString(i8** %0, i8* %1, i8* %2) {
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8** %0, i8*** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%10 = load i8*, i8** %5
%11 = call i32 @strlen(i8* %10)
store i32 %11, i32* %7
%12 = load i8*, i8** %6
%13 = call i32 @strlen(i8* %12)
store i32 %13, i32* %8
%14 = load i32, i32* %7
%15 = load i32, i32* %8
%16 = sub nsw i32 %14, %15
store i32 %16, i32* %9
%17 = load i32, i32* %9
%18 = sext i32 %17 to i64
%19 = mul i64 %18, 1
%20 = trunc i64 %19 to i32
%21 = call i64 @malloc(i32 %20)
%22 = inttoptr i64 %21 to i8*
%23 = load i8**, i8*** %4
store i8* %22, i8** %23
%24 = load i8**, i8*** %4
%25 = load i8*, i8** %24
%26 = load i8*, i8** %5
%27 = load i32, i32* %8
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
%30 = load i32, i32* %9
%31 = call i32 @memcpy(i8* %25, i8* %29, i32 %30)
%32 = load i8**, i8*** %4
%33 = load i8*, i8** %32
%34 = load i32, i32* %9
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
store i8 0, i8* %36
ret void
}

LLVM IR (-O2):
define void @assignConfigString(i8** nocapture %0, i8* %1, i8* %2) {
%4 = tail call i32 @strlen(i8* %1)
%5 = tail call i32 @strlen(i8* %2)
%6 = sub nsw i32 %4, %5
%7 = sext i32 %6 to i64
%8 = tail call i64 @malloc(i32 %6)
%9 = inttoptr i64 %8 to i8*
store i8* %9, i8** %0
%10 = sext i32 %5 to i64
%11 = getelementptr inbounds i8, i8* %1, i64 %10
%12 = tail call i32 @memcpy(i8* %9, i8* %11, i32 %6)
%13 = load i8*, i8** %0
%14 = getelementptr inbounds i8, i8* %13, i64 %7
store i8 0, i8* %14
ret void
}