#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 *intersection(int *, int, int *, int, int *);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  int arr1[] = {2, 1};
  int arr2[] = {1, 2};
  int *res = NULL;
  int size = 0;
  res = intersection(arr1, 2, arr2, 2, &size);
  for (int i = 0; i < size; i++) {
    printf("%d ", res[i]);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0xc(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
lea    -0xc(%rbp),%rdi
lea    -0x14(%rbp),%rdx
mov    $0x2,%ecx
lea    -0x24(%rbp),%r8
mov    %ecx,%esi
call   1040 <intersection@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    11aa <main+0x8a>
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1177 <main+0x57>
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
movabs $0x100000002,%rax
mov    %rax,0x18(%rsp)
movabs $0x200000001,%rax
mov    %rax,0x10(%rsp)
movl   $0x0,0xc(%rsp)
lea    0x18(%rsp),%rdi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%r8
mov    $0x2,%esi
mov    $0x2,%ecx
call   1050 <intersection@plt>
cmpl   $0x0,0xc(%rsp)
jle    11ac <main+0x7c>
mov    %rax,%r15
lea    0xe72(%rip),%r14
xor    %ebx,%ebx
mov    (%r15,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     1190 <main+0x60>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.arr1 = [2 x i32] [i32 2, i32 1]
@__const.main.arr2 = [2 x i32] [i32 1, i32 2]
@.str = [4 x i8] c"%d \00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [2 x i32]
%3 = alloca [2 x i32]
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = bitcast [2 x i32]* %2 to i8*
%8 = bitcast [2 x i32]* %3 to i8*
store i32* null, i32** %4
store i32 0, i32* %5
%9 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%10 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%11 = call i32* @intersection(i32* %9, i32 2, i32* %10, i32 2, i32* %5)
store i32* %11, i32** %4
store i32 0, i32* %6
br label %12
12: ; preds = %23, %0
%13 = load i32, i32* %6
%14 = load i32, i32* %5
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %26
16: ; preds = %12
%17 = load i32*, i32** %4
%18 = load i32, i32* %6
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %17, i64 %19
%21 = load i32, i32* %20
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %21)
br label %23
23: ; preds = %16
%24 = load i32, i32* %6
%25 = add nsw i32 %24, 1
store i32 %25, i32* %6
br label %12
26: ; preds = %12
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
define i32 @main() {
%1 = alloca i64
%2 = alloca i64
%3 = alloca i32
%4 = bitcast i64* %1 to i8*
store i64 4294967298, i64* %1
%5 = bitcast i64* %2 to i8*
store i64 8589934593, i64* %2
%6 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%7 = bitcast i64* %1 to i32*
%8 = bitcast i64* %2 to i32*
%9 = call i32* @intersection(i32* %7, i32 2, i32* %8, i32 2, i32* %3)
%10 = load i32, i32* %3
%11 = icmp sgt i32 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %14, %0
%13 = call i32 @putchar(i32 10)
ret i32 0
14: ; preds = %0, %14
%15 = phi i64 [ %19, %14 ], [ 0, %0 ]
%16 = getelementptr inbounds i32, i32* %9, i64 %15
%17 = load i32, i32* %16
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = add nuw nsw i64 %15, 1
%20 = load i32, i32* %3
%21 = sext i32 %20 to i64
%22 = icmp slt i64 %19, %21
br i1 %22, label %14, label %12
}