#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__ calloc(int, int);
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ sort_extra(int **, int *, int, int *, int *, int *, int *,
                              int, int);
int *merge(int *arr1, int *arr2, int size_a, int size_b) {
  int *merged_arr = (int *)calloc(1, sizeof(int));
  int i, j, k;
  i = 0;
  j = 0;
  k = 0;
  sort_extra(&merged_arr, &i, size_a + size_b, &k, arr2, &j, arr1, size_b,
             size_a);
  free(arr1);
  free(arr2);
  return merged_arr;
}


x86 assembly (clang, -O0):
<merge>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    $0x1,%edi
mov    $0x4,%esi
call   1040 <calloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x14(%rbp),%edx
add    -0x18(%rbp),%edx
mov    -0x10(%rbp),%r8
mov    -0x8(%rbp),%r11
mov    -0x18(%rbp),%r10d
mov    -0x14(%rbp),%eax
lea    -0x20(%rbp),%rdi
lea    -0x24(%rbp),%rsi
lea    -0x2c(%rbp),%rcx
lea    -0x28(%rbp),%r9
mov    %r11,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1050 <sort_extra@plt>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<merge>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %ecx,%r12d
mov    %edx,%ebx
mov    %rsi,%r14
mov    %rdi,%r15
mov    $0x1,%edi
mov    $0x4,%esi
call   1040 <calloc@plt>
mov    %rax,0x10(%rsp)
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
movl   $0x0,0x4(%rsp)
lea    (%r12,%rbx,1),%edx
sub    $0x8,%rsp
lea    0x18(%rsp),%rdi
lea    0x14(%rsp),%rsi
lea    0xc(%rsp),%rcx
lea    0x10(%rsp),%r9
mov    %r14,%r8
push   %rbx
push   %r12
push   %r15
call   1050 <sort_extra@plt>
add    $0x20,%rsp
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    0x10(%rsp),%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32* @merge(i32* %0, i32* %1, i32 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%13 = call i64 @calloc(i32 1, i32 4)
%14 = inttoptr i64 %13 to i32*
store i32* %14, i32** %9
store i32 0, i32* %10
store i32 0, i32* %11
store i32 0, i32* %12
%15 = load i32, i32* %7
%16 = load i32, i32* %8
%17 = add nsw i32 %15, %16
%18 = load i32*, i32** %6
%19 = load i32*, i32** %5
%20 = load i32, i32* %8
%21 = load i32, i32* %7
%22 = call i32 @sort_extra(i32** %9, i32* %10, i32 %17, i32* %12, i32* %18, i32* %11, i32* %19, i32 %20, i32 %21)
%23 = load i32*, i32** %5
%24 = call i32 @free(i32* %23)
%25 = load i32*, i32** %6
%26 = call i32 @free(i32* %25)
%27 = load i32*, i32** %9
ret i32* %27
}

LLVM IR (-O2):
define i32* @merge(i32* %0, i32* %1, i32 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = bitcast i32** %5 to i8*
%10 = tail call i64 @calloc(i32 1, i32 4)
%11 = inttoptr i64 %10 to i32*
store i32* %11, i32** %5
%12 = bitcast i32* %6 to i8*
%13 = bitcast i32* %7 to i8*
%14 = bitcast i32* %8 to i8*
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
%15 = add nsw i32 %3, %2
%16 = call i32 @sort_extra(i32** %5, i32* %6, i32 %15, i32* %8, i32* %1, i32* %7, i32* %0, i32 %3, i32 %2)
%17 = call i32 @free(i32* %0)
%18 = call i32 @free(i32* %1)
%19 = load i32*, i32** %5
ret i32* %19
}