#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*/ free(int *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
scalar_t__ set_same(int *, int, int *, int);
int main() {
  int n1, n2, i;
  int *array1;
  int *array2;
  scanf("%d", &n1);
  array1 = (int *)malloc(n1 * sizeof(int));
  for (i = 0; i < n1; i++)
    scanf("%d", &array1[i]);
  scanf("%d", &n2);
  array2 = (int *)malloc(n2 * sizeof(int));
  for (i = 0; i < n2; i++)
    scanf("%d", &array2[i]);
  if (set_same(array1, n1, array2, n2))
    printf("SAME\n");
  else
    printf("NO\n");
  free(array1);
  free(array2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11be <main+0x6e>
mov    -0x18(%rbp),%rsi
movslq -0x10(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe55(%rip),%rdi
call   1070 <scanf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1189 <main+0x39>
lea    0xe3b(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1070 <scanf@plt>
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    121d <main+0xcd>
mov    -0x20(%rbp),%rsi
movslq -0x10(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xdf6(%rip),%rdi
call   1070 <scanf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11e8 <main+0x98>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0xc(%rbp),%ecx
call   1040 <set_same@plt>
cmp    $0x0,%rax
je     124b <main+0xfb>
lea    0xdc2(%rip),%rdi
call   1050 <printf@plt>
jmp    1257 <main+0x107>
lea    0xdb7(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xe9c(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1070 <scanf@plt>
mov    0x8(%rsp),%edi
shl    $0x2,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
cmpl   $0x0,0x8(%rsp)
jle    11bd <main+0x6d>
xor    %r12d,%r12d
lea    0xe72(%rip),%r15
mov    %r14,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
add    $0x1,%r12
movslq 0x8(%rsp),%rax
add    $0x4,%rbx
cmp    %rax,%r12
jl     11a0 <main+0x50>
lea    0xe3c(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
mov    0xc(%rsp),%edi
shl    $0x2,%edi
call   1060 <malloc@plt>
mov    %rax,%r15
mov    0xc(%rsp),%ecx
test   %ecx,%ecx
jle    121d <main+0xcd>
xor    %r13d,%r13d
lea    0xe11(%rip),%r12
mov    %r15,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r12,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
add    $0x1,%r13
movslq 0xc(%rsp),%rcx
add    $0x4,%rbx
cmp    %rcx,%r13
jl     1200 <main+0xb0>
mov    0x8(%rsp),%esi
mov    %r14,%rdi
mov    %r15,%rdx
call   1040 <set_same@plt>
test   %rax,%rax
lea    0xdcd(%rip),%rax
lea    0xdc9(%rip),%rdi
cmove  %rax,%rdi
call   1050 <puts@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [6 x i8] c"SAME\0A\00"
@.str.2 = [4 x i8] c"NO\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
store i32 0, i32* %1
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%8 = load i32, i32* %2
%9 = sext i32 %8 to i64
%10 = mul i64 %9, 4
%11 = trunc i64 %10 to i32
%12 = call i64 @malloc(i32 %11)
%13 = inttoptr i64 %12 to i32*
store i32* %13, i32** %5
store i32 0, i32* %4
br label %14
14: ; preds = %24, %0
%15 = load i32, i32* %4
%16 = load i32, i32* %2
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %27
18: ; preds = %14
%19 = load i32*, i32** %5
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %19, i64 %21
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %22)
br label %24
24: ; preds = %18
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %14
27: ; preds = %14
%28 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%29 = load i32, i32* %3
%30 = sext i32 %29 to i64
%31 = mul i64 %30, 4
%32 = trunc i64 %31 to i32
%33 = call i64 @malloc(i32 %32)
%34 = inttoptr i64 %33 to i32*
store i32* %34, i32** %6
store i32 0, i32* %4
br label %35
35: ; preds = %45, %27
%36 = load i32, i32* %4
%37 = load i32, i32* %3
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %48
39: ; preds = %35
%40 = load i32*, i32** %6
%41 = load i32, i32* %4
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i32, i32* %40, 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 = %39
%46 = load i32, i32* %4
%47 = add nsw i32 %46, 1
store i32 %47, i32* %4
br label %35
48: ; preds = %35
%49 = load i32*, i32** %5
%50 = load i32, i32* %2
%51 = load i32*, i32** %6
%52 = load i32, i32* %3
%53 = call i64 @set_same(i32* %49, i32 %50, i32* %51, i32 %52)
%54 = icmp ne i64 %53, 0
br i1 %54, label %55, label %57
55: ; preds = %48
%56 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %59
57: ; preds = %48
%58 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %59
59: ; preds = %57, %55
%60 = load i32*, i32** %5
%61 = call i32 @free(i32* %60)
%62 = load i32*, i32** %6
%63 = call i32 @free(i32* %62)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@str = [3 x i8] c"NO\00"
@str.3 = [5 x i8] c"SAME\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* %1)
%6 = load i32, i32* %1
%7 = shl i32 %6, 2
%8 = call i64 @malloc(i32 %7)
%9 = inttoptr i64 %8 to i32*
%10 = load i32, i32* %1
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %20
12: ; preds = %0, %12
%13 = phi i64 [ %16, %12 ], [ 0, %0 ]
%14 = getelementptr inbounds i32, i32* %9, i64 %13
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %14)
%16 = add nuw nsw i64 %13, 1
%17 = load i32, i32* %1
%18 = sext i32 %17 to i64
%19 = icmp slt i64 %16, %18
br i1 %19, label %12, label %20
20: ; preds = %12, %0
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%22 = load i32, i32* %2
%23 = shl i32 %22, 2
%24 = call i64 @malloc(i32 %23)
%25 = inttoptr i64 %24 to i32*
%26 = load i32, i32* %2
%27 = icmp sgt i32 %26, 0
br i1 %27, label %28, label %36
28: ; preds = %20, %28
%29 = phi i64 [ %32, %28 ], [ 0, %20 ]
%30 = getelementptr inbounds i32, i32* %25, i64 %29
%31 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %30)
%32 = add nuw nsw i64 %29, 1
%33 = load i32, i32* %2
%34 = sext i32 %33 to i64
%35 = icmp slt i64 %32, %34
br i1 %35, label %28, label %36
36: ; preds = %28, %20
%37 = phi i32 [ %26, %20 ], [ %33, %28 ]
%38 = load i32, i32* %1
%39 = call i64 @set_same(i32* %9, i32 %38, i32* %25, i32 %37)
%40 = icmp eq i64 %39, 0
%41 = select i1 %40, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @str.3, i64 0, i64 0)
%42 = call i32 @puts(i8* dereferenceable(1) %41)
%43 = call i32 @free(i32* %9)
%44 = call i32 @free(i32* %25)
ret i32 0
}