#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 */
struct delta_index {
  int dummy;
};

/* Variables and functions */
void *create_delta(struct delta_index *, void const *, unsigned long,
                   unsigned long *, unsigned long);
struct delta_index *create_delta_index(void const *, unsigned long);
int /*<<< orphan*/ free_delta_index(struct delta_index *);
void *diff_delta(const void *src_buf, unsigned long src_bufsize,
                 const void *trg_buf, unsigned long trg_bufsize,
                 unsigned long *delta_size, unsigned long max_delta_size) {
  struct delta_index *index = create_delta_index(src_buf, src_bufsize);
  if (index) {
    void *delta =
        create_delta(index, trg_buf, trg_bufsize, delta_size, max_delta_size);
    free_delta_index(index);
    return delta;
  }
  return NULL;
}


x86 assembly (clang, -O0):
<diff_delta>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <create_delta_index@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     119f <diff_delta+0x6f>
mov    -0x40(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%r8
call   1050 <create_delta@plt>
mov    %rax,-0x48(%rbp)
mov    -0x40(%rbp),%rdi
call   1030 <free_delta_index@plt>
mov    -0x48(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11a7 <diff_delta+0x77>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<diff_delta>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %r9,%r14
mov    %r8,%r15
mov    %rcx,%r12
mov    %rdx,%r13
call   1040 <create_delta_index@plt>
test   %rax,%rax
je     1176 <diff_delta+0x46>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r13,%rsi
mov    %r12,%rdx
mov    %r15,%rcx
mov    %r14,%r8
call   1050 <create_delta@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1030 <free_delta_index@plt>
mov    %r14,%rax
jmp    1178 <diff_delta+0x48>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.delta_index = type { i32 }
define i8* @diff_delta(i8* %0, i64 %1, i8* %2, i64 %3, i64* %4, i64 %5) {
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i64*
%13 = alloca i64
%14 = alloca %struct.delta_index*
%15 = alloca i8*
store i8* %0, i8** %8
store i64 %1, i64* %9
store i8* %2, i8** %10
store i64 %3, i64* %11
store i64* %4, i64** %12
store i64 %5, i64* %13
%16 = load i8*, i8** %8
%17 = load i64, i64* %9
%18 = call %struct.delta_index* @create_delta_index(i8* %16, i64 %17)
store %struct.delta_index* %18, %struct.delta_index** %14
%19 = load %struct.delta_index*, %struct.delta_index** %14
%20 = icmp ne %struct.delta_index* %19, null
br i1 %20, label %21, label %31
21: ; preds = %6
%22 = load %struct.delta_index*, %struct.delta_index** %14
%23 = load i8*, i8** %10
%24 = load i64, i64* %11
%25 = load i64*, i64** %12
%26 = load i64, i64* %13
%27 = call i8* @create_delta(%struct.delta_index* %22, i8* %23, i64 %24, i64* %25, i64 %26)
store i8* %27, i8** %15
%28 = load %struct.delta_index*, %struct.delta_index** %14
%29 = call i32 @free_delta_index(%struct.delta_index* %28)
%30 = load i8*, i8** %15
store i8* %30, i8** %7
br label %32
31: ; preds = %6
store i8* null, i8** %7
br label %32
32: ; preds = %31, %21
%33 = load i8*, i8** %7
ret i8* %33
}

LLVM IR (-O2):
%struct.delta_index = type { i32 }
define i8* @diff_delta(i8* %0, i64 %1, i8* %2, i64 %3, i64* %4, i64 %5) {
%7 = tail call %struct.delta_index* @create_delta_index(i8* %0, i64 %1)
%8 = icmp eq %struct.delta_index* %7, null
br i1 %8, label %12, label %9
9: ; preds = %6
%10 = tail call i8* @create_delta(%struct.delta_index* %7, i8* %2, i64 %3, i64* %4, i64 %5)
%11 = tail call i32 @free_delta_index(%struct.delta_index* %7)
br label %12
12: ; preds = %6, %9
%13 = phi i8* [ %10, %9 ], [ null, %6 ]
ret i8* %13
}