#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 *merge_sorted_arrays(int *, int, int *, int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int list2[4] = {2, 7, 8, 12};
  int list1[3] = {-1, 0, 10};
  int *lptr1 = list1, *lptr2 = list2;
  int *newlistptr = merge_sorted_arrays(lptr1, sizeof list1 / sizeof *lptr1,
                                        lptr2, sizeof list2 / sizeof *lptr2);
  printf("\n The new array after merging the two arrays is ...\n");
  for (long unsigned int i = 0;
       i < ((sizeof list1 / sizeof *lptr1) + (sizeof list2 / sizeof *lptr2));
       i++) {
    printf("%d ", *(newlistptr + i));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xec4(%rip),%rax
mov    %rax,-0x2c(%rbp)
mov    0xec2(%rip),%eax
mov    %eax,-0x24(%rbp)
lea    -0x2c(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rdx
mov    $0x3,%esi
mov    $0x4,%ecx
call   1040 <merge_sorted_arrays@plt>
mov    %rax,-0x48(%rbp)
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x0,-0x50(%rbp)
cmpq   $0x7,-0x50(%rbp)
jae    11cf <main+0xaf>
mov    -0x48(%rbp),%rax
mov    -0x50(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
jmp    119a <main+0x7a>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
movaps 0xec2(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
mov    0xecf(%rip),%eax
mov    %eax,0x8(%rsp)
mov    0xebc(%rip),%rax
mov    %rax,(%rsp)
mov    %rsp,%rdi
lea    0x10(%rsp),%rdx
mov    $0x3,%esi
mov    $0x4,%ecx
call   1050 <merge_sorted_arrays@plt>
mov    %rax,%rbx
lea    0xea7(%rip),%rdi
call   1030 <puts@plt>
mov    (%rbx),%esi
lea    0xe95(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x14(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.list2 = [4 x i32] [i32 2, i32 7, i32 8, i32 12]
@__const.main.list1 = [3 x i32] [i32 -1, i32 0, i32 10]
@.str = [53 x i8] c"\0A The new array after merging the two arrays is ...\0A\00"
@.str.1 = [4 x i8] c"%d \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [4 x i32]
%3 = alloca [3 x i32]
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i64
store i32 0, i32* %1
%8 = bitcast [4 x i32]* %2 to i8*
%9 = bitcast [3 x i32]* %3 to i8*
%10 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 0
store i32* %10, i32** %4
%11 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
store i32* %11, i32** %5
%12 = load i32*, i32** %4
%13 = load i32*, i32** %5
%14 = call i32* @merge_sorted_arrays(i32* %12, i32 3, i32* %13, i32 4)
store i32* %14, i32** %6
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
store i64 0, i64* %7
br label %16
16: ; preds = %25, %0
%17 = load i64, i64* %7
%18 = icmp ult i64 %17, 7
br i1 %18, label %19, label %28
19: ; preds = %16
%20 = load i32*, i32** %6
%21 = load i64, i64* %7
%22 = getelementptr inbounds i32, i32* %20, i64 %21
%23 = load i32, i32* %22
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %23)
br label %25
25: ; preds = %19
%26 = load i64, i64* %7
%27 = add i64 %26, 1
store i64 %27, i64* %7
br label %16
28: ; preds = %16
ret i32 0
}

LLVM IR (-O2):
@__const.main.list2 = [4 x i32] [i32 2, i32 7, i32 8, i32 12]
@__const.main.list1 = [3 x i32] [i32 -1, i32 0, i32 10]
@.str.1 = [4 x i8] c"%d \00"
@str = [52 x i8] c"\0A The new array after merging the two arrays is ...\00"
define i32 @main() {
%1 = alloca [4 x i32]
%2 = alloca [3 x i32]
%3 = bitcast [4 x i32]* %1 to i8*
%4 = bitcast [3 x i32]* %2 to i8*
%5 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%6 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%7 = call i32* @merge_sorted_arrays(i32* %5, i32 3, i32* %6, i32 4)
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str, i64 0, i64 0))
%9 = load i32, i32* %7
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = getelementptr inbounds i32, i32* %7, i64 1
%12 = load i32, i32* %11
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = getelementptr inbounds i32, i32* %7, i64 2
%15 = load i32, i32* %14
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds i32, i32* %7, i64 3
%18 = load i32, i32* %17
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = getelementptr inbounds i32, i32* %7, i64 4
%21 = load i32, i32* %20
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %21)
%23 = getelementptr inbounds i32, i32* %7, i64 5
%24 = load i32, i32* %23
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %24)
%26 = getelementptr inbounds i32, i32* %7, i64 6
%27 = load i32, i32* %26
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %27)
ret i32 0
}