#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 */
struct timeval {
  int tv_sec;
  int tv_usec;
};

/* Variables and functions */
int /*<<< orphan*/ LocalCall(unsigned long *, unsigned long *, unsigned long *);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
unsigned long rand();
int main() {
  unsigned long argumento1[256], argumento2[256];
  unsigned long respuesta[512];
  double tiempo;
  struct timeval ti_usec, tf_usec;
  int i;
  for (i = 0; i < 256; i++) {
    *(argumento1 + i) = rand();
    *(argumento2 + i) = rand();
  }
  printf("Se generaron 2 argumentos con 256 datos de tipo LONG (4 bytes) como "
         "entrada a la llamada local\n");
  gettimeofday(&ti_usec, 0);
  LocalCall(argumento1, argumento2, respuesta);
  gettimeofday(&tf_usec, 0);
  tiempo = (tf_usec.tv_sec - ti_usec.tv_sec) * 1000000 +
           (tf_usec.tv_usec - ti_usec.tv_usec);
  printf("La llamada a LocalCall demoro %g us\n", tiempo);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2030,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x202c(%rbp)
cmpl   $0x100,-0x202c(%rbp)
jge    11b2 <main+0x72>
mov    $0x0,%al
call   1060 <rand@plt>
mov    %rax,%rcx
movslq -0x202c(%rbp),%rax
mov    %rcx,-0x810(%rbp,%rax,8)
ff
mov    $0x0,%al
call   1060 <rand@plt>
mov    %rax,%rcx
movslq -0x202c(%rbp),%rax
mov    %rcx,-0x1010(%rbp,%rax,8)
ff
mov    -0x202c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x202c(%rbp)
jmp    115c <main+0x1c>
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x2020(%rbp),%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
lea    -0x810(%rbp),%rdi
lea    -0x1010(%rbp),%rsi
lea    -0x2010(%rbp),%rdx
call   1050 <LocalCall@plt>
lea    -0x2028(%rbp),%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
mov    -0x2028(%rbp),%eax
sub    -0x2020(%rbp),%eax
imul   $0xf4240,%eax,%eax
mov    -0x2024(%rbp),%ecx
sub    -0x201c(%rbp),%ecx
add    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x2018(%rbp)
ff
movsd  -0x2018(%rbp),%xmm0
ff
lea    0xe2f(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x2030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x2010,%rsp
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <rand@plt>
mov    %rax,0x810(%rsp,%rbx,8)
xor    %eax,%eax
call   1070 <rand@plt>
mov    %rax,0x10(%rsp,%rbx,8)
add    $0x1,%rbx
cmp    $0x100,%rbx
jne    1160 <main+0x10>
lea    0xe96(%rip),%rdi
call   1030 <puts@plt>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
lea    0x810(%rsp),%rdi
lea    0x10(%rsp),%rsi
lea    0x1010(%rsp),%rdx
call   1060 <LocalCall@plt>
mov    %rsp,%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
mov    (%rsp),%eax
mov    0x4(%rsp),%ecx
sub    0x8(%rsp),%eax
sub    0xc(%rsp),%ecx
imul   $0xf4240,%eax,%eax
add    %eax,%ecx
cvtsi2sd %ecx,%xmm0
lea    0xe1a(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x2010,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
@.str = [96 x i8] c"Se generaron 2 argumentos con 256 datos de tipo LONG (4 bytes) como entrada a la llamada local\0A\00"
@.str.1 = [37 x i8] c"La llamada a LocalCall demoro %g us\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [256 x i64]
%3 = alloca [256 x i64]
%4 = alloca [512 x i64]
%5 = alloca double
%6 = alloca %struct.timeval
%7 = alloca %struct.timeval
%8 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %8
br label %9
9: ; preds = %23, %0
%10 = load i32, i32* %8
%11 = icmp slt i32 %10, 256
br i1 %11, label %12, label %26
12: ; preds = %9
%13 = call i64 (...) @rand()
%14 = getelementptr inbounds [256 x i64], [256 x i64]* %2, i64 0, i64 0
%15 = load i32, i32* %8
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i64, i64* %14, i64 %16
store i64 %13, i64* %17
%18 = call i64 (...) @rand()
%19 = getelementptr inbounds [256 x i64], [256 x i64]* %3, i64 0, i64 0
%20 = load i32, i32* %8
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i64, i64* %19, i64 %21
store i64 %18, i64* %22
br label %23
23: ; preds = %12
%24 = load i32, i32* %8
%25 = add nsw i32 %24, 1
store i32 %25, i32* %8
br label %9
26: ; preds = %9
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([96 x i8], [96 x i8]* @.str, i64 0, i64 0))
%28 = call i32 @gettimeofday(%struct.timeval* %6, i32 0)
%29 = getelementptr inbounds [256 x i64], [256 x i64]* %2, i64 0, i64 0
%30 = getelementptr inbounds [256 x i64], [256 x i64]* %3, i64 0, i64 0
%31 = getelementptr inbounds [512 x i64], [512 x i64]* %4, i64 0, i64 0
%32 = call i32 @LocalCall(i64* %29, i64* %30, i64* %31)
%33 = call i32 @gettimeofday(%struct.timeval* %7, i32 0)
%34 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
%35 = load i32, i32* %34
%36 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%37 = load i32, i32* %36
%38 = sub nsw i32 %35, %37
%39 = mul nsw i32 %38, 1000000
%40 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 1
%41 = load i32, i32* %40
%42 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
%43 = load i32, i32* %42
%44 = sub nsw i32 %41, %43
%45 = add nsw i32 %39, %44
%46 = sitofp i32 %45 to double
store double %46, double* %5
%47 = load double, double* %5
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), double %47)
ret i32 0
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
@.str.1 = [37 x i8] c"La llamada a LocalCall demoro %g us\0A\00"
@str = [95 x i8] c"Se generaron 2 argumentos con 256 datos de tipo LONG (4 bytes) como entrada a la llamada local\00"
define i32 @main() {
%1 = alloca [256 x i64]
%2 = alloca [256 x i64]
%3 = alloca [512 x i64]
%4 = alloca %struct.timeval
%5 = alloca %struct.timeval
%6 = bitcast [256 x i64]* %1 to i8*
%7 = bitcast [256 x i64]* %2 to i8*
%8 = bitcast [512 x i64]* %3 to i8*
%9 = bitcast %struct.timeval* %4 to i8*
%10 = bitcast %struct.timeval* %5 to i8*
br label %11
11: ; preds = %0, %11
%12 = phi i64 [ 0, %0 ], [ %17, %11 ]
%13 = tail call i64 (...) @rand()
%14 = getelementptr inbounds [256 x i64], [256 x i64]* %1, i64 0, i64 %12
store i64 %13, i64* %14
%15 = tail call i64 (...) @rand()
%16 = getelementptr inbounds [256 x i64], [256 x i64]* %2, i64 0, i64 %12
store i64 %15, i64* %16
%17 = add nuw nsw i64 %12, 1
%18 = icmp eq i64 %17, 256
br i1 %18, label %19, label %11
19: ; preds = %11
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([95 x i8], [95 x i8]* @str, i64 0, i64 0))
%21 = call i32 @gettimeofday(%struct.timeval* %4, i32 0)
%22 = getelementptr inbounds [256 x i64], [256 x i64]* %1, i64 0, i64 0
%23 = getelementptr inbounds [256 x i64], [256 x i64]* %2, i64 0, i64 0
%24 = getelementptr inbounds [512 x i64], [512 x i64]* %3, i64 0, i64 0
%25 = call i32 @LocalCall(i64* %22, i64* %23, i64* %24)
%26 = call i32 @gettimeofday(%struct.timeval* %5, i32 0)
%27 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 0
%28 = load i32, i32* %27
%29 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
%30 = load i32, i32* %29
%31 = sub nsw i32 %28, %30
%32 = mul nsw i32 %31, 1000000
%33 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 1
%34 = load i32, i32* %33
%35 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 1
%36 = load i32, i32* %35
%37 = sub i32 %34, %36
%38 = add nsw i32 %37, %32
%39 = sitofp i32 %38 to double
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), double %39)
ret i32 0
}