#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*/ scanf(char *, int *);
int /*<<< orphan*/ sort(int *, int);
int /*<<< orphan*/ sum(int *, int *, int);
int main() {
  int n, t, i, j;
  scanf("%d", &t);
  for (i = 0; i < t; i++) {
    scanf("%d", &n);
    int a[n], b[n];
    for (j = 0; j < n; j++) {
      scanf("%d", &a[j]);
    }
    for (j = 0; j < n; j++) {
      scanf("%d", &b[j]);
    }
    sort(a, n);
    sort(b, n);
    sum(a, b, n);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    126e <main+0x13e>
lea    0xe97(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x8(%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,-0x30(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11f5 <main+0xc5>
mov    -0x40(%rbp),%rsi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe1e(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11c0 <main+0x90>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1231 <main+0x101>
mov    -0x38(%rbp),%rsi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xde2(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11fc <main+0xcc>
mov    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1030 <sort@plt>
mov    -0x38(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1030 <sort@plt>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x8(%rbp),%edx
call   1040 <sum@plt>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1156 <main+0x26>
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    0xeb8(%rip),%rdi
lea    -0x30(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0x30(%rbp)
jle    1251 <main+0x121>
xor    %eax,%eax
lea    0xe9c(%rip),%r13
jmp    11a5 <main+0x75>
cs nopw 0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1030 <sort@plt>
mov    -0x2c(%rbp),%esi
mov    %r12,%rdi
call   1030 <sort@plt>
mov    -0x2c(%rbp),%edx
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <sum@plt>
mov    -0x38(%rbp),%rsp
mov    -0x40(%rbp),%rax
add    $0x1,%eax
cmp    -0x30(%rbp),%eax
jge    1251 <main+0x121>
mov    %rax,-0x40(%rbp)
mov    %r13,%rdi
lea    -0x2c(%rbp),%rsi
call   1050 <scanf@plt>
mov    %rsp,-0x38(%rbp)
mov    -0x2c(%rbp),%eax
mov    %rsp,%r15
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    -0x2c(%rbp),%esi
mov    %rsp,%r12
lea    0xf(,%rsi,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
test   %esi,%esi
jle    1170 <main+0x40>
mov    %r15,%rbx
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r13,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
add    $0x1,%r14
movslq -0x2c(%rbp),%rsi
add    $0x4,%rbx
cmp    %rsi,%r14
jl     1200 <main+0xd0>
test   %esi,%esi
jle    1170 <main+0x40>
mov    %r12,%r14
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %r13,%rdi
mov    %r14,%rsi
call   1050 <scanf@plt>
add    $0x1,%rbx
movslq -0x2c(%rbp),%rsi
add    $0x4,%r14
cmp    %rsi,%rbx
jl     1230 <main+0x100>
jmp    1170 <main+0x40>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 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 ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%6 = load i32, i32* %2
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %47
8: ; preds = %0, %37
%9 = phi i32 [ %44, %37 ], [ 0, %0 ]
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%11 = load i32, i32* %1
%12 = zext i32 %11 to i64
%13 = call i8* @llvm.stacksave()
%14 = alloca i32, i64 %12
%15 = load i32, i32* %1
%16 = zext i32 %15 to i64
%17 = alloca i32, i64 %16
%18 = icmp sgt i32 %15, 0
br i1 %18, label %21, label %37
19: ; preds = %21
%20 = icmp sgt i32 %26, 0
br i1 %20, label %29, label %37
21: ; preds = %8, %21
%22 = phi i64 [ %25, %21 ], [ 0, %8 ]
%23 = getelementptr inbounds i32, i32* %14, i64 %22
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %23)
%25 = add nuw nsw i64 %22, 1
%26 = load i32, i32* %1
%27 = sext i32 %26 to i64
%28 = icmp slt i64 %25, %27
br i1 %28, label %21, label %19
29: ; preds = %19, %29
%30 = phi i64 [ %33, %29 ], [ 0, %19 ]
%31 = getelementptr inbounds i32, i32* %17, i64 %30
%32 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %31)
%33 = add nuw nsw i64 %30, 1
%34 = load i32, i32* %1
%35 = sext i32 %34 to i64
%36 = icmp slt i64 %33, %35
br i1 %36, label %29, label %37
37: ; preds = %29, %8, %19
%38 = phi i32 [ %26, %19 ], [ %15, %8 ], [ %34, %29 ]
%39 = call i32 @sort(i32* %14, i32 %38)
%40 = load i32, i32* %1
%41 = call i32 @sort(i32* %17, i32 %40)
%42 = load i32, i32* %1
%43 = call i32 @sum(i32* %14, i32* %17, i32 %42)
%44 = add nuw nsw i32 %9, 1
%45 = load i32, i32* %2
%46 = icmp slt i32 %44, %45
br i1 %46, label %8, label %47
47: ; preds = %37, %0
ret i32 0
}