#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);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int size1, size2, i;
  scanf("%d\n", &size1);
  int arr1[size1];
  for (i = 0; i < size1; i++) {
    scanf("%d ", &arr1[i]);
  }
  scanf("%d\n", &size2);
  int arr2[size2];
  for (i = 0; i < size2; i++) {
    scanf("%d ", &arr2[i]);
  }
  merge(arr1, size1, arr2, size2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11a2 <main+0x82>
mov    -0x30(%rbp),%rsi
movslq -0x10(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe75(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    116d <main+0x4d>
lea    0xe57(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    120e <main+0xee>
mov    -0x38(%rbp),%rsi
movslq -0x10(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe09(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11d9 <main+0xb9>
mov    -0x38(%rbp),%rdx
mov    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%ecx
call   1030 <merge@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xec8(%rip),%rdi
lea    -0x2c(%rbp),%rsi
call   1040 <scanf@plt>
mov    %rsp,%r13
mov    -0x2c(%rbp),%eax
mov    %rsp,%r14
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
cmpl   $0x0,-0x2c(%rbp)
jle    118c <main+0x6c>
xor    %r12d,%r12d
lea    0xe98(%rip),%r15
mov    %r14,%rbx
nop
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
add    $0x1,%r12
movslq -0x2c(%rbp),%rax
add    $0x4,%rbx
cmp    %rax,%r12
jl     1170 <main+0x50>
lea    0xe6d(%rip),%rdi
lea    -0x30(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x30(%rbp),%ecx
mov    %rsp,%r15
lea    0xf(,%rcx,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
test   %ecx,%ecx
jle    11f0 <main+0xd0>
mov    %r13,-0x38(%rbp)
xor    %r13d,%r13d
lea    0xe3e(%rip),%r12
mov    %r15,%rbx
nopl   0x0(%rax)
mov    %r12,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
add    $0x1,%r13
movslq -0x30(%rbp),%rcx
add    $0x4,%rbx
cmp    %rcx,%r13
jl     11d0 <main+0xb0>
mov    -0x38(%rbp),%r13
mov    -0x2c(%rbp),%esi
mov    %r14,%rdi
mov    %r15,%rdx
call   1030 <merge@plt>
mov    %r13,%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [4 x i8] c"%d \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
store i32 0, i32* %1
%8 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %2
%10 = zext i32 %9 to i64
%11 = call i8* @llvm.stacksave()
store i8* %11, i8** %5
%12 = alloca i32, i64 %10
store i64 %10, i64* %6
store i32 0, i32* %4
br label %13
13: ; preds = %22, %0
%14 = load i32, i32* %4
%15 = load i32, i32* %2
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %25
17: ; preds = %13
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %12, i64 %19
%21 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %20)
br label %22
22: ; preds = %17
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 1
store i32 %24, i32* %4
br label %13
25: ; preds = %13
%26 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %3)
%27 = load i32, i32* %3
%28 = zext i32 %27 to i64
%29 = alloca i32, i64 %28
store i64 %28, i64* %7
store i32 0, i32* %4
br label %30
30: ; preds = %39, %25
%31 = load i32, i32* %4
%32 = load i32, i32* %3
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %42
34: ; preds = %30
%35 = load i32, i32* %4
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i32, i32* %29, i64 %36
%38 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %37)
br label %39
39: ; preds = %34
%40 = load i32, i32* %4
%41 = add nsw i32 %40, 1
store i32 %41, i32* %4
br label %30
42: ; preds = %30
%43 = load i32, i32* %2
%44 = load i32, i32* %3
%45 = call i32 @merge(i32* %12, i32 %43, i32* %29, i32 %44)
store i32 0, i32* %1
%46 = load i8*, i8** %5
%47 = load i32, i32* %1
ret i32 %47
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [4 x i8] c"%d \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = zext i32 %6 to i64
%8 = call i8* @llvm.stacksave()
%9 = alloca i32, i64 %7
%10 = load i32, i32* %1
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %20
12: ; preds = %0, %12
%13 = phi i64 [ %16, %12 ], [ 0, %0 ]
%14 = getelementptr inbounds i32, i32* %9, i64 %13
%15 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %14)
%16 = add nuw nsw i64 %13, 1
%17 = load i32, i32* %1
%18 = sext i32 %17 to i64
%19 = icmp slt i64 %16, %18
br i1 %19, label %12, label %20
20: ; preds = %12, %0
%21 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %2)
%22 = load i32, i32* %2
%23 = zext i32 %22 to i64
%24 = alloca i32, i64 %23
%25 = icmp sgt i32 %22, 0
br i1 %25, label %26, label %34
26: ; preds = %20, %26
%27 = phi i64 [ %30, %26 ], [ 0, %20 ]
%28 = getelementptr inbounds i32, i32* %24, i64 %27
%29 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %28)
%30 = add nuw nsw i64 %27, 1
%31 = load i32, i32* %2
%32 = sext i32 %31 to i64
%33 = icmp slt i64 %30, %32
br i1 %33, label %26, label %34
34: ; preds = %26, %20
%35 = phi i32 [ %22, %20 ], [ %31, %26 ]
%36 = load i32, i32* %1
%37 = call i32 @merge(i32* %9, i32 %36, i32* %24, i32 %35)
ret i32 0
}