#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 getSize();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ readVec(int *, int);
int scalar_product(int *, int *, int);
int main() {
  int size = getSize();
  int u[size], v[size];
  printf("\nNow entering numbers for first vector:\n");
  readVec(u, size);
  printf("\nNow entering numbers for second vector:\n");
  readVec(v, size);
  printf("\nResult = %d\n\n", scalar_product(v, u, size));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
call   1060 <getSize@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1030 <readVec@plt>
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1030 <readVec@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x8(%rbp),%edx
call   1050 <scalar_product@plt>
mov    %eax,%esi
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1070 <getSize@plt>
mov    %eax,%r14d
mov    %eax,%eax
mov    %rsp,%r15
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    %rsp,%rbx
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xe84(%rip),%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
mov    %r14d,%esi
call   1030 <readVec@plt>
lea    0xe95(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
call   1030 <readVec@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14d,%edx
call   1060 <scalar_product@plt>
lea    0xe39(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [41 x i8] c"\0ANow entering numbers for first vector:\0A\00"
@.str.1 = [42 x i8] c"\0ANow entering numbers for second vector:\0A\00"
@.str.2 = [15 x i8] c"\0AResult = %d\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
store i32 0, i32* %1
%6 = call i32 (...) @getSize()
store i32 %6, i32* %2
%7 = load i32, i32* %2
%8 = zext i32 %7 to i64
%9 = call i8* @llvm.stacksave()
store i8* %9, i8** %3
%10 = alloca i32, i64 %8
store i64 %8, i64* %4
%11 = load i32, i32* %2
%12 = zext i32 %11 to i64
%13 = alloca i32, i64 %12
store i64 %12, i64* %5
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%15 = load i32, i32* %2
%16 = call i32 @readVec(i32* %10, i32 %15)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
%18 = load i32, i32* %2
%19 = call i32 @readVec(i32* %13, i32 %18)
%20 = load i32, i32* %2
%21 = call i32 @scalar_product(i32* %13, i32* %10, i32 %20)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %21)
store i32 0, i32* %1
%23 = load i8*, i8** %3
%24 = load i32, i32* %1
ret i32 %24
}

LLVM IR (-O2):
@.str.2 = [15 x i8] c"\0AResult = %d\0A\0A\00"
@str = [40 x i8] c"\0ANow entering numbers for first vector:\00"
@str.3 = [41 x i8] c"\0ANow entering numbers for second vector:\00"
define i32 @main() {
%1 = tail call i32 (...) @getSize()
%2 = zext i32 %1 to i64
%3 = alloca i32, i64 %2
%4 = alloca i32, i64 %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
%6 = call i32 @readVec(i32* %3, i32 %1)
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.3, i64 0, i64 0))
%8 = call i32 @readVec(i32* %4, i32 %1)
%9 = call i32 @scalar_product(i32* %4, i32* %3, i32 %1)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %9)
ret i32 0
}