#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 dot_prod(int *, int *);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char **argv) {
  int a[2] = {1 * argc, 2 * argc};
  int b[2] = {3 * argc, 4 * argc};
  printf("a.b = %i\n", dot_prod(a, b));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%eax
shl    $0x0,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x14(%rbp)
imul   $0x3,-0x8(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%eax
shl    $0x2,%eax
mov    %eax,-0x1c(%rbp)
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <dot_prod@plt>
mov    %eax,%esi
lea    0xe92(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
mov    %edi,0x10(%rsp)
lea    (%rdi,%rdi,1),%eax
mov    %eax,0x14(%rsp)
lea    (%rdi,%rdi,2),%eax
mov    %eax,0x8(%rsp)
shl    $0x2,%edi
mov    %edi,0xc(%rsp)
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1040 <dot_prod@plt>
lea    0xead(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"a.b = %i\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [2 x i32]
%7 = alloca [2 x i32]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%9 = load i32, i32* %4
%10 = mul nsw i32 1, %9
store i32 %10, i32* %8
%11 = getelementptr inbounds i32, i32* %8, i64 1
%12 = load i32, i32* %4
%13 = mul nsw i32 2, %12
store i32 %13, i32* %11
%14 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%15 = load i32, i32* %4
%16 = mul nsw i32 3, %15
store i32 %16, i32* %14
%17 = getelementptr inbounds i32, i32* %14, i64 1
%18 = load i32, i32* %4
%19 = mul nsw i32 4, %18
store i32 %19, i32* %17
%20 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%21 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%22 = call i32 @dot_prod(i32* %20, i32* %21)
%23 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %22)
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"a.b = %i\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [2 x i32]
%4 = alloca [2 x i32]
%5 = bitcast [2 x i32]* %3 to i8*
%6 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
store i32 %0, i32* %6
%7 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%8 = shl nsw i32 %0, 1
store i32 %8, i32* %7
%9 = bitcast [2 x i32]* %4 to i8*
%10 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%11 = mul nsw i32 %0, 3
store i32 %11, i32* %10
%12 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%13 = shl nsw i32 %0, 2
store i32 %13, i32* %12
%14 = call i32 @dot_prod(i32* %6, i32* %10)
%15 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %14)
ret i32 0
}