#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*/ random();
int /*<<< orphan*/ vector_madd_asm(int *, int *, int *, int *,
                                   unsigned int const);
int /*<<< orphan*/ vector_set(int *, int /*<<< orphan*/, unsigned int const);
void bench_madd() {
  const static unsigned int size = 256;
  int i, j;
  int a[size];
  int b[size];
  int c[size];
  int res[size];
  for (i = 0; i < 40; i++) {
    vector_set(a, random(), size);
    vector_set(b, random(), size);
    vector_set(c, random(), size);
    for (j = 0; j < 20; j++)
      vector_madd_asm(res, a, b, c, size);
  }
}


x86 assembly (clang, -O0):
<bench_madd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1010,%rsp
mov    %rsp,%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x4(%rbp)
cmpl   $0x28,-0x4(%rbp)
jge    11fa <bench_madd+0xca>
mov    $0x0,%al
call   1040 <random@plt>
mov    %eax,%esi
lea    -0x410(%rbp),%rdi
mov    $0x100,%edx
call   1050 <vector_set@plt>
mov    $0x0,%al
call   1040 <random@plt>
mov    %eax,%esi
lea    -0x810(%rbp),%rdi
mov    $0x100,%edx
call   1050 <vector_set@plt>
mov    $0x0,%al
call   1040 <random@plt>
mov    %eax,%esi
lea    -0xc10(%rbp),%rdi
mov    $0x100,%edx
call   1050 <vector_set@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x14,-0x8(%rbp)
jge    11e7 <bench_madd+0xb7>
lea    -0x1010(%rbp),%rdi
lea    -0x410(%rbp),%rsi
lea    -0x810(%rbp),%rdx
lea    -0xc10(%rbp),%rcx
mov    $0x100,%r8d
call   1030 <vector_madd_asm@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11a8 <bench_madd+0x78>
jmp    11ec <bench_madd+0xbc>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1149 <bench_madd+0x19>
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
add    $0x1010,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bench_madd>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1000,%rsp
mov    $0x28,%ebp
lea    0xc00(%rsp),%r14
lea    0x800(%rsp),%r15
lea    0x400(%rsp),%rbx
mov    %rsp,%r12
nop
xor    %eax,%eax
call   1040 <random@plt>
mov    %r14,%rdi
mov    %eax,%esi
mov    $0x100,%edx
call   1050 <vector_set@plt>
xor    %eax,%eax
call   1040 <random@plt>
mov    %r15,%rdi
mov    %eax,%esi
mov    $0x100,%edx
call   1050 <vector_set@plt>
xor    %eax,%eax
call   1040 <random@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x100,%edx
call   1050 <vector_set@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %rbx,%rcx
mov    $0x100,%r8d
call   1030 <vector_madd_asm@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %rbx,%rcx
mov    $0x100,%r8d
call   1030 <vector_madd_asm@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %rbx,%rcx
mov    $0x100,%r8d
call   1030 <vector_madd_asm@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %rbx,%rcx
mov    $0x100,%r8d
call   1030 <vector_madd_asm@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %rbx,%rcx
mov    $0x100,%r8d
call   1030 <vector_madd_asm@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %rbx,%rcx
mov    $0x100,%r8d
call   1030 <vector_madd_asm@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %rbx,%rcx
mov    $0x100,%r8d
call   1030 <vector_madd_asm@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %rbx,%rcx
mov    $0x100,%r8d
call   1030 <vector_madd_asm@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %rbx,%rcx
mov    $0x100,%r8d
call   1030 <vector_madd_asm@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %rbx,%rcx
mov    $0x100,%r8d
call   1030 <vector_madd_asm@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %rbx,%rcx
mov    $0x100,%r8d
call   1030 <vector_madd_asm@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %rbx,%rcx
mov    $0x100,%r8d
call   1030 <vector_madd_asm@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %rbx,%rcx
mov    $0x100,%r8d
call   1030 <vector_madd_asm@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %rbx,%rcx
mov    $0x100,%r8d
call   1030 <vector_madd_asm@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %rbx,%rcx
mov    $0x100,%r8d
call   1030 <vector_madd_asm@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %rbx,%rcx
mov    $0x100,%r8d
call   1030 <vector_madd_asm@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %rbx,%rcx
mov    $0x100,%r8d
call   1030 <vector_madd_asm@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %rbx,%rcx
mov    $0x100,%r8d
call   1030 <vector_madd_asm@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %rbx,%rcx
mov    $0x100,%r8d
call   1030 <vector_madd_asm@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %rbx,%rcx
mov    $0x100,%r8d
call   1030 <vector_madd_asm@plt>
add    $0xffffffff,%ebp
jne    1160 <bench_madd+0x30>
add    $0x1000,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@bench_madd.size = internal constant i32 256
define void @bench_madd() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = call i8* @llvm.stacksave()
store i8* %4, i8** %3
%5 = alloca i32, i64 256
%6 = alloca i32, i64 256
%7 = alloca i32, i64 256
%8 = alloca i32, i64 256
store i32 0, i32* %1
br label %9
9: ; preds = %28, %0
%10 = load i32, i32* %1
%11 = icmp slt i32 %10, 40
br i1 %11, label %12, label %31
12: ; preds = %9
%13 = call i32 (...) @random()
%14 = call i32 @vector_set(i32* %5, i32 %13, i32 256)
%15 = call i32 (...) @random()
%16 = call i32 @vector_set(i32* %6, i32 %15, i32 256)
%17 = call i32 (...) @random()
%18 = call i32 @vector_set(i32* %7, i32 %17, i32 256)
store i32 0, i32* %2
br label %19
19: ; preds = %24, %12
%20 = load i32, i32* %2
%21 = icmp slt i32 %20, 20
br i1 %21, label %22, label %27
22: ; preds = %19
%23 = call i32 @vector_madd_asm(i32* %8, i32* %5, i32* %6, i32* %7, i32 256)
br label %24
24: ; preds = %22
%25 = load i32, i32* %2
%26 = add nsw i32 %25, 1
store i32 %26, i32* %2
br label %19
27: ; preds = %19
br label %28
28: ; preds = %27
%29 = load i32, i32* %1
%30 = add nsw i32 %29, 1
store i32 %30, i32* %1
br label %9
31: ; preds = %9
%32 = load i8*, i8** %3
ret void
}

