#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*/ ascendingarrayunion(int *, int, int *, int, int, int);
int /*<<< orphan*/ ascendingselectionsort(int *, int, int, int, int, int);
int /*<<< orphan*/ descendingarrayunion(int *, int, int *, int, int, int);
int /*<<< orphan*/ descendingselectionsort(int *, int, int, int, int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int m_index = 0;
  int n_index = 0;
  do {
    printf("Please write here the array A size: \n");
    scanf("%d", &m_index);
    printf("Please write here the array B size: \n");
    scanf("%d", &n_index);
  } while (m_index == n_index || (m_index < 0 || n_index < 0));
  int a[m_index];
  int b[n_index];
  printf("Array A size is: %d\n", m_index);
  printf("Array B size is: %d\n", n_index);
  int i;
  for (i = 0; i < m_index; i++) {
    printf("Please write the elements for the array A one by one and push "
           "ENTER\n");
    scanf("%d", &a[i]);
  }
  int j;
  for (j = 0; j < n_index; j++) {
    printf("Please write the elements for the array B one by one and push "
           "ENTER\n");
    scanf("%d", &b[j]);
  }
  printf("The elements in the array A are: \n");
  for (i = 0; i < m_index; i++)
    printf("%d\n", a[i]);
  printf("The elements in the array B are \n");
  for (j = 0; j < n_index; j++)
    printf("%d\n", b[j]);
  int min = 0;
  int min_index = 0;
  ascendingselectionsort(a, m_index, i, j, min, min_index);
  printf("Now the array A is in ascending order.\n");
  printf("The elements in the array A are: \n");
  for (i = 0; i < m_index; i++)
    printf("Element: %d\n", a[i]);
  descendingselectionsort(b, n_index, i, j, min, min_index);
  printf("Now the array B is in descending order.\n");
  printf("The elements in the array B are: \n");
  for (i = 0; i < n_index; i++)
    printf("Element: %d\n", b[i]);
  ascendingarrayunion(a, m_index, b, n_index, min, min_index);
  descendingarrayunion(a, m_index, b, n_index, min, min_index);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe94(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe76(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x8(%rbp),%ecx
mov    $0x1,%al
cmp    -0xc(%rbp),%ecx
mov    %al,-0x39(%rbp)
je     11e9 <main+0x89>
mov    $0x1,%al
cmpl   $0x0,-0x8(%rbp)
mov    %al,-0x3a(%rbp)
jl     11e3 <main+0x83>
cmpl   $0x0,-0xc(%rbp)
setl   %al
mov    %al,-0x3a(%rbp)
mov    -0x3a(%rbp),%al
mov    %al,-0x39(%rbp)
mov    -0x39(%rbp),%al
test   $0x1,%al
jne    117d <main+0x1d>
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,-0x50(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
mov    -0xc(%rbp),%eax
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    -0x8(%rbp),%esi
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xe0e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12a7 <main+0x147>
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x50(%rbp),%rsi
movslq -0x2c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xd92(%rip),%rdi
call   1070 <scanf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1264 <main+0x104>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    12f1 <main+0x191>
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x48(%rbp),%rsi
movslq -0x30(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xd48(%rip),%rdi
call   1070 <scanf@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    12ae <main+0x14e>
lea    0xe0b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1339 <main+0x1d9>
mov    -0x50(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xd3c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1306 <main+0x1a6>
lea    0xde6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1381 <main+0x221>
mov    -0x48(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xcf4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    134e <main+0x1ee>
mov    -0x50(%rbp),%rdi
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x8(%rbp),%esi
mov    -0x2c(%rbp),%edx
mov    -0x30(%rbp),%ecx
mov    -0x34(%rbp),%r8d
mov    -0x38(%rbp),%r9d
call   1080 <ascendingselectionsort@plt>
lea    0xd98(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xd45(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    13ff <main+0x29f>
mov    -0x50(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xd86(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    13cc <main+0x26c>
mov    -0x48(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x2c(%rbp),%edx
mov    -0x30(%rbp),%ecx
mov    -0x34(%rbp),%r8d
mov    -0x38(%rbp),%r9d
call   1030 <descendingselectionsort@plt>
lea    0xd5d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xd78(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    146f <main+0x30f>
mov    -0x48(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xd16(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    143c <main+0x2dc>
mov    -0x48(%rbp),%rdx
mov    -0x50(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%ecx
mov    -0x34(%rbp),%r8d
mov    -0x38(%rbp),%r9d
call   1060 <ascendingarrayunion@plt>
mov    -0x50(%rbp),%rdi
mov    -0x48(%rbp),%rdx
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%ecx
mov    -0x34(%rbp),%r8d
mov    -0x38(%rbp),%r9d
call   1040 <descendingarrayunion@plt>
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
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x2c(%rbp)
lea    0xea4(%rip),%r14
lea    0xe63(%rip),%rbx
lea    -0x30(%rbp),%r15
lea    0xeb7(%rip),%r12
lea    -0x2c(%rbp),%r13
nopl   0x0(%rax)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <scanf@plt>
mov    %r12,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1080 <scanf@plt>
mov    -0x30(%rbp),%eax
mov    -0x2c(%rbp),%ecx
cmp    %ecx,%eax
je     11b0 <main+0x40>
test   %eax,%eax
js     11b0 <main+0x40>
test   %ecx,%ecx
js     11b0 <main+0x40>
mov    %rsp,-0x40(%rbp)
mov    %rsp,%rcx
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    -0x2c(%rbp),%eax
mov    %rsp,%r15
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    -0x30(%rbp),%esi
lea    0xddc(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    -0x2c(%rbp),%esi
lea    0xde0(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
cmpl   $0x0,-0x30(%rbp)
jle    1284 <main+0x114>
xor    %r14d,%r14d
lea    0xf2d(%rip),%r12
lea    0xdaa(%rip),%r13
mov    -0x38(%rbp),%rbx
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1080 <scanf@plt>
add    $0x1,%r14
movslq -0x30(%rbp),%rax
add    $0x4,%rbx
cmp    %rax,%r14
jl     1260 <main+0xf0>
cmpl   $0x0,-0x2c(%rbp)
jle    12c4 <main+0x154>
xor    %r14d,%r14d
lea    0xea4(%rip),%r12
lea    0xd65(%rip),%r13
mov    %r15,%rbx
xchg   %ax,%ax
mov    %r12,%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1080 <scanf@plt>
add    $0x1,%r14
movslq -0x2c(%rbp),%rax
add    $0x4,%rbx
cmp    %rax,%r14
jl     12a0 <main+0x130>
lea    0xe01(%rip),%rdi
call   1030 <puts@plt>
xor    %r12d,%r12d
cmpl   $0x0,-0x30(%rbp)
mov    $0x0,%r13d
mov    -0x38(%rbp),%r14
jle    130b <main+0x19b>
lea    0xd2a(%rip),%rbx
xor    %r13d,%r13d
nopl   (%rax)
mov    (%r14,%r13,4),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%r13
movslq -0x30(%rbp),%rax
cmp    %rax,%r13
jl     12f0 <main+0x180>
lea    0xd72(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,-0x2c(%rbp)
jle    134b <main+0x1db>
lea    0xcf0(%rip),%rbx
xor    %r12d,%r12d
nopw   0x0(%rax,%rax,1)
mov    (%r15,%r12,4),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%r12
movslq -0x2c(%rbp),%rax
cmp    %rax,%r12
jl     1330 <main+0x1c0>
mov    -0x30(%rbp),%esi
xor    %ebx,%ebx
mov    %r14,%rdi
mov    %r13d,%edx
mov    %r12d,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1090 <ascendingselectionsort@plt>
lea    0xd3a(%rip),%rdi
call   1030 <puts@plt>
lea    0xd55(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,-0x30(%rbp)
jle    13ab <main+0x23b>
lea    0xca4(%rip),%r13
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    (%r14,%rbx,4),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%rbx
movslq -0x30(%rbp),%rax
cmp    %rax,%rbx
jl     1390 <main+0x220>
mov    -0x2c(%rbp),%esi
mov    %r15,%rdi
mov    %ebx,%edx
mov    %r12d,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1040 <descendingselectionsort@plt>
lea    0xd26(%rip),%rdi
call   1030 <puts@plt>
lea    0xd42(%rip),%rdi
call   1030 <puts@plt>
mov    -0x2c(%rbp),%ecx
test   %ecx,%ecx
jle    140f <main+0x29f>
lea    0xc46(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    (%r15,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%rbx
movslq -0x2c(%rbp),%rcx
cmp    %rcx,%rbx
jl     13f0 <main+0x280>
mov    -0x38(%rbp),%r14
mov    -0x30(%rbp),%esi
mov    %r14,%rdi
mov    %r15,%rdx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1070 <ascendingarrayunion@plt>
mov    -0x30(%rbp),%esi
mov    -0x2c(%rbp),%ecx
mov    %r14,%rdi
mov    %r15,%rdx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1050 <descendingarrayunion@plt>
mov    -0x40(%rbp),%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 = [38 x i8] c"Please write here the array A size: \0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [38 x i8] c"Please write here the array B size: \0A\00"
@.str.3 = [21 x i8] c"Array A size is: %d\0A\00"
@.str.4 = [21 x i8] c"Array B size is: %d\0A\00"
@.str.5 = [69 x i8] c"Please write the elements for the array A one by one and push ENTER\0A\00"
@.str.6 = [69 x i8] c"Please write the elements for the array B one by one and push ENTER\0A\00"
@.str.7 = [35 x i8] c"The elements in the array A are: \0A\00"
@.str.8 = [4 x i8] c"%d\0A\00"
@.str.9 = [34 x i8] c"The elements in the array B are \0A\00"
@.str.10 = [40 x i8] c"Now the array A is in ascending order.\0A\00"
@.str.11 = [13 x i8] c"Element: %d\0A\00"
@.str.12 = [41 x i8] c"Now the array B is in descending order.\0A\00"
@.str.13 = [35 x i8] c"The elements in the array B are: \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
br label %11
11: ; preds = %28, %0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
br label %16
16: ; preds = %11
%17 = load i32, i32* %2
%18 = load i32, i32* %3
%19 = icmp eq i32 %17, %18
br i1 %19, label %28, label %20
20: ; preds = %16
%21 = load i32, i32* %2
%22 = icmp slt i32 %21, 0
br i1 %22, label %26, label %23
23: ; preds = %20
%24 = load i32, i32* %3
%25 = icmp slt i32 %24, 0
br label %26
26: ; preds = %23, %20
%27 = phi i1 [ true, %20 ], [ %25, %23 ]
br label %28
28: ; preds = %26, %16
%29 = phi i1 [ true, %16 ], [ %27, %26 ]
br i1 %29, label %11, label %30
30: ; preds = %28
%31 = load i32, i32* %2
%32 = zext i32 %31 to i64
%33 = call i8* @llvm.stacksave()
store i8* %33, i8** %4
%34 = alloca i32, i64 %32
store i64 %32, i64* %5
%35 = load i32, i32* %3
%36 = zext i32 %35 to i64
%37 = alloca i32, i64 %36
store i64 %36, i64* %6
%38 = load i32, i32* %2
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %38)
%40 = load i32, i32* %3
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %40)
store i32 0, i32* %7
br label %42
42: ; preds = %52, %30
%43 = load i32, i32* %7
%44 = load i32, i32* %2
%45 = icmp slt i32 %43, %44
br i1 %45, label %46, label %55
46: ; preds = %42
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.5, i64 0, i64 0))
%48 = load i32, i32* %7
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i32, i32* %34, i64 %49
%51 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %50)
br label %52
52: ; preds = %46
%53 = load i32, i32* %7
%54 = add nsw i32 %53, 1
store i32 %54, i32* %7
br label %42
55: ; preds = %42
store i32 0, i32* %8
br label %56
56: ; preds = %66, %55
%57 = load i32, i32* %8
%58 = load i32, i32* %3
%59 = icmp slt i32 %57, %58
br i1 %59, label %60, label %69
60: ; preds = %56
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.6, i64 0, i64 0))
%62 = load i32, i32* %8
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i32, i32* %37, i64 %63
%65 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %64)
br label %66
66: ; preds = %60
%67 = load i32, i32* %8
%68 = add nsw i32 %67, 1
store i32 %68, i32* %8
br label %56
69: ; preds = %56
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.7, i64 0, i64 0))
store i32 0, i32* %7
br label %71
71: ; preds = %81, %69
%72 = load i32, i32* %7
%73 = load i32, i32* %2
%74 = icmp slt i32 %72, %73
br i1 %74, label %75, label %84
75: ; preds = %71
%76 = load i32, i32* %7
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds i32, i32* %34, i64 %77
%79 = load i32, i32* %78
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i32 %79)
br label %81
81: ; preds = %75
%82 = load i32, i32* %7
%83 = add nsw i32 %82, 1
store i32 %83, i32* %7
br label %71
84: ; preds = %71
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.9, i64 0, i64 0))
store i32 0, i32* %8
br label %86
86: ; preds = %96, %84
%87 = load i32, i32* %8
%88 = load i32, i32* %3
%89 = icmp slt i32 %87, %88
br i1 %89, label %90, label %99
90: ; preds = %86
%91 = load i32, i32* %8
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds i32, i32* %37, i64 %92
%94 = load i32, i32* %93
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i32 %94)
br label %96
96: ; preds = %90
%97 = load i32, i32* %8
%98 = add nsw i32 %97, 1
store i32 %98, i32* %8
br label %86
99: ; preds = %86
store i32 0, i32* %9
store i32 0, i32* %10
%100 = load i32, i32* %2
%101 = load i32, i32* %7
%102 = load i32, i32* %8
%103 = load i32, i32* %9
%104 = load i32, i32* %10
%105 = call i32 @ascendingselectionsort(i32* %34, i32 %100, i32 %101, i32 %102, i32 %103, i32 %104)
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.10, i64 0, i64 0))
%107 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.7, i64 0, i64 0))
store i32 0, i32* %7
br label %108
108: ; preds = %118, %99
%109 = load i32, i32* %7
%110 = load i32, i32* %2
%111 = icmp slt i32 %109, %110
br i1 %111, label %112, label %121
112: ; preds = %108
%113 = load i32, i32* %7
%114 = sext i32 %113 to i64
%115 = getelementptr inbounds i32, i32* %34, i64 %114
%116 = load i32, i32* %115
%117 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0), i32 %116)
br label %118
118: ; preds = %112
%119 = load i32, i32* %7
%120 = add nsw i32 %119, 1
store i32 %120, i32* %7
br label %108
121: ; preds = %108
%122 = load i32, i32* %3
%123 = load i32, i32* %7
%124 = load i32, i32* %8
%125 = load i32, i32* %9
%126 = load i32, i32* %10
%127 = call i32 @descendingselectionsort(i32* %37, i32 %122, i32 %123, i32 %124, i32 %125, i32 %126)
%128 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.12, i64 0, i64 0))
%129 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.13, i64 0, i64 0))
store i32 0, i32* %7
br label %130
130: ; preds = %140, %121
%131 = load i32, i32* %7
%132 = load i32, i32* %3
%133 = icmp slt i32 %131, %132
br i1 %133, label %134, label %143
134: ; preds = %130
%135 = load i32, i32* %7
%136 = sext i32 %135 to i64
%137 = getelementptr inbounds i32, i32* %37, i64 %136
%138 = load i32, i32* %137
%139 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0), i32 %138)
br label %140
140: ; preds = %134
%141 = load i32, i32* %7
%142 = add nsw i32 %141, 1
store i32 %142, i32* %7
br label %130
143: ; preds = %130
%144 = load i32, i32* %2
%145 = load i32, i32* %3
%146 = load i32, i32* %9
%147 = load i32, i32* %10
%148 = call i32 @ascendingarrayunion(i32* %34, i32 %144, i32* %37, i32 %145, i32 %146, i32 %147)
%149 = load i32, i32* %2
%150 = load i32, i32* %3
%151 = load i32, i32* %9
%152 = load i32, i32* %10
%153 = call i32 @descendingarrayunion(i32* %34, i32 %149, i32* %37, i32 %150, i32 %151, i32 %152)
%154 = load i8*, i8** %4
%155 = load i32, i32* %1
ret i32 %155
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [21 x i8] c"Array A size is: %d\0A\00"
@.str.4 = [21 x i8] c"Array B size is: %d\0A\00"
@.str.8 = [4 x i8] c"%d\0A\00"
@.str.11 = [13 x i8] c"Element: %d\0A\00"
@str = [37 x i8] c"Please write here the array A size: \00"
@str.14 = [37 x i8] c"Please write here the array B size: \00"
@str.16 = [33 x i8] c"The elements in the array B are \00"
@str.17 = [39 x i8] c"Now the array A is in ascending order.\00"
@str.18 = [34 x i8] c"The elements in the array A are: \00"
@str.19 = [40 x i8] c"Now the array B is in descending order.\00"
@str.20 = [34 x i8] c"The elements in the array B are: \00"
@str.21 = [68 x i8] c"Please write the elements for the array B one by one and push ENTER\00"
@str.22 = [68 x i8] c"Please write the elements for the array A one by one and push ENTER\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%4 = bitcast i32* %2 to i8*
store i32 0, i32* %2
br label %5
5: ; preds = %17, %0
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.14, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %1
%11 = load i32, i32* %2
%12 = icmp eq i32 %10, %11
br i1 %12, label %17, label %13
13: ; preds = %5
%14 = icmp slt i32 %10, 0
%15 = icmp slt i32 %11, 0
%16 = select i1 %14, i1 true, i1 %15
br i1 %16, label %17, label %18
17: ; preds = %13, %5
br label %5
18: ; preds = %13
%19 = zext i32 %10 to i64
%20 = call i8* @llvm.stacksave()
%21 = alloca i32, i64 %19
%22 = load i32, i32* %2
%23 = zext i32 %22 to i64
%24 = alloca i32, i64 %23
%25 = load i32, i32* %1
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %25)
%27 = load i32, i32* %2
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %27)
%29 = load i32, i32* %1
%30 = icmp sgt i32 %29, 0
br i1 %30, label %34, label %31
31: ; preds = %34, %18
%32 = load i32, i32* %2
%33 = icmp sgt i32 %32, 0
br i1 %33, label %43, label %52
34: ; preds = %18, %34
%35 = phi i64 [ %39, %34 ], [ 0, %18 ]
%36 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([68 x i8], [68 x i8]* @str.22, i64 0, i64 0))
%37 = getelementptr inbounds i32, i32* %21, i64 %35
%38 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %37)
%39 = add nuw nsw i64 %35, 1
%40 = load i32, i32* %1
%41 = sext i32 %40 to i64
%42 = icmp slt i64 %39, %41
br i1 %42, label %34, label %31
43: ; preds = %31, %43
%44 = phi i64 [ %48, %43 ], [ 0, %31 ]
%45 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([68 x i8], [68 x i8]* @str.21, i64 0, i64 0))
%46 = getelementptr inbounds i32, i32* %24, i64 %44
%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 %44, 1
%49 = load i32, i32* %2
%50 = sext i32 %49 to i64
%51 = icmp slt i64 %48, %50
br i1 %51, label %43, label %52
52: ; preds = %43, %31
%53 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.18, i64 0, i64 0))
%54 = load i32, i32* %1
%55 = icmp sgt i32 %54, 0
br i1 %55, label %56, label %67
56: ; preds = %52, %56
%57 = phi i64 [ %61, %56 ], [ 0, %52 ]
%58 = getelementptr inbounds i32, i32* %21, i64 %57
%59 = load i32, i32* %58
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i32 %59)
%61 = add nuw nsw i64 %57, 1
%62 = load i32, i32* %1
%63 = sext i32 %62 to i64
%64 = icmp slt i64 %61, %63
br i1 %64, label %56, label %65
65: ; preds = %56
%66 = trunc i64 %61 to i32
br label %67
67: ; preds = %65, %52
%68 = phi i32 [ 0, %52 ], [ %66, %65 ]
%69 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.16, i64 0, i64 0))
%70 = load i32, i32* %2
%71 = icmp sgt i32 %70, 0
br i1 %71, label %72, label %83
72: ; preds = %67, %72
%73 = phi i64 [ %77, %72 ], [ 0, %67 ]
%74 = getelementptr inbounds i32, i32* %24, i64 %73
%75 = load i32, i32* %74
%76 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i32 %75)
%77 = add nuw nsw i64 %73, 1
%78 = load i32, i32* %2
%79 = sext i32 %78 to i64
%80 = icmp slt i64 %77, %79
br i1 %80, label %72, label %81
81: ; preds = %72
%82 = trunc i64 %77 to i32
br label %83
83: ; preds = %81, %67
%84 = phi i32 [ 0, %67 ], [ %82, %81 ]
%85 = load i32, i32* %1
%86 = call i32 @ascendingselectionsort(i32* %21, i32 %85, i32 %68, i32 %84, i32 0, i32 0)
%87 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.17, i64 0, i64 0))
%88 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.18, i64 0, i64 0))
%89 = load i32, i32* %1
%90 = icmp sgt i32 %89, 0
br i1 %90, label %91, label %102
91: ; preds = %83, %91
%92 = phi i64 [ %96, %91 ], [ 0, %83 ]
%93 = getelementptr inbounds i32, i32* %21, i64 %92
%94 = load i32, i32* %93
%95 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0), i32 %94)
%96 = add nuw nsw i64 %92, 1
%97 = load i32, i32* %1
%98 = sext i32 %97 to i64
%99 = icmp slt i64 %96, %98
br i1 %99, label %91, label %100
100: ; preds = %91
%101 = trunc i64 %96 to i32
br label %102
102: ; preds = %100, %83
%103 = phi i32 [ 0, %83 ], [ %101, %100 ]
%104 = load i32, i32* %2
%105 = call i32 @descendingselectionsort(i32* %24, i32 %104, i32 %103, i32 %84, i32 0, i32 0)
%106 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.19, i64 0, i64 0))
%107 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.20, i64 0, i64 0))
%108 = load i32, i32* %2
%109 = icmp sgt i32 %108, 0
br i1 %109, label %110, label %119
110: ; preds = %102, %110
%111 = phi i64 [ %115, %110 ], [ 0, %102 ]
%112 = getelementptr inbounds i32, i32* %24, i64 %111
%113 = load i32, i32* %112
%114 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0), i32 %113)
%115 = add nuw nsw i64 %111, 1
%116 = load i32, i32* %2
%117 = sext i32 %116 to i64
%118 = icmp slt i64 %115, %117
br i1 %118, label %110, label %119
119: ; preds = %110, %102
%120 = phi i32 [ %108, %102 ], [ %116, %110 ]
%121 = load i32, i32* %1
%122 = call i32 @ascendingarrayunion(i32* %21, i32 %121, i32* %24, i32 %120, i32 0, i32 0)
%123 = load i32, i32* %1
%124 = load i32, i32* %2
%125 = call i32 @descendingarrayunion(i32* %21, i32 %123, i32* %24, i32 %124, i32 0, i32 0)
ret i32 0
}