#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int arr1[10], arr2[10], arr3[20];
  int i, n1, n2, m, index = 0;
  printf("\n Enter the number of elements in array 1: ");
  scanf("%d", &n1);
  printf("\n\n Enter the Elements of the first array");
  for (i = 0; i < n1; i++) {
    scanf("%d", &arr1[i]);
  }
  printf("\n Enter the number of elements in array 2: ");
  scanf("%d", &n2);
  printf("\n\n Enter the Elements of the second array");
  for (i = 0; i < n2; i++) {
    scanf("%d", &arr2[i]);
    m = n1 + n2;
  }
  for (i = 0; i < n1; i++) {
    arr3[index] = arr1[i];
    index++;
  }
  for (i = 0; i < n2; i++) {
    arr3[index] = arr2[i];
    index++;
  }
  printf("\n\n The merged array is");
  for (i = 0; i < m; i++) {
    printf("\t\n Arr[%d] = %d", i, arr3[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc4(%rbp)
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf7e(%rip),%rdi
lea    -0xb8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xec8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xb4(%rbp)
mov    -0xb4(%rbp),%eax
cmp    -0xb8(%rbp),%eax
jge    11b9 <main+0x99>
movslq -0xb4(%rbp),%rax
lea    -0x30(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xf2f(%rip),%rdi
call   1040 <scanf@plt>
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
jmp    1175 <main+0x55>
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf01(%rip),%rdi
lea    -0xbc(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xb4(%rbp)
mov    -0xb4(%rbp),%eax
cmp    -0xbc(%rbp),%eax
jge    1248 <main+0x128>
movslq -0xb4(%rbp),%rax
lea    -0x60(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xeb2(%rip),%rdi
call   1040 <scanf@plt>
mov    -0xb8(%rbp),%eax
add    -0xbc(%rbp),%eax
mov    %eax,-0xc0(%rbp)
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
jmp    11f2 <main+0xd2>
movl   $0x0,-0xb4(%rbp)
mov    -0xb4(%rbp),%eax
cmp    -0xb8(%rbp),%eax
jge    12a0 <main+0x180>
movslq -0xb4(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%ecx
movslq -0xc4(%rbp),%rax
mov    %ecx,-0xb0(%rbp,%rax,4)
mov    -0xc4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc4(%rbp)
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
jmp    1252 <main+0x132>
movl   $0x0,-0xb4(%rbp)
mov    -0xb4(%rbp),%eax
cmp    -0xbc(%rbp),%eax
jge    12f8 <main+0x1d8>
movslq -0xb4(%rbp),%rax
mov    -0x60(%rbp,%rax,4),%ecx
movslq -0xc4(%rbp),%rax
mov    %ecx,-0xb0(%rbp,%rax,4)
mov    -0xc4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc4(%rbp)
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
jmp    12aa <main+0x18a>
lea    0xdac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xb4(%rbp)
mov    -0xb4(%rbp),%eax
cmp    -0xc0(%rbp),%eax
jge    1358 <main+0x238>
mov    -0xb4(%rbp),%esi
movslq -0xb4(%rbp),%rax
mov    -0xb0(%rbp,%rax,4),%edx
lea    0xd85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
jmp    1310 <main+0x1f0>
xor    %eax,%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xc0,%rsp
lea    0xeba(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf7b(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
lea    0xec7(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
cmpl   $0x0,0x8(%rsp)
jle    11ad <main+0x7d>
lea    0x40(%rsp),%r15
xor    %ebx,%ebx
lea    0xf4e(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
add    $0x1,%rbx
movslq 0x8(%rsp),%rax
add    $0x4,%r15
cmp    %rax,%rbx
jl     1190 <main+0x60>
lea    0xea1(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf0d(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
lea    0xeae(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0xc(%rsp),%r15d
test   %r15d,%r15d
jle    12bb <main+0x18b>
lea    0x10(%rsp),%r12
xor    %ebx,%ebx
lea    0xed9(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%r15
add    $0x4,%r12
cmp    %r15,%rbx
jl     1200 <main+0xd0>
mov    0x8(%rsp),%eax
lea    (%r15,%rax,1),%ebp
test   %eax,%eax
jle    12c7 <main+0x197>
mov    %eax,%ebx
lea    0x0(,%rbx,4),%rdx
lea    0x70(%rsp),%rdi
lea    0x40(%rsp),%rsi
call   1040 <memcpy@plt>
test   %r15d,%r15d
jle    1264 <main+0x134>
lea    (%rsp,%rbx,4),%rdi
add    $0x70,%rdi
mov    %r15d,%edx
shl    $0x2,%rdx
lea    0x10(%rsp),%rsi
call   1040 <memcpy@plt>
lea    0xe40(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
test   %ebp,%ebp
jle    12a9 <main+0x179>
mov    %ebp,%r15d
lea    0xe42(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x70(%rsp,%rbx,4),%edx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1290 <main+0x160>
xor    %eax,%eax
add    $0xc0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x8(%rsp),%eax
test   %eax,%eax
jg     122d <main+0xfd>
xor    %ebx,%ebx
test   %r15d,%r15d
jg     124b <main+0x11b>
jmp    1264 <main+0x134>

LLVM IR (-O0):
@.str = [44 x i8] c"\0A Enter the number of elements in array 1: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [41 x i8] c"\0A\0A Enter the Elements of the first array\00"
@.str.3 = [44 x i8] c"\0A Enter the number of elements in array 2: \00"
@.str.4 = [42 x i8] c"\0A\0A Enter the Elements of the second array\00"
@.str.5 = [23 x i8] c"\0A\0A The merged array is\00"
@.str.6 = [16 x i8] c"\09\0A Arr[%d] = %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i32]
%3 = alloca [10 x i32]
%4 = alloca [20 x i32]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %9
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %5
br label %13
13: ; preds = %22, %0
%14 = load i32, i32* %5
%15 = load i32, i32* %6
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %25
17: ; preds = %13
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %19
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %20)
br label %22
22: ; preds = %17
%23 = load i32, i32* %5
%24 = add nsw i32 %23, 1
store i32 %24, i32* %5
br label %13
25: ; preds = %13
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0))
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %5
br label %29
29: ; preds = %41, %25
%30 = load i32, i32* %5
%31 = load i32, i32* %7
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %44
33: ; preds = %29
%34 = load i32, i32* %5
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 %35
%37 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %36)
%38 = load i32, i32* %6
%39 = load i32, i32* %7
%40 = add nsw i32 %38, %39
store i32 %40, i32* %8
br label %41
41: ; preds = %33
%42 = load i32, i32* %5
%43 = add nsw i32 %42, 1
store i32 %43, i32* %5
br label %29
44: ; preds = %29
store i32 0, i32* %5
br label %45
45: ; preds = %59, %44
%46 = load i32, i32* %5
%47 = load i32, i32* %6
%48 = icmp slt i32 %46, %47
br i1 %48, label %49, label %62
49: ; preds = %45
%50 = load i32, i32* %5
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %51
%53 = load i32, i32* %52
%54 = load i32, i32* %9
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 %55
store i32 %53, i32* %56
%57 = load i32, i32* %9
%58 = add nsw i32 %57, 1
store i32 %58, i32* %9
br label %59
59: ; preds = %49
%60 = load i32, i32* %5
%61 = add nsw i32 %60, 1
store i32 %61, i32* %5
br label %45
62: ; preds = %45
store i32 0, i32* %5
br label %63
63: ; preds = %77, %62
%64 = load i32, i32* %5
%65 = load i32, i32* %7
%66 = icmp slt i32 %64, %65
br i1 %66, label %67, label %80
67: ; preds = %63
%68 = load i32, i32* %5
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 %69
%71 = load i32, i32* %70
%72 = load i32, i32* %9
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 %73
store i32 %71, i32* %74
%75 = load i32, i32* %9
%76 = add nsw i32 %75, 1
store i32 %76, i32* %9
br label %77
77: ; preds = %67
%78 = load i32, i32* %5
%79 = add nsw i32 %78, 1
store i32 %79, i32* %5
br label %63
80: ; preds = %63
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %5
br label %82
82: ; preds = %93, %80
%83 = load i32, i32* %5
%84 = load i32, i32* %8
%85 = icmp slt i32 %83, %84
br i1 %85, label %86, label %96
86: ; preds = %82
%87 = load i32, i32* %5
%88 = load i32, i32* %5
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 %89
%91 = load i32, i32* %90
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i32 %87, i32 %91)
br label %93
93: ; preds = %86
%94 = load i32, i32* %5
%95 = add nsw i32 %94, 1
store i32 %95, i32* %5
br label %82
96: ; preds = %82
ret i32 0
}

LLVM IR (-O2):
@.str = [44 x i8] c"\0A Enter the number of elements in array 1: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [41 x i8] c"\0A\0A Enter the Elements of the first array\00"
@.str.3 = [44 x i8] c"\0A Enter the number of elements in array 2: \00"
@.str.4 = [42 x i8] c"\0A\0A Enter the Elements of the second array\00"
@.str.5 = [23 x i8] c"\0A\0A The merged array is\00"
@.str.6 = [16 x i8] c"\09\0A Arr[%d] = %d\00"
define i32 @main() {
%1 = alloca [10 x i32]
%2 = bitcast [10 x i32]* %1 to i8*
%3 = alloca [10 x i32]
%4 = bitcast [10 x i32]* %3 to i8*
%5 = alloca [20 x i32]
%6 = bitcast [20 x i32]* %5 to i8*
%7 = alloca i32
%8 = alloca i32
%9 = bitcast i32* %7 to i8*
%10 = bitcast i32* %8 to i8*
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0))
%14 = load i32, i32* %7
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %24
16: ; preds = %0, %16
%17 = phi i64 [ %20, %16 ], [ 0, %0 ]
%18 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %17
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %18)
%20 = add nuw nsw i64 %17, 1
%21 = load i32, i32* %7
%22 = sext i32 %21 to i64
%23 = icmp slt i64 %20, %22
br i1 %23, label %16, label %24
24: ; preds = %16, %0
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0))
%26 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0))
%28 = load i32, i32* %8
%29 = icmp sgt i32 %28, 0
br i1 %29, label %44, label %30
30: ; preds = %24
%31 = load i32, i32* %7
br label %35
32: ; preds = %44
%33 = load i32, i32* %7
%34 = add nsw i32 %49, %33
br label %35
35: ; preds = %30, %32
%36 = phi i32 [ %33, %32 ], [ %31, %30 ]
%37 = phi i32 [ %34, %32 ], [ undef, %30 ]
%38 = phi i32 [ %49, %32 ], [ %28, %30 ]
%39 = icmp sgt i32 %36, 0
br i1 %39, label %40, label %52
40: ; preds = %35
%41 = zext i32 %36 to i64
%42 = shl nuw nsw i64 %41, 2
%43 = zext i32 %36 to i64
br label %52
44: ; preds = %24, %44
%45 = phi i64 [ %48, %44 ], [ 0, %24 ]
%46 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 %45
%47 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %46)
%48 = add nuw nsw i64 %45, 1
%49 = load i32, i32* %8
%50 = sext i32 %49 to i64
%51 = icmp slt i64 %48, %50
br i1 %51, label %44, label %32
52: ; preds = %40, %35
%53 = phi i64 [ 0, %35 ], [ %43, %40 ]
%54 = icmp sgt i32 %38, 0
br i1 %54, label %55, label %60
55: ; preds = %52
%56 = getelementptr [20 x i32], [20 x i32]* %5, i64 0, i64 %53
%57 = bitcast i32* %56 to i8*
%58 = zext i32 %38 to i64
%59 = shl nuw nsw i64 %58, 2
br label %60
60: ; preds = %55, %52
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
%62 = icmp sgt i32 %37, 0
br i1 %62, label %63, label %73
63: ; preds = %60
%64 = zext i32 %37 to i64
br label %65
65: ; preds = %63, %65
%66 = phi i64 [ 0, %63 ], [ %71, %65 ]
%67 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 %66
%68 = load i32, i32* %67
%69 = trunc i64 %66 to i32
%70 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i32 %69, i32 %68)
%71 = add nuw nsw i64 %66, 1
%72 = icmp eq i64 %71, %64
br i1 %72, label %73, label %65
73: ; preds = %65, %60
ret i32 0
}