LLVM IR (-O2):
define void @bench_madd() {
%1 = alloca [256 x i32]
%2 = alloca [256 x i32]
%3 = alloca [256 x i32]
%4 = alloca [256 x i32]
%5 = getelementptr inbounds [256 x i32], [256 x i32]* %4, i64 0, i64 0
%6 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 0
%7 = getelementptr inbounds [256 x i32], [256 x i32]* %2, i64 0, i64 0
%8 = getelementptr inbounds [256 x i32], [256 x i32]* %1, i64 0, i64 0
br label %9
9: ; preds = %0, %9
%10 = phi i32 [ 0, %0 ], [ %37, %9 ]
%11 = call i32 (...) @random()
%12 = call i32 @vector_set(i32* %8, i32 %11, i32 256)
%13 = call i32 (...) @random()
%14 = call i32 @vector_set(i32* %7, i32 %13, i32 256)
%15 = call i32 (...) @random()
%16 = call i32 @vector_set(i32* %6, i32 %15, i32 256)
%17 = call i32 @vector_madd_asm(i32* %5, i32* %8, i32* %7, i32* %6, i32 256)
%18 = call i32 @vector_madd_asm(i32* %5, i32* %8, i32* %7, i32* %6, i32 256)
%19 = call i32 @vector_madd_asm(i32* %5, i32* %8, i32* %7, i32* %6, i32 256)
%20 = call i32 @vector_madd_asm(i32* %5, i32* %8, i32* %7, i32* %6, i32 256)
%21 = call i32 @vector_madd_asm(i32* %5, i32* %8, i32* %7, i32* %6, i32 256)
%22 = call i32 @vector_madd_asm(i32* %5, i32* %8, i32* %7, i32* %6, i32 256)
%23 = call i32 @vector_madd_asm(i32* %5, i32* %8, i32* %7, i32* %6, i32 256)
%24 = call i32 @vector_madd_asm(i32* %5, i32* %8, i32* %7, i32* %6, i32 256)
%25 = call i32 @vector_madd_asm(i32* %5, i32* %8, i32* %7, i32* %6, i32 256)
%26 = call i32 @vector_madd_asm(i32* %5, i32* %8, i32* %7, i32* %6, i32 256)
%27 = call i32 @vector_madd_asm(i32* %5, i32* %8, i32* %7, i32* %6, i32 256)
%28 = call i32 @vector_madd_asm(i32* %5, i32* %8, i32* %7, i32* %6, i32 256)
%29 = call i32 @vector_madd_asm(i32* %5, i32* %8, i32* %7, i32* %6, i32 256)
%30 = call i32 @vector_madd_asm(i32* %5, i32* %8, i32* %7, i32* %6, i32 256)
%31 = call i32 @vector_madd_asm(i32* %5, i32* %8, i32* %7, i32* %6, i32 256)
%32 = call i32 @vector_madd_asm(i32* %5, i32* %8, i32* %7, i32* %6, i32 256)
%33 = call i32 @vector_madd_asm(i32* %5, i32* %8, i32* %7, i32* %6, i32 256)
%34 = call i32 @vector_madd_asm(i32* %5, i32* %8, i32* %7, i32* %6, i32 256)
%35 = call i32 @vector_madd_asm(i32* %5, i32* %8, i32* %7, i32* %6, i32 256)
%36 = call i32 @vector_madd_asm(i32* %5, i32* %8, i32* %7, i32* %6, i32 256)
%37 = add nuw nsw i32 %10, 1
%38 = icmp eq i32 %37, 40
br i1 %38, label %39, label %9
39: ; preds = %9
ret void
}