#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 timespec {
  int tv_sec;
  int tv_nsec;
};

/* Variables and functions */
int /*<<< orphan*/ CLOCK_REALTIME;
int /*<<< orphan*/ LocalCall(unsigned long *, unsigned long *, unsigned long *);
int /*<<< orphan*/ clock_gettime(int /*<<< orphan*/, struct timespec *);
int /*<<< orphan*/ printf(char *, ...);
unsigned long rand();
int main() {
  unsigned long argumento1[256], argumento2[256];
  unsigned long respuesta[512];
  double tiemponano;
  struct timespec ti_nano, tf_nano;
  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");
  clock_gettime(CLOCK_REALTIME, &ti_nano);
  LocalCall(argumento1, argumento2, respuesta);
  clock_gettime(CLOCK_REALTIME, &tf_nano);
  tiemponano = (tf_nano.tv_sec - ti_nano.tv_sec) * 1000000000 +
               (tf_nano.tv_nsec - ti_nano.tv_nsec);
  printf("La llamada a LocalCall demoro %g us | %g ns\n", tiemponano / 1000,
         tiemponano);
  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    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2e19(%rip),%rax
mov    (%rax),%edi
lea    -0x2020(%rbp),%rsi
call   1030 <clock_gettime@plt>
lea    -0x810(%rbp),%rdi
lea    -0x1010(%rbp),%rsi
lea    -0x2010(%rbp),%rdx
call   1050 <LocalCall@plt>
mov    0x2dea(%rip),%rax
mov    (%rax),%edi
lea    -0x2028(%rbp),%rsi
call   1030 <clock_gettime@plt>
mov    -0x2028(%rbp),%eax
sub    -0x2020(%rbp),%eax
imul   $0x3b9aca00,%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
movsd  0xdc0(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  -0x2018(%rbp),%xmm1
ff
lea    0xe15(%rip),%rdi
mov    $0x2,%al
call   1040 <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    0xea6(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e45(%rip),%rbx
mov    (%rbx),%edi
lea    0x8(%rsp),%rsi
call   1040 <clock_gettime@plt>
lea    0x810(%rsp),%rdi
lea    0x10(%rsp),%rsi
lea    0x1010(%rsp),%rdx
call   1060 <LocalCall@plt>
mov    (%rbx),%edi
mov    %rsp,%rsi
call   1040 <clock_gettime@plt>
mov    (%rsp),%eax
mov    0x4(%rsp),%ecx
sub    0x8(%rsp),%eax
imul   $0x3b9aca00,%eax,%eax
sub    0xc(%rsp),%ecx
add    %eax,%ecx
cvtsi2sd %ecx,%xmm1
movapd %xmm1,%xmm0
divsd  0xe0e(%rip),%xmm0
lea    0xe0f(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x2010,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timespec = 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"
@CLOCK_REALTIME = global i32 0
@.str.1 = [45 x i8] c"La llamada a LocalCall demoro %g us | %g ns\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.timespec
%7 = alloca %struct.timespec
%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 = load i32, i32* @CLOCK_REALTIME
%29 = call i32 @clock_gettime(i32 %28, %struct.timespec* %6)
%30 = getelementptr inbounds [256 x i64], [256 x i64]* %2, i64 0, i64 0
%31 = getelementptr inbounds [256 x i64], [256 x i64]* %3, i64 0, i64 0
%32 = getelementptr inbounds [512 x i64], [512 x i64]* %4, i64 0, i64 0
%33 = call i32 @LocalCall(i64* %30, i64* %31, i64* %32)
%34 = load i32, i32* @CLOCK_REALTIME
%35 = call i32 @clock_gettime(i32 %34, %struct.timespec* %7)
%36 = getelementptr inbounds %struct.timespec, %struct.timespec* %7, i32 0, i32 0
%37 = load i32, i32* %36
%38 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i32 0, i32 0
%39 = load i32, i32* %38
%40 = sub nsw i32 %37, %39
%41 = mul nsw i32 %40, 1000000000
%42 = getelementptr inbounds %struct.timespec, %struct.timespec* %7, i32 0, i32 1
%43 = load i32, i32* %42
%44 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i32 0, i32 1
%45 = load i32, i32* %44
%46 = sub nsw i32 %43, %45
%47 = add nsw i32 %41, %46
%48 = sitofp i32 %47 to double
store double %48, double* %5
%49 = load double, double* %5
%50 = fdiv double %49, 1.000000e+03
%51 = load double, double* %5
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), double %50, double %51)
ret i32 0
}

LLVM IR (-O2):
%struct.timespec = type { i32, i32 }
@CLOCK_REALTIME = global i32 0
@.str.1 = [45 x i8] c"La llamada a LocalCall demoro %g us | %g ns\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.timespec
%5 = alloca %struct.timespec
%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.timespec* %4 to i8*
%10 = bitcast %struct.timespec* %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 = load i32, i32* @CLOCK_REALTIME
%22 = call i32 @clock_gettime(i32 %21, %struct.timespec* %4)
%23 = getelementptr inbounds [256 x i64], [256 x i64]* %1, i64 0, i64 0
%24 = getelementptr inbounds [256 x i64], [256 x i64]* %2, i64 0, i64 0
%25 = getelementptr inbounds [512 x i64], [512 x i64]* %3, i64 0, i64 0
%26 = call i32 @LocalCall(i64* %23, i64* %24, i64* %25)
%27 = load i32, i32* @CLOCK_REALTIME
%28 = call i32 @clock_gettime(i32 %27, %struct.timespec* %5)
%29 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i64 0, i32 0
%30 = load i32, i32* %29
%31 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i64 0, i32 0
%32 = load i32, i32* %31
%33 = sub nsw i32 %30, %32
%34 = mul nsw i32 %33, 1000000000
%35 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i64 0, i32 1
%36 = load i32, i32* %35
%37 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i64 0, i32 1
%38 = load i32, i32* %37
%39 = sub i32 %36, %38
%40 = add nsw i32 %39, %34
%41 = sitofp i32 %40 to double
%42 = fdiv double %41, 1.000000e+03
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), double %42, double %41)
ret i32 0
}