#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 *, size_t, int *, size_t);
int /*<<< orphan*/ print_arr(int *, size_t);
int /*<<< orphan*/ printf(char *);
int scanf(char *, ...);
int main(void) {
  printf("Enter A's size, followed by B's size, followed by the elements of A "
         "and then "
         "the elements of B.\n");
  size_t a_sz, b_sz;
  while (scanf("%zu%zu", &a_sz, &b_sz) == 2) {
    int A[a_sz + b_sz];
    int B[b_sz];
    size_t i;
    for (i = 0; i < a_sz; i++) {
      scanf("%d", &A[i]);
    }
    for (i = 0; i < b_sz; i++) {
      scanf("%d", &B[i]);
    }
    merge(A, a_sz, B, b_sz);
    printf("Merged:\n");
    print_arr(A, a_sz + b_sz);
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
call   1040 <printf@plt>
lea    0xeff(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
mov    $0x0,%al
call   1060 <scanf@plt>
cmp    $0x2,%eax
jne    129c <main+0x15c>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
add    %rcx,%rax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    120e <main+0xce>
mov    -0x48(%rbp),%rsi
mov    -0x38(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    11d2 <main+0x92>
movq   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1252 <main+0x112>
mov    -0x40(%rbp),%rsi
mov    -0x38(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    1216 <main+0xd6>
mov    -0x48(%rbp),%rdi
mov    -0x40(%rbp),%rdx
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rcx
call   1050 <merge@plt>
lea    0xdfd(%rip),%rdi
call   1040 <printf@plt>
mov    -0x48(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    -0x18(%rbp),%rsi
call   1030 <print_arr@plt>
lea    0xdd4(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
jmp    115b <main+0x1b>
xor    %eax,%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    0xea2(%rip),%rdi
call   1040 <puts@plt>
lea    0xe8c(%rip),%rdi
lea    -0x38(%rbp),%rsi
lea    -0x30(%rbp),%rdx
xor    %eax,%eax
call   1070 <scanf@plt>
cmp    $0x2,%eax
jne    12a7 <main+0x157>
lea    0xe74(%rip),%r13
jmp    11f6 <main+0xa6>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %ecx,%ecx
mov    %r12,%rdi
mov    %r15,%rdx
call   1060 <merge@plt>
lea    0xeb6(%rip),%rdi
call   1040 <puts@plt>
mov    -0x30(%rbp),%rsi
add    -0x38(%rbp),%rsi
mov    %r12,%rdi
call   1050 <print_arr@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x40(%rbp),%rsp
lea    0xe22(%rip),%rdi
lea    -0x38(%rbp),%rsi
lea    -0x30(%rbp),%rdx
xor    %eax,%eax
call   1070 <scanf@plt>
cmp    $0x2,%eax
jne    12a7 <main+0x157>
mov    %rsp,%rdx
mov    -0x30(%rbp),%rax
add    -0x38(%rbp),%rax
mov    %rsp,%r12
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
mov    -0x30(%rbp),%rax
mov    %rsp,%r15
lea    0xf(,%rax,4),%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%r15
mov    %r15,%rsp
cmpq   $0x0,-0x38(%rbp)
mov    %rdx,-0x40(%rbp)
je     1270 <main+0x120>
mov    %r12,%r14
xor    %ebx,%ebx
nop
mov    %r13,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
add    $0x1,%rbx
mov    -0x38(%rbp),%rsi
add    $0x4,%r14
cmp    %rsi,%rbx
jb     1240 <main+0xf0>
mov    -0x30(%rbp),%rax
test   %rax,%rax
jne    127b <main+0x12b>
jmp    11a0 <main+0x50>
nopl   0x0(%rax)
xor    %esi,%esi
test   %rax,%rax
je     11a0 <main+0x50>
mov    %r15,%r14
xor    %ebx,%ebx
mov    %r13,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
add    $0x1,%rbx
mov    -0x30(%rbp),%rcx
add    $0x4,%r14
cmp    %rcx,%rbx
jb     1280 <main+0x130>
mov    -0x38(%rbp),%rsi
jmp    11a2 <main+0x52>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [97 x i8] c"Enter A's size, followed by B's size, followed by the elements of A and then the elements of B.\0A\00"
@.str.1 = [7 x i8] c"%zu%zu\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [9 x i8] c"Merged:\0A\00"
@.str.4 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
store i32 0, i32* %1
%8 = call i32 @printf(i8* getelementptr inbounds ([97 x i8], [97 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %43, %0
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i64* %2, i64* %3)
%11 = icmp eq i32 %10, 2
br i1 %11, label %12, label %54
12: ; preds = %9
%13 = load i64, i64* %2
%14 = load i64, i64* %3
%15 = add i64 %13, %14
%16 = call i8* @llvm.stacksave()
store i8* %16, i8** %4
%17 = alloca i32, i64 %15
store i64 %15, i64* %5
%18 = load i64, i64* %3
%19 = alloca i32, i64 %18
store i64 %18, i64* %6
store i64 0, i64* %7
br label %20
20: ; preds = %28, %12
%21 = load i64, i64* %7
%22 = load i64, i64* %2
%23 = icmp ult i64 %21, %22
br i1 %23, label %24, label %31
24: ; preds = %20
%25 = load i64, i64* %7
%26 = getelementptr inbounds i32, i32* %17, i64 %25
%27 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %26)
br label %28
28: ; preds = %24
%29 = load i64, i64* %7
%30 = add i64 %29, 1
store i64 %30, i64* %7
br label %20
31: ; preds = %20
store i64 0, i64* %7
br label %32
32: ; preds = %40, %31
%33 = load i64, i64* %7
%34 = load i64, i64* %3
%35 = icmp ult i64 %33, %34
br i1 %35, label %36, label %43
36: ; preds = %32
%37 = load i64, i64* %7
%38 = getelementptr inbounds i32, i32* %19, i64 %37
%39 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %38)
br label %40
40: ; preds = %36
%41 = load i64, i64* %7
%42 = add i64 %41, 1
store i64 %42, i64* %7
br label %32
43: ; preds = %32
%44 = load i64, i64* %2
%45 = load i64, i64* %3
%46 = call i32 @merge(i32* %17, i64 %44, i32* %19, i64 %45)
%47 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%48 = load i64, i64* %2
%49 = load i64, i64* %3
%50 = add i64 %48, %49
%51 = call i32 @print_arr(i32* %17, i64 %50)
%52 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%53 = load i8*, i8** %4
br label %9
54: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [7 x i8] c"%zu%zu\00"
@.str.2 = [3 x i8] c"%d\00"
@str = [96 x i8] c"Enter A's size, followed by B's size, followed by the elements of A and then the elements of B.\00"
@str.5 = [8 x i8] c"Merged:\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca i64
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([96 x i8], [96 x i8]* @str, i64 0, i64 0))
%4 = bitcast i64* %1 to i8*
%5 = bitcast i64* %2 to i8*
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i64* %1, i64* %2)
%7 = icmp eq i32 %6, 2
br i1 %7, label %8, label %52
8: ; preds = %0, %40
%9 = load i64, i64* %1
%10 = load i64, i64* %2
%11 = add i64 %10, %9
%12 = call i8* @llvm.stacksave()
%13 = alloca i32, i64 %11
%14 = load i64, i64* %2
%15 = alloca i32, i64 %14
%16 = load i64, i64* %1
%17 = icmp eq i64 %16, 0
br i1 %17, label %20, label %24
18: ; preds = %24
%19 = load i64, i64* %2
br label %20
20: ; preds = %18, %8
%21 = phi i64 [ %29, %18 ], [ 0, %8 ]
%22 = phi i64 [ %19, %18 ], [ %14, %8 ]
%23 = icmp eq i64 %22, 0
br i1 %23, label %40, label %31
24: ; preds = %8, %24
%25 = phi i64 [ %28, %24 ], [ 0, %8 ]
%26 = getelementptr inbounds i32, i32* %13, i64 %25
%27 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %26)
%28 = add nuw i64 %25, 1
%29 = load i64, i64* %1
%30 = icmp ult i64 %28, %29
br i1 %30, label %24, label %18
31: ; preds = %20, %31
%32 = phi i64 [ %35, %31 ], [ 0, %20 ]
%33 = getelementptr inbounds i32, i32* %15, i64 %32
%34 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %33)
%35 = add nuw i64 %32, 1
%36 = load i64, i64* %2
%37 = icmp ult i64 %35, %36
br i1 %37, label %31, label %38
38: ; preds = %31
%39 = load i64, i64* %1
br label %40
40: ; preds = %38, %20
%41 = phi i64 [ %21, %20 ], [ %39, %38 ]
%42 = phi i64 [ 0, %20 ], [ %36, %38 ]
%43 = call i32 @merge(i32* %13, i64 %41, i32* %15, i64 %42)
%44 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.5, i64 0, i64 0))
%45 = load i64, i64* %1
%46 = load i64, i64* %2
%47 = add i64 %46, %45
%48 = call i32 @print_arr(i32* %13, i64 %47)
%49 = call i32 @putchar(i32 10)
%50 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i64* %1, i64* %2)
%51 = icmp eq i32 %50, 2
br i1 %51, label %8, label %52
52: ; preds = %40, %0
ret i32 0
}