#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 a[2 + 1], b[2 + 1], c[2 * 2];
  a[2] = b[2] = 10000;
  int ia = 0, ib = 0;
  int i, j, max = 0;
  printf("Enter %d Elements for Array %d: ", 2, 1);
  for (j = 0; j < 2; j++)
    scanf("%d", &a[j]);
  printf("Enter %d Elements for Array %d: ", 2, 2);
  for (j = 0; j < 2; j++)
    scanf("%d", &b[j]);
  for (i = 0; i < 2 * 2; i++) {
    if (a[ia] < b[ib])
      c[i] = a[ia++];
    else
      c[i] = b[ib++];
    printf("C[%d] = %d \n", i, c[i]);
  }
  printf("Merged LIST: ");
  for (i = 0; i < 2 * 2; i++)
    printf("%d ", c[i]);
  printf(" \n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x2710,-0x14(%rbp)
movl   $0x2710,-0x8(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x44(%rbp)
lea    0xea7(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x40(%rbp)
cmpl   $0x2,-0x40(%rbp)
jge    11a4 <main+0x84>
movslq -0x40(%rbp),%rax
lea    -0x10(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe90(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1171 <main+0x51>
lea    0xe55(%rip),%rdi
mov    $0x2,%edx
mov    %edx,%esi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x40(%rbp)
cmpl   $0x2,-0x40(%rbp)
jge    11f3 <main+0xd3>
movslq -0x40(%rbp),%rax
lea    -0x1c(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe41(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    11c0 <main+0xa0>
movl   $0x0,-0x3c(%rbp)
cmpl   $0x4,-0x3c(%rbp)
jge    1278 <main+0x158>
movslq -0x34(%rbp),%rax
mov    -0x10(%rbp,%rax,4),%eax
movslq -0x38(%rbp),%rcx
cmp    -0x1c(%rbp,%rcx,4),%eax
jge    1238 <main+0x118>
mov    -0x34(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x34(%rbp)
cltq
mov    -0x10(%rbp,%rax,4),%ecx
movslq -0x3c(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
jmp    1251 <main+0x131>
mov    -0x38(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x38(%rbp)
cltq
mov    -0x1c(%rbp,%rax,4),%ecx
movslq -0x3c(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x3c(%rbp),%esi
movslq -0x3c(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%edx
lea    0xdc1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11fa <main+0xda>
lea    0xdb2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x3c(%rbp)
cmpl   $0x4,-0x3c(%rbp)
jge    12bb <main+0x19b>
movslq -0x3c(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%esi
lea    0xd99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    128d <main+0x16d>
lea    0xd6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
movl   $0x2710,0x14(%rsp)
movl   $0x2710,0x20(%rsp)
lea    0xeab(%rip),%r14
mov    $0x2,%r15d
mov    %r14,%rdi
mov    $0x2,%esi
mov    $0x1,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeab(%rip),%rbx
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0x1c(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
mov    %r14,%rdi
mov    $0x2,%esi
mov    $0x2,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
mov    0x18(%rsp),%ebx
mov    0xc(%rsp),%r12d
xor    %r13d,%r13d
xor    %r14d,%r14d
cmp    %r12d,%ebx
setge  %r13b
setl   %r14b
mov    %r12d,%edx
cmovl  %ebx,%edx
lea    0xe3f(%rip),%rdi
xor    %esi,%esi
mov    %edx,0x24(%rsp)
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rsp,%r14,4),%eax
mov    0xc(%rsp,%r13,4),%ecx
cmp    %ecx,%eax
jge    1218 <main+0xe8>
xor    %r14d,%r14d
cmp    %r12d,%ebx
setl   %r14b
add    $0x1,%r14d
mov    %eax,%ecx
mov    %r13d,%r15d
mov    %r14d,%ebp
jmp    1227 <main+0xf7>
xor    %ebp,%ebp
cmp    %r12d,%ebx
setl   %bpl
sub    %ebp,%r15d
mov    %r15,%r13
lea    0xdf6(%rip),%rdi
mov    $0x1,%esi
mov    %ecx,%r12d
mov    %ecx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rsp,%r14,4),%eax
mov    0xc(%rsp,%r13,4),%ebx
add    $0x1,%ebp
add    $0x1,%r15d
cmp    %ebx,%eax
cmovl  %r13,%r15
cmovge %r14,%rbp
cmovl  %eax,%ebx
lea    0xdc0(%rip),%r14
mov    %r14,%rdi
mov    $0x2,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rsp,%rbp,4),%eax
mov    0xc(%rsp,%r15,4),%ebp
cmp    %ebp,%eax
cmovl  %eax,%ebp
mov    %r14,%rdi
mov    $0x3,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd96(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd96(%rip),%r15
mov    %r15,%rdi
mov    0x24(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd5a(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [33 x i8] c"Enter %d Elements for Array %d: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [13 x i8] c"C[%d] = %d \0A\00"
@.str.3 = [14 x i8] c"Merged LIST: \00"
@.str.4 = [4 x i8] c"%d \00"
@str = [2 x i8] c" \00"
define i32 @main() {
%1 = alloca [3 x i32]
%2 = alloca [3 x i32]
%3 = bitcast [3 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 2
store i32 10000, i32* %5
%6 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 2
store i32 10000, i32* %6
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 2, i32 1)
%8 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 0
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%10 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 1
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %10)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 2, i32 2)
%13 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %13)
%15 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 1
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %15)
%17 = load i32, i32* %8
%18 = load i32, i32* %13
%19 = icmp slt i32 %17, %18
%20 = select i1 %19, i32 %17, i32 %18
%21 = xor i1 %19, true
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 0, i32 %20)
%23 = zext i1 %19 to i64
%24 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 %23
%25 = load i32, i32* %24
%26 = zext i1 %21 to i64
%27 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 %26
%28 = load i32, i32* %27
%29 = icmp slt i32 %25, %28
br i1 %29, label %34, label %30
30: ; preds = %0
%31 = zext i1 %19 to i32
%32 = select i1 %19, i32 1, i32 2
%33 = zext i32 %32 to i64
br label %38
34: ; preds = %0
%35 = zext i1 %21 to i32
%36 = select i1 %19, i32 2, i32 1
%37 = zext i32 %36 to i64
br label %38
38: ; preds = %34, %30
%39 = phi i64 [ %26, %34 ], [ %33, %30 ]
%40 = phi i64 [ %37, %34 ], [ %23, %30 ]
%41 = phi i32 [ %25, %34 ], [ %28, %30 ]
%42 = phi i32 [ %35, %34 ], [ %32, %30 ]
%43 = phi i32 [ %36, %34 ], [ %31, %30 ]
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 1, i32 %41)
%45 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 %40
%46 = load i32, i32* %45
%47 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 %39
%48 = load i32, i32* %47
%49 = icmp slt i32 %46, %48
%50 = add nuw nsw i32 %43, 1
%51 = zext i32 %50 to i64
%52 = add nuw nsw i32 %42, 1
%53 = zext i32 %52 to i64
%54 = select i1 %49, i64 %39, i64 %53
%55 = select i1 %49, i64 %51, i64 %40
%56 = select i1 %49, i32 %46, i32 %48
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 2, i32 %56)
%58 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 %55
%59 = load i32, i32* %58
%60 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 %54
%61 = load i32, i32* %60
%62 = icmp slt i32 %59, %61
%63 = select i1 %62, i32 %59, i32 %61
%64 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 3, i32 %63)
%65 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%66 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %20)
%67 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %41)
%68 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %56)
%69 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %63)
%70 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
ret i32 0
}