#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 intersectOrdered(int *, int, int *, int);
int *malloc(int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int *a, na, *b, nb;
  int i;
  scanf("%d", &na);
  a = malloc(sizeof(int) * na);
  for (i = 0; i < na; i++) {
    scanf("%d", &a[i]);
  }
  scanf("%d", &nb);
  b = malloc(sizeof(int) * nb);
  for (i = 0; i < nb; i++) {
    scanf("%d", &b[i]);
  }
  printf("%d", intersectOrdered(a, na, b, nb));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11ae <main+0x6e>
mov    -0x10(%rbp),%rsi
movslq -0x28(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe65(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1179 <main+0x39>
lea    0xe4b(%rip),%rdi
lea    -0x24(%rbp),%rsi
call   1050 <scanf@plt>
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    120d <main+0xcd>
mov    -0x20(%rbp),%rsi
movslq -0x28(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe06(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11d8 <main+0x98>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
call   1060 <intersectOrdered@plt>
mov    %eax,%esi
lea    0xdd7(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xeae(%rip),%rdi
mov    %rsp,%rsi
call   1050 <scanf@plt>
mov    (%rsp),%ebx
lea    0x0(,%rbx,4),%edi
call   1040 <malloc@plt>
mov    %rax,%r14
test   %ebx,%ebx
jle    119c <main+0x5c>
xor    %r12d,%r12d
lea    0xe86(%rip),%r15
mov    %r14,%rbx
nopl   (%rax)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
add    $0x1,%r12
movslq (%rsp),%rax
add    $0x4,%rbx
cmp    %rax,%r12
jl     1180 <main+0x40>
lea    0xe5d(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%r13d
lea    0x0(,%r13,4),%edi
call   1040 <malloc@plt>
mov    %rax,%r15
test   %r13d,%r13d
jle    11fd <main+0xbd>
xor    %ebp,%ebp
lea    0xe30(%rip),%r12
mov    %r15,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r12,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
add    $0x1,%rbp
movslq 0x4(%rsp),%r13
add    $0x4,%rbx
cmp    %r13,%rbp
jl     11e0 <main+0xa0>
mov    (%rsp),%esi
mov    %r14,%rdi
mov    %r15,%rdx
mov    %r13d,%ecx
call   1060 <intersectOrdered@plt>
lea    0xdeb(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%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 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* %3)
%8 = load i32, i32* %3
%9 = sext i32 %8 to i64
%10 = mul i64 4, %9
%11 = trunc i64 %10 to i32
%12 = call i32* @malloc(i32 %11)
store i32* %12, i32** %2
store i32 0, i32* %6
br label %13
13: ; preds = %23, %0
%14 = load i32, i32* %6
%15 = load i32, i32* %3
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %26
17: ; preds = %13
%18 = load i32*, i32** %2
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %18, i64 %20
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %21)
br label %23
23: ; preds = %17
%24 = load i32, i32* %6
%25 = add nsw i32 %24, 1
store i32 %25, i32* %6
br label %13
26: ; preds = %13
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%28 = load i32, i32* %5
%29 = sext i32 %28 to i64
%30 = mul i64 4, %29
%31 = trunc i64 %30 to i32
%32 = call i32* @malloc(i32 %31)
store i32* %32, i32** %4
store i32 0, i32* %6
br label %33
33: ; preds = %43, %26
%34 = load i32, i32* %6
%35 = load i32, i32* %5
%36 = icmp slt i32 %34, %35
br i1 %36, label %37, label %46
37: ; preds = %33
%38 = load i32*, i32** %4
%39 = load i32, i32* %6
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i32, i32* %38, i64 %40
%42 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %41)
br label %43
43: ; preds = %37
%44 = load i32, i32* %6
%45 = add nsw i32 %44, 1
store i32 %45, i32* %6
br label %33
46: ; preds = %33
%47 = load i32*, i32** %2
%48 = load i32, i32* %3
%49 = load i32*, i32** %4
%50 = load i32, i32* %5
%51 = call i32 @intersectOrdered(i32* %47, i32 %48, i32* %49, i32 %50)
%52 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %51)
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* %1)
%6 = load i32, i32* %1
%7 = shl i32 %6, 2
%8 = call i32* @malloc(i32 %7)
%9 = icmp sgt i32 %6, 0
br i1 %9, label %10, label %18
10: ; preds = %0, %10
%11 = phi i64 [ %14, %10 ], [ 0, %0 ]
%12 = getelementptr inbounds i32, i32* %8, i64 %11
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %12)
%14 = add nuw nsw i64 %11, 1
%15 = load i32, i32* %1
%16 = sext i32 %15 to i64
%17 = icmp slt i64 %14, %16
br i1 %17, label %10, label %18
18: ; preds = %10, %0
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%20 = load i32, i32* %2
%21 = shl i32 %20, 2
%22 = call i32* @malloc(i32 %21)
%23 = icmp sgt i32 %20, 0
br i1 %23, label %24, label %32
24: ; preds = %18, %24
%25 = phi i64 [ %28, %24 ], [ 0, %18 ]
%26 = getelementptr inbounds i32, i32* %22, i64 %25
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %26)
%28 = add nuw nsw i64 %25, 1
%29 = load i32, i32* %2
%30 = sext i32 %29 to i64
%31 = icmp slt i64 %28, %30
br i1 %31, label %24, label %32
32: ; preds = %24, %18
%33 = phi i32 [ %20, %18 ], [ %29, %24 ]
%34 = load i32, i32* %1
%35 = call i32 @intersectOrdered(i32* %8, i32 %34, i32* %22, i32 %33)
%36 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %35)
ret i32 0
}