#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*/ merge(int *, int *, int);
int /*<<< orphan*/ print_array(int *);
int /*<<< orphan*/ printf(char *);
int main() {
  int a[10] = {-1, 2, 4, 6, 0, 0, 0, 0, 0, 0};
  int b[6] = {1, 3, 5, 7, 8, 9};
  int size_a = 4;
  printf("A: ");
  print_array(a);
  printf("B: ");
  print_array(b);
  merge(a, b, size_a);
  printf("A2: ");
  print_array(a);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1050 <memset@plt>
movl   $0xffffffff,-0x30(%rbp)
movl   $0x2,-0x2c(%rbp)
movl   $0x4,-0x28(%rbp)
movl   $0x6,-0x24(%rbp)
mov    0xe7e(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xe7b(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    0xe78(%rip),%rax
mov    %rax,-0x40(%rbp)
movl   $0x4,-0x54(%rbp)
lea    0xe6e(%rip),%rdi
call   1040 <printf@plt>
lea    -0x30(%rbp),%rdi
call   1030 <print_array@plt>
lea    0xe5d(%rip),%rdi
call   1040 <printf@plt>
lea    -0x50(%rbp),%rdi
call   1030 <print_array@plt>
lea    -0x30(%rbp),%rdi
lea    -0x50(%rbp),%rsi
mov    -0x54(%rbp),%edx
call   1060 <merge@plt>
lea    0xe3c(%rip),%rdi
call   1040 <printf@plt>
lea    -0x30(%rbp),%rdi
call   1030 <print_array@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x48,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
movq   $0x0,0x40(%rsp)
movaps 0xeb1(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
mov    0xec5(%rip),%rax
mov    %rax,0x10(%rsp)
movaps 0xea9(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xeb6(%rip),%rdi
call   1040 <printf@plt>
lea    0x20(%rsp),%r14
mov    %r14,%rdi
call   1030 <print_array@plt>
lea    0xea1(%rip),%rdi
call   1040 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <print_array@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x4,%edx
call   1050 <merge@plt>
lea    0xe7e(%rip),%rdi
call   1040 <printf@plt>
mov    %r14,%rdi
call   1030 <print_array@plt>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.b = [6 x i32] [i32 1, i32 3, i32 5, i32 7, i32 8, i32 9]
@.str = [4 x i8] c"A: \00"
@.str.1 = [4 x i8] c"B: \00"
@.str.2 = [5 x i8] c"A2: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i32]
%3 = alloca [6 x i32]
%4 = alloca i32
store i32 0, i32* %1
%5 = bitcast [10 x i32]* %2 to i8*
%6 = bitcast i8* %5 to [10 x i32]*
%7 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i32 0, i32 0
store i32 -1, i32* %7
%8 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i32 0, i32 1
store i32 2, i32* %8
%9 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i32 0, i32 2
store i32 4, i32* %9
%10 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i32 0, i32 3
store i32 6, i32* %10
%11 = bitcast [6 x i32]* %3 to i8*
store i32 4, i32* %4
%12 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%13 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%14 = call i32 @print_array(i32* %13)
%15 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%16 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 0
%17 = call i32 @print_array(i32* %16)
%18 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%19 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 0
%20 = load i32, i32* %4
%21 = call i32 @merge(i32* %18, i32* %19, i32 %20)
%22 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%23 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%24 = call i32 @print_array(i32* %23)
ret i32 0
}

LLVM IR (-O2):
@__const.main.b = [6 x i32] [i32 1, i32 3, i32 5, i32 7, i32 8, i32 9]
@.str = [4 x i8] c"A: \00"
@.str.1 = [4 x i8] c"B: \00"
@.str.2 = [5 x i8] c"A2: \00"
define i32 @main() {
%1 = alloca [10 x i32]
%2 = alloca [6 x i32]
%3 = bitcast [10 x i32]* %1 to i8*
%4 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 4
%5 = bitcast i32* %4 to i8*
%6 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%7 = bitcast [10 x i32]* %1 to <4 x i32>*
store <4 x i32> <i32 -1, i32 2, i32 4, i32 6>, <4 x i32>* %7
%8 = bitcast [6 x i32]* %2 to i8*
%9 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @print_array(i32* %6)
%11 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%12 = getelementptr inbounds [6 x i32], [6 x i32]* %2, i64 0, i64 0
%13 = call i32 @print_array(i32* %12)
%14 = call i32 @merge(i32* %6, i32* %12, i32 4)
%15 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 @print_array(i32* %6)
ret i32 0
}