#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 */
typedef int int32_t;

/* Variables and functions */
int /*<<< orphan*/ add(int, int *, int *, int, int *);
int *malloc(int);
int random();
int main(void) {
  const int size = 64;
  int sizeBytes = size * sizeof(int32_t);
  int32_t *x = malloc(sizeBytes);
  int32_t *y = malloc(sizeBytes);
  int32_t *s = malloc(sizeBytes);
  int scalar = 3;
  for (int i = 0; i < size; ++i) {
    x[i] = random() % 100;
    y[i] = random() % 100;
  }
  int ticks = size;
  add(ticks, x, y, scalar, s);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x40,-0x8(%rbp)
movl   $0x100,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0xc(%rbp),%edi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
movl   $0x3,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
cmpl   $0x40,-0x30(%rbp)
jge    11cb <main+0x9b>
mov    $0x0,%al
call   1040 <random@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    -0x18(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    $0x0,%al
call   1040 <random@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    -0x20(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    117f <main+0x4f>
movl   $0x40,-0x34(%rbp)
mov    -0x34(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x2c(%rbp),%ecx
mov    -0x28(%rbp),%r8
call   1030 <add@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    $0x100,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
mov    $0x100,%edi
call   1050 <malloc@plt>
mov    %rax,%r12
mov    $0x100,%edi
call   1050 <malloc@plt>
mov    %rax,%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <random@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,(%r14,%rbx,4)
xor    %eax,%eax
call   1040 <random@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,(%r12,%rbx,4)
add    $0x1,%rbx
cmp    $0x40,%rbx
jne    1170 <main+0x40>
mov    $0x40,%edi
mov    %r14,%rsi
mov    %r12,%rdx
mov    $0x3,%ecx
mov    %r15,%r8
call   1030 <add@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
store i32 64, i32* %2
store i32 256, i32* %3
%10 = load i32, i32* %3
%11 = call i32* @malloc(i32 %10)
store i32* %11, i32** %4
%12 = load i32, i32* %3
%13 = call i32* @malloc(i32 %12)
store i32* %13, i32** %5
%14 = load i32, i32* %3
%15 = call i32* @malloc(i32 %14)
store i32* %15, i32** %6
store i32 3, i32* %7
store i32 0, i32* %8
br label %16
16: ; preds = %32, %0
%17 = load i32, i32* %8
%18 = icmp slt i32 %17, 64
br i1 %18, label %19, label %35
19: ; preds = %16
%20 = call i32 (...) @random()
%21 = srem i32 %20, 100
%22 = load i32*, i32** %4
%23 = load i32, i32* %8
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i32, i32* %22, i64 %24
store i32 %21, i32* %25
%26 = call i32 (...) @random()
%27 = srem i32 %26, 100
%28 = load i32*, i32** %5
%29 = load i32, i32* %8
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i32, i32* %28, i64 %30
store i32 %27, i32* %31
br label %32
32: ; preds = %19
%33 = load i32, i32* %8
%34 = add nsw i32 %33, 1
store i32 %34, i32* %8
br label %16
35: ; preds = %16
store i32 64, i32* %9
%36 = load i32, i32* %9
%37 = load i32*, i32** %4
%38 = load i32*, i32** %5
%39 = load i32, i32* %7
%40 = load i32*, i32** %6
%41 = call i32 @add(i32 %36, i32* %37, i32* %38, i32 %39, i32* %40)
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32* @malloc(i32 256)
%2 = tail call i32* @malloc(i32 256)
%3 = tail call i32* @malloc(i32 256)
br label %6
4: ; preds = %6
%5 = tail call i32 @add(i32 64, i32* %1, i32* %2, i32 3, i32* %3)
ret i32 0
6: ; preds = %0, %6
%7 = phi i64 [ 0, %0 ], [ %14, %6 ]
%8 = tail call i32 (...) @random()
%9 = srem i32 %8, 100
%10 = getelementptr inbounds i32, i32* %1, i64 %7
store i32 %9, i32* %10
%11 = tail call i32 (...) @random()
%12 = srem i32 %11, 100
%13 = getelementptr inbounds i32, i32* %2, i64 %7
store i32 %12, i32* %13
%14 = add nuw nsw i64 %7, 1
%15 = icmp eq i64 %14, 64
br i1 %15, label %4, label %6
}