#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*/ inters(int, int *, int *, int *);
int /*<<< orphan*/ ler_vetor(int, int *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, int *);
int taminters(int, int *, int *);
int main(int argc, const char *argv[]) {
  int *a, *b, *c, n, cont;
  puts("Informe o numero de elementos:");
  scanf("%d", &n);
  a = (int *)(malloc(sizeof(int) * n));
  b = (int *)(malloc(sizeof(int) * n));
  c = (int *)(malloc(sizeof(int) * taminters(n, a, b)));
  ler_vetor(n, a);
  ler_vetor(n, b);
  inters(n, a, b, c);
  printf("O vetor interseção é:\n");
  for (cont = 0; cont < taminters(n, a, b); cont++) {
    printf("%d ", c[cont]);
  }
  printf("\nO tamanho do vetor intersecção é: %d\n", taminters(n, a, b));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe73(%rip),%rdi
call   1030 <puts@plt>
lea    0xe86(%rip),%rdi
lea    -0x2c(%rbp),%rsi
call   1070 <scanf@plt>
movslq -0x2c(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
movslq -0x2c(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x2c(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1090 <taminters@plt>
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x2c(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1040 <ler_vetor@plt>
mov    -0x2c(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1040 <ler_vetor@plt>
mov    -0x2c(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1080 <inters@plt>
lea    0xe06(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x2c(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1090 <taminters@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
cmp    %ecx,%eax
jge    1274 <main+0x104>
mov    -0x28(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xddd(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    122a <main+0xba>
mov    -0x2c(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1090 <taminters@plt>
mov    %eax,%esi
lea    0xdb3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xe7c(%rip),%rdi
call   1030 <puts@plt>
lea    0xe8f(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
mov    0xc(%rsp),%edi
shl    $0x2,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
mov    0xc(%rsp),%edi
shl    $0x2,%edi
call   1060 <malloc@plt>
mov    %rax,%r15
mov    0xc(%rsp),%edi
mov    %r14,%rsi
mov    %rax,%rdx
call   1090 <taminters@plt>
lea    0x0(,%rax,4),%edi
call   1060 <malloc@plt>
mov    %rax,%r13
mov    0xc(%rsp),%edi
mov    %r14,%rsi
call   1040 <ler_vetor@plt>
mov    0xc(%rsp),%edi
mov    %r15,%rsi
call   1040 <ler_vetor@plt>
mov    0xc(%rsp),%edi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %r13,%rcx
call   1080 <inters@plt>
lea    0xe49(%rip),%rdi
call   1030 <puts@plt>
mov    0xc(%rsp),%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   1090 <taminters@plt>
test   %eax,%eax
jle    1259 <main+0xe9>
lea    0xdfc(%rip),%r12
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    0x0(%r13,%rbx,4),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
mov    0xc(%rsp),%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   1090 <taminters@plt>
cltq
cmp    %rax,%rbx
jl     1230 <main+0xc0>
mov    0xc(%rsp),%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   1090 <taminters@plt>
lea    0xdb7(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Informe o numero de elementos:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [26 x i8] c"O vetor interse\C3\A7\C3\A3o \C3\A9:\0A\00"
@.str.3 = [4 x i8] c"%d \00"
@.str.4 = [42 x i8] c"\0AO tamanho do vetor intersec\C3\A7\C3\A3o \C3\A9: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = call i32 @puts(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %9)
%13 = load i32, i32* %9
%14 = sext i32 %13 to i64
%15 = mul i64 4, %14
%16 = trunc i64 %15 to i32
%17 = call i64 @malloc(i32 %16)
%18 = inttoptr i64 %17 to i32*
store i32* %18, i32** %6
%19 = load i32, i32* %9
%20 = sext i32 %19 to i64
%21 = mul i64 4, %20
%22 = trunc i64 %21 to i32
%23 = call i64 @malloc(i32 %22)
%24 = inttoptr i64 %23 to i32*
store i32* %24, i32** %7
%25 = load i32, i32* %9
%26 = load i32*, i32** %6
%27 = load i32*, i32** %7
%28 = call i32 @taminters(i32 %25, i32* %26, i32* %27)
%29 = sext i32 %28 to i64
%30 = mul i64 4, %29
%31 = trunc i64 %30 to i32
%32 = call i64 @malloc(i32 %31)
%33 = inttoptr i64 %32 to i32*
store i32* %33, i32** %8
%34 = load i32, i32* %9
%35 = load i32*, i32** %6
%36 = call i32 @ler_vetor(i32 %34, i32* %35)
%37 = load i32, i32* %9
%38 = load i32*, i32** %7
%39 = call i32 @ler_vetor(i32 %37, i32* %38)
%40 = load i32, i32* %9
%41 = load i32*, i32** %6
%42 = load i32*, i32** %7
%43 = load i32*, i32** %8
%44 = call i32 @inters(i32 %40, i32* %41, i32* %42, i32* %43)
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %10
br label %46
46: ; preds = %60, %2
%47 = load i32, i32* %10
%48 = load i32, i32* %9
%49 = load i32*, i32** %6
%50 = load i32*, i32** %7
%51 = call i32 @taminters(i32 %48, i32* %49, i32* %50)
%52 = icmp slt i32 %47, %51
br i1 %52, label %53, label %63
53: ; preds = %46
%54 = load i32*, i32** %8
%55 = load i32, i32* %10
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i32, i32* %54, i64 %56
%58 = load i32, i32* %57
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %58)
br label %60
60: ; preds = %53
%61 = load i32, i32* %10
%62 = add nsw i32 %61, 1
store i32 %62, i32* %10
br label %46
63: ; preds = %46
%64 = load i32, i32* %9
%65 = load i32*, i32** %6
%66 = load i32*, i32** %7
%67 = call i32 @taminters(i32 %64, i32* %65, i32* %66)
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i32 %67)
ret i32 0
}

LLVM IR (-O2):
@.str = [31 x i8] c"Informe o numero de elementos:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [4 x i8] c"%d \00"
@.str.4 = [42 x i8] c"\0AO tamanho do vetor intersec\C3\A7\C3\A3o \C3\A9: %d\0A\00"
@str = [25 x i8] c"O vetor interse\C3\A7\C3\A3o \C3\A9:\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%7 = load i32, i32* %3
%8 = shl i32 %7, 2
%9 = call i64 @malloc(i32 %8)
%10 = inttoptr i64 %9 to i32*
%11 = load i32, i32* %3
%12 = shl i32 %11, 2
%13 = call i64 @malloc(i32 %12)
%14 = inttoptr i64 %13 to i32*
%15 = load i32, i32* %3
%16 = call i32 @taminters(i32 %15, i32* %10, i32* %14)
%17 = shl i32 %16, 2
%18 = call i64 @malloc(i32 %17)
%19 = inttoptr i64 %18 to i32*
%20 = load i32, i32* %3
%21 = call i32 @ler_vetor(i32 %20, i32* %10)
%22 = load i32, i32* %3
%23 = call i32 @ler_vetor(i32 %22, i32* %14)
%24 = load i32, i32* %3
%25 = call i32 @inters(i32 %24, i32* %10, i32* %14, i32* %19)
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%27 = load i32, i32* %3
%28 = call i32 @taminters(i32 %27, i32* %10, i32* %14)
%29 = icmp sgt i32 %28, 0
br i1 %29, label %30, label %40
30: ; preds = %2, %30
%31 = phi i64 [ %35, %30 ], [ 0, %2 ]
%32 = getelementptr inbounds i32, i32* %19, i64 %31
%33 = load i32, i32* %32
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %33)
%35 = add nuw nsw i64 %31, 1
%36 = load i32, i32* %3
%37 = call i32 @taminters(i32 %36, i32* %10, i32* %14)
%38 = sext i32 %37 to i64
%39 = icmp slt i64 %35, %38
br i1 %39, label %30, label %40
40: ; preds = %30, %2
%41 = load i32, i32* %3
%42 = call i32 @taminters(i32 %41, i32* %10, i32* %14)
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i32 %42)
ret i32 0
}