#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 */
char *malloc(int);
int /*<<< orphan*/ memcpy(char *, char *, int);
char *MergeOperatorPartialMerge(void *arg, const char *key, size_t key_length,
                                const char *left_operand,
                                size_t left_operand_length,
                                const char *right_operand,
                                size_t right_operand_length,
                                unsigned char *success,
                                size_t *new_value_length) {
  *new_value_length = 4;
  *success = 1;
  char *result = malloc(4);
  memcpy(result, "fake", 4);
  return result;
}


x86 assembly (clang, -O0):
<MergeOperatorPartialMerge>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    0x20(%rbp),%rax
movq   $0x4,(%rax)
mov    0x18(%rbp),%rax
movb   $0x1,(%rax)
mov    $0x4,%edi
call   1040 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
lea    0xe89(%rip),%rsi
mov    $0x4,%edx
call   1030 <memcpy@plt>
mov    -0x38(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MergeOperatorPartialMerge>:
push   %rbx
mov    0x18(%rsp),%rax
mov    0x20(%rsp),%rcx
movq   $0x4,(%rcx)
movb   $0x1,(%rax)
mov    $0x4,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
lea    0xeb7(%rip),%rsi
mov    %rax,%rdi
mov    $0x4,%edx
call   1030 <memcpy@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"fake\00"
define i8* @MergeOperatorPartialMerge(i8* %0, i8* %1, i64 %2, i8* %3, i64 %4, i8* %5, i64 %6, i8* %7, i64* %8) {
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i64
%13 = alloca i8*
%14 = alloca i64
%15 = alloca i8*
%16 = alloca i64
%17 = alloca i8*
%18 = alloca i64*
%19 = alloca i8*
store i8* %0, i8** %10
store i8* %1, i8** %11
store i64 %2, i64* %12
store i8* %3, i8** %13
store i64 %4, i64* %14
store i8* %5, i8** %15
store i64 %6, i64* %16
store i8* %7, i8** %17
store i64* %8, i64** %18
%20 = load i64*, i64** %18
store i64 4, i64* %20
%21 = load i8*, i8** %17
store i8 1, i8* %21
%22 = call i8* @malloc(i32 4)
store i8* %22, i8** %19
%23 = load i8*, i8** %19
%24 = call i32 @memcpy(i8* %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%25 = load i8*, i8** %19
ret i8* %25
}

LLVM IR (-O2):
@.str = [5 x i8] c"fake\00"
define i8* @MergeOperatorPartialMerge(i8* nocapture readnone %0, i8* nocapture readnone %1, i64 %2, i8* nocapture readnone %3, i64 %4, i8* nocapture readnone %5, i64 %6, i8* nocapture writeonly %7, i64* nocapture writeonly %8) {
store i64 4, i64* %8
store i8 1, i8* %7
%10 = tail call dereferenceable_or_null(4) i8* @malloc(i32 4)
%11 = tail call i32 @memcpy(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
ret i8* %10
}