#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*/ printf(char *, ...);
void interseccao(int a[], int b[], int tamA, int tamB) {
  int i, j;
  for (i = 0; i < tamB; i++) {
    for (j = 0; j < tamA; j++) {
      if (a[i] == b[j])
        printf("%d, ", a[i]);
    }
  }
  printf("\b \b");
  printf("\b \b");
  printf("}\n\n");
}


x86 assembly (clang, -O0):
<interseccao>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11a7 <interseccao+0x97>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1194 <interseccao+0x84>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x10(%rbp),%rcx
movslq -0x20(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jne    1181 <interseccao+0x71>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1186 <interseccao+0x76>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1140 <interseccao+0x30>
jmp    1199 <interseccao+0x89>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112d <interseccao+0x1d>
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<interseccao>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edx,0xc(%rsp)
test   %ecx,%ecx
jle    11a1 <interseccao+0x81>
mov    %rsi,%r13
mov    %rdi,%rbp
mov    %ecx,%eax
mov    %rax,0x10(%rsp)
mov    0xc(%rsp),%ebx
lea    0xeb2(%rip),%r15
xor    %r14d,%r14d
jmp    116b <interseccao+0x4b>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%r14
cmp    0x10(%rsp),%r14
je     11a1 <interseccao+0x81>
cmpl   $0x0,0xc(%rsp)
jle    1160 <interseccao+0x40>
xor    %r12d,%r12d
jmp    1189 <interseccao+0x69>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r12
cmp    %r12,%rbx
je     1160 <interseccao+0x40>
mov    0x0(%rbp,%r14,4),%esi
cmp    0x0(%r13,%r12,4),%esi
jne    1180 <interseccao+0x60>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1180 <interseccao+0x60>
lea    0xe5d(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe46(%rip),%rdi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <puts@plt>

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

LLVM IR (-O2):
@.str = [5 x i8] c"%d, \00"
@.str.1 = [4 x i8] c"\08 \08\00"
@str = [3 x i8] c"}\0A\00"
define void @interseccao(i32* nocapture %0, i32* nocapture %1, i32 %2, i32 %3) {
%5 = icmp sgt i32 %3, 0
br i1 %5, label %6, label %28
6: ; preds = %4
%7 = icmp sgt i32 %2, 0
%8 = zext i32 %3 to i64
%9 = zext i32 %2 to i64
br label %10
10: ; preds = %6, %25
%11 = phi i64 [ 0, %6 ], [ %26, %25 ]
br i1 %7, label %12, label %25
12: ; preds = %10
%13 = getelementptr inbounds i32, i32* %0, i64 %11
br label %14
14: ; preds = %12, %22
%15 = phi i64 [ 0, %12 ], [ %23, %22 ]
%16 = load i32, i32* %13
%17 = getelementptr inbounds i32, i32* %1, i64 %15
%18 = load i32, i32* %17
%19 = icmp eq i32 %16, %18
br i1 %19, label %20, label %22
20: ; preds = %14
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %16)
br label %22
22: ; preds = %14, %20
%23 = add nuw nsw i64 %15, 1
%24 = icmp eq i64 %23, %9
br i1 %24, label %25, label %14
25: ; preds = %22, %10
%26 = add nuw nsw i64 %11, 1
%27 = icmp eq i64 %26, %8
br i1 %27, label %28, label %10
28: ; preds = %25, %4
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
ret void
}