#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*/ arglist_free(char *, char **);
char **argsplit(char *, char **, int *);
char *concat(char *, char const *, int /*<<< orphan*/ *);
char *context_find(char *);
int /*<<< orphan*/ free(char *);
char *getcpy(char *);
void merge_profile_entry(const char *addr, const char *host, char *vec[],
                         int *vecp) {
  char *addr_entry = concat("sendfrom-", addr, NULL);
  char *profile_entry = context_find(addr_entry);
  free(addr_entry);
  if (profile_entry == NULL) {
    char *host_entry = concat("sendfrom-", host, NULL);
    profile_entry = context_find(host_entry);
    free(host_entry);
  }
  if (profile_entry && *profile_entry) {
    int profile_vecp;
    char *file;
    char **profile_vec = argsplit(profile_entry, &file, &profile_vecp);
    int i;
    for (i = 0; i < profile_vecp; ++i) {
      vec[(*vecp)++] = getcpy(profile_vec[i]);
    }
    arglist_free(file, profile_vec);
  }
}


x86 assembly (clang, -O0):
<merge_profile_entry>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe7d(%rip),%rdi
xor    %eax,%eax
mov    %eax,%edx
call   1040 <concat@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1060 <context_find@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x30(%rbp)
jne    11df <merge_profile_entry+0x7f>
mov    -0x10(%rbp),%rsi
lea    0xe44(%rip),%rdi
xor    %eax,%eax
mov    %eax,%edx
call   1040 <concat@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
call   1060 <context_find@plt>
mov    %rax,-0x30(%rbp)
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x30(%rbp)
je     1269 <merge_profile_entry+0x109>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1269 <merge_profile_entry+0x109>
mov    -0x30(%rbp),%rdi
lea    -0x48(%rbp),%rsi
lea    -0x3c(%rbp),%rdx
call   1070 <argsplit@plt>
mov    %rax,-0x50(%rbp)
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    125c <merge_profile_entry+0xfc>
mov    -0x50(%rbp),%rax
movslq -0x54(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <getcpy@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rsi
mov    (%rsi),%ecx
mov    %ecx,%edi
add    $0x1,%edi
mov    %edi,(%rsi)
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1216 <merge_profile_entry+0xb6>
mov    -0x48(%rbp),%rdi
mov    -0x50(%rbp),%rsi
call   1080 <arglist_free@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<merge_profile_entry>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rcx,%r15
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%rsi
lea    0xe80(%rip),%rdi
xor    %edx,%edx
call   1040 <concat@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <context_find@plt>
mov    %rax,%r13
mov    %rbx,%rdi
call   1030 <free@plt>
test   %r13,%r13
jne    11ce <merge_profile_entry+0x6e>
lea    0xe57(%rip),%rdi
mov    %r12,%rsi
xor    %edx,%edx
call   1040 <concat@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <context_find@plt>
mov    %rax,%r13
mov    %rbx,%rdi
call   1030 <free@plt>
test   %r13,%r13
je     1231 <merge_profile_entry+0xd1>
cmpb   $0x0,0x0(%r13)
je     1231 <merge_profile_entry+0xd1>
lea    0x8(%rsp),%rsi
lea    0x4(%rsp),%rdx
mov    %r13,%rdi
call   1070 <argsplit@plt>
mov    %rax,%r12
cmpl   $0x0,0x4(%rsp)
jle    1224 <merge_profile_entry+0xc4>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r12,%rbx,8),%rdi
call   1050 <getcpy@plt>
movslq (%r15),%rcx
lea    0x1(%rcx),%edx
mov    %edx,(%r15)
mov    %rax,(%r14,%rcx,8)
add    $0x1,%rbx
movslq 0x4(%rsp),%rax
cmp    %rax,%rbx
jl     1200 <merge_profile_entry+0xa0>
mov    0x8(%rsp),%rdi
mov    %r12,%rsi
call   1080 <arglist_free@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [10 x i8] c"sendfrom-\00"
define void @merge_profile_entry(i8* %0, i8* %1, i8** %2, i32* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8**
%8 = alloca i32*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i8**
%15 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8** %2, i8*** %7
store i32* %3, i32** %8
%16 = load i8*, i8** %5
%17 = call i8* @concat(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %16, i32* null)
store i8* %17, i8** %9
%18 = load i8*, i8** %9
%19 = call i8* @context_find(i8* %18)
store i8* %19, i8** %10
%20 = load i8*, i8** %9
%21 = call i32 @free(i8* %20)
%22 = load i8*, i8** %10
%23 = icmp eq i8* %22, null
br i1 %23, label %24, label %31
24: ; preds = %4
%25 = load i8*, i8** %6
%26 = call i8* @concat(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %25, i32* null)
store i8* %26, i8** %11
%27 = load i8*, i8** %11
%28 = call i8* @context_find(i8* %27)
store i8* %28, i8** %10
%29 = load i8*, i8** %11
%30 = call i32 @free(i8* %29)
br label %31
31: ; preds = %24, %4
%32 = load i8*, i8** %10
%33 = icmp ne i8* %32, null
br i1 %33, label %34, label %66
34: ; preds = %31
%35 = load i8*, i8** %10
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %66
39: ; preds = %34
%40 = load i8*, i8** %10
%41 = call i8** @argsplit(i8* %40, i8** %13, i32* %12)
store i8** %41, i8*** %14
store i32 0, i32* %15
br label %42
42: ; preds = %59, %39
%43 = load i32, i32* %15
%44 = load i32, i32* %12
%45 = icmp slt i32 %43, %44
br i1 %45, label %46, label %62
46: ; preds = %42
%47 = load i8**, i8*** %14
%48 = load i32, i32* %15
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8*, i8** %47, i64 %49
%51 = load i8*, i8** %50
%52 = call i8* @getcpy(i8* %51)
%53 = load i8**, i8*** %7
%54 = load i32*, i32** %8
%55 = load i32, i32* %54
%56 = add nsw i32 %55, 1
store i32 %56, i32* %54
%57 = sext i32 %55 to i64
%58 = getelementptr inbounds i8*, i8** %53, i64 %57
store i8* %52, i8** %58
br label %59
59: ; preds = %46
%60 = load i32, i32* %15
%61 = add nsw i32 %60, 1
store i32 %61, i32* %15
br label %42
62: ; preds = %42
%63 = load i8*, i8** %13
%64 = load i8**, i8*** %14
%65 = call i32 @arglist_free(i8* %63, i8** %64)
br label %66
66: ; preds = %62, %34, %31
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"sendfrom-\00"
define void @merge_profile_entry(i8* %0, i8* %1, i8** nocapture writeonly %2, i32* nocapture %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = tail call i8* @concat(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %0, i32* null)
%8 = tail call i8* @context_find(i8* %7)
%9 = tail call i32 @free(i8* %7)
%10 = icmp eq i8* %8, null
br i1 %10, label %11, label %16
11: ; preds = %4
%12 = tail call i8* @concat(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %1, i32* null)
%13 = tail call i8* @context_find(i8* %12)
%14 = tail call i32 @free(i8* %12)
%15 = icmp eq i8* %13, null
br i1 %15, label %42, label %16
16: ; preds = %4, %11
%17 = phi i8* [ %13, %11 ], [ %8, %4 ]
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 0
br i1 %19, label %42, label %20
20: ; preds = %16
%21 = bitcast i32* %5 to i8*
%22 = bitcast i8** %6 to i8*
%23 = call i8** @argsplit(i8* %17, i8** %6, i32* %5)
%24 = load i32, i32* %5
%25 = icmp sgt i32 %24, 0
br i1 %25, label %26, label %39
26: ; preds = %20, %26
%27 = phi i64 [ %35, %26 ], [ 0, %20 ]
%28 = getelementptr inbounds i8*, i8** %23, i64 %27
%29 = load i8*, i8** %28
%30 = call i8* @getcpy(i8* %29)
%31 = load i32, i32* %3
%32 = add nsw i32 %31, 1
store i32 %32, i32* %3
%33 = sext i32 %31 to i64
%34 = getelementptr inbounds i8*, i8** %2, i64 %33
store i8* %30, i8** %34
%35 = add nuw nsw i64 %27, 1
%36 = load i32, i32* %5
%37 = sext i32 %36 to i64
%38 = icmp slt i64 %35, %37
br i1 %38, label %26, label %39
39: ; preds = %26, %20
%40 = load i8*, i8** %6
%41 = call i32 @arglist_free(i8* %40, i8** %23)
br label %42
42: ; preds = %39, %16, %11
ret void
}