#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 *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int produto_escalar(int, int *, int *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ read_array(int, int *);
int /*<<< orphan*/ scanf(char *, int *);
int main(int argc, const char *argv[]) {
  int *v1, *v2, n, cont;
  puts("Informe o tamanho do vetor:");
  scanf("%d", &n);
  v1 = (malloc(sizeof(int) * n));
  v2 = (malloc(sizeof(int) * n));
  printf("Lendo o primeiro vetor...\n");
  read_array(n, v1);
  printf("Lendo o segundo vetor...\n");
  read_array(n, v2);
  printf("O produto escalar é: %d\n", produto_escalar(n, v1, v2));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe83(%rip),%rdi
call   1030 <puts@plt>
lea    0xe93(%rip),%rdi
lea    -0x24(%rbp),%rsi
call   1060 <scanf@plt>
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1070 <read_array@plt>
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1070 <read_array@plt>
mov    -0x24(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1080 <produto_escalar@plt>
mov    %eax,%esi
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xe96(%rip),%rdi
call   1030 <puts@plt>
lea    0xea6(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%ebp
shl    $0x2,%ebp
mov    %ebp,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    %ebp,%edi
call   1050 <malloc@plt>
mov    %rax,%rbp
lea    0xe97(%rip),%rdi
call   1030 <puts@plt>
mov    0x4(%rsp),%edi
mov    %rbx,%rsi
call   1070 <read_array@plt>
lea    0xe99(%rip),%rdi
call   1030 <puts@plt>
mov    0x4(%rsp),%edi
mov    %rbp,%rsi
call   1070 <read_array@plt>
mov    0x4(%rsp),%edi
mov    %rbx,%rsi
mov    %rbp,%rdx
call   1080 <produto_escalar@plt>
lea    0xe3e(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Informe o tamanho do vetor:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [27 x i8] c"Lendo o primeiro vetor...\0A\00"
@.str.3 = [26 x i8] c"Lendo o segundo vetor...\0A\00"
@.str.4 = [26 x i8] c"O produto escalar \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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32 @puts(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%12 = load i32, i32* %8
%13 = sext i32 %12 to i64
%14 = mul i64 4, %13
%15 = trunc i64 %14 to i32
%16 = call i32* @malloc(i32 %15)
store i32* %16, i32** %6
%17 = load i32, i32* %8
%18 = sext i32 %17 to i64
%19 = mul i64 4, %18
%20 = trunc i64 %19 to i32
%21 = call i32* @malloc(i32 %20)
store i32* %21, i32** %7
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%23 = load i32, i32* %8
%24 = load i32*, i32** %6
%25 = call i32 @read_array(i32 %23, i32* %24)
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%27 = load i32, i32* %8
%28 = load i32*, i32** %7
%29 = call i32 @read_array(i32 %27, i32* %28)
%30 = load i32, i32* %8
%31 = load i32*, i32** %6
%32 = load i32*, i32** %7
%33 = call i32 @produto_escalar(i32 %30, i32* %31, i32* %32)
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %33)
ret i32 0
}

LLVM IR (-O2):
@.str = [28 x i8] c"Informe o tamanho do vetor:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.4 = [26 x i8] c"O produto escalar \C3\A9: %d\0A\00"
@str = [26 x i8] c"Lendo o primeiro vetor...\00"
@str.5 = [25 x i8] c"Lendo o segundo vetor...\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 ([28 x i8], [28 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 i32* @malloc(i32 %8)
%10 = call i32* @malloc(i32 %8)
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%12 = load i32, i32* %3
%13 = call i32 @read_array(i32 %12, i32* %9)
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.5, i64 0, i64 0))
%15 = load i32, i32* %3
%16 = call i32 @read_array(i32 %15, i32* %10)
%17 = load i32, i32* %3
%18 = call i32 @produto_escalar(i32 %17, i32* %9, i32* %10)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %18)
ret i32 0
}