#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 *);
int /*<<< orphan*/ clock_gettime(int /*<<< orphan*/, struct timespec *);
int /*<<< orphan*/ printf(char *, double, ...);
unsigned long rand();
int main() {
  unsigned long argumento;
  unsigned long *respuesta;
  double tiemponano;
  struct timespec ti_nano, tf_nano;
  argumento = rand();
  printf(
      "Se genero un argumento de tipo LONG (4 bytes) que tien el valor %lu\n",
      argumento);
  clock_gettime(CLOCK_REALTIME, &ti_nano);
  LocalCall(argumento, 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("Local Call dio como resultado en la salida: %lu\n", *respuesta);
  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    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
call   1060 <rand@plt>
mov    %rax,-0x10(%rbp)
movq   -0x10(%rbp),%xmm0
movaps 0xeaa(%rip),%xmm1
movaps %xmm1,-0x50(%rbp)
punpckldq %xmm1,%xmm0
movapd 0xeaa(%rip),%xmm1
movaps %xmm1,-0x40(%rbp)
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
lea    0xea0(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    0x2e42(%rip),%rax
mov    %rax,-0x58(%rbp)
mov    (%rax),%edi
lea    -0x28(%rbp),%rsi
call   1030 <clock_gettime@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <LocalCall@plt>
mov    -0x58(%rbp),%rax
mov    (%rax),%edi
lea    -0x30(%rbp),%rsi
call   1030 <clock_gettime@plt>
movaps -0x50(%rbp),%xmm2
movaps -0x40(%rbp),%xmm1
mov    -0x30(%rbp),%eax
mov    -0x2c(%rbp),%ecx
mov    -0x28(%rbp),%esi
mov    -0x24(%rbp),%edx
sub    %esi,%eax
imul   $0x3b9aca00,%eax,%eax
sub    %edx,%ecx
add    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movq   (%rax),%xmm0
punpckldq %xmm2,%xmm0
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
lea    0xe61(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  -0x20(%rbp),%xmm0
movsd  0xdd8(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  -0x20(%rbp),%xmm1
lea    0xe6e(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
xor    %eax,%eax
call   1060 <rand@plt>
mov    %rax,%rbx
movq   %rax,%xmm1
punpckldq 0xea2(%rip),%xmm1
subpd  0xeaa(%rip),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
lea    0xeaf(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    0x2e59(%rip),%r14
mov    (%r14),%edi
lea    0x8(%rsp),%rsi
call   1030 <clock_gettime@plt>
mov    %rbx,%rdi
call   1050 <LocalCall@plt>
mov    (%r14),%edi
mov    %rsp,%rsi
call   1030 <clock_gettime@plt>
mov    (%rsp),%eax
mov    0x4(%rsp),%ecx
sub    0x8(%rsp),%eax
sub    0xc(%rsp),%ecx
imul   $0x3b9aca00,%eax,%eax
add    %eax,%ecx
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
movsd  %xmm0,0x10(%rsp)
lea    0xe9b(%rip),%rdi
xorpd  %xmm0,%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0x10(%rsp),%xmm1
movapd %xmm1,%xmm0
divsd  0xe31(%rip),%xmm0
lea    0xea8(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.timespec = type { i32, i32 }
@.str = [69 x i8] c"Se genero un argumento de tipo LONG (4 bytes) que tien el valor %lu\0A\00"
@CLOCK_REALTIME = global i32 0
@.str.1 = [49 x i8] c"Local Call dio como resultado en la salida: %lu\0A\00"
@.str.2 = [45 x i8] c"La llamada a LocalCall demoro %g us | %g ns\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64*
%4 = alloca double
%5 = alloca %struct.timespec
%6 = alloca %struct.timespec
store i32 0, i32* %1
%7 = call i64 (...) @rand()
store i64 %7, i64* %2
%8 = load i64, i64* %2
%9 = uitofp i64 %8 to double
%10 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str, i64 0, i64 0), double %9)
%11 = load i32, i32* @CLOCK_REALTIME
%12 = call i32 @clock_gettime(i32 %11, %struct.timespec* %5)
%13 = load i64, i64* %2
%14 = load i64*, i64** %3
%15 = call i32 @LocalCall(i64 %13, i64* %14)
%16 = load i32, i32* @CLOCK_REALTIME
%17 = call i32 @clock_gettime(i32 %16, %struct.timespec* %6)
%18 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i32 0, i32 0
%19 = load i32, i32* %18
%20 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i32 0, i32 0
%21 = load i32, i32* %20
%22 = sub nsw i32 %19, %21
%23 = mul nsw i32 %22, 1000000000
%24 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i32 0, i32 1
%25 = load i32, i32* %24
%26 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i32 0, i32 1
%27 = load i32, i32* %26
%28 = sub nsw i32 %25, %27
%29 = add nsw i32 %23, %28
%30 = sitofp i32 %29 to double
store double %30, double* %4
%31 = load i64*, i64** %3
%32 = load i64, i64* %31
%33 = uitofp i64 %32 to double
%34 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), double %33)
%35 = load double, double* %4
%36 = fdiv double %35, 1.000000e+03
%37 = load double, double* %4
%38 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), double %36, double %37)
ret i32 0
}

LLVM IR (-O2):
%struct.timespec = type { i32, i32 }
@.str = [69 x i8] c"Se genero un argumento de tipo LONG (4 bytes) que tien el valor %lu\0A\00"
@CLOCK_REALTIME = global i32 0
@.str.1 = [49 x i8] c"Local Call dio como resultado en la salida: %lu\0A\00"
@.str.2 = [45 x i8] c"La llamada a LocalCall demoro %g us | %g ns\0A\00"
define i32 @main() {
%1 = alloca %struct.timespec
%2 = alloca %struct.timespec
%3 = bitcast %struct.timespec* %1 to i8*
%4 = bitcast %struct.timespec* %2 to i8*
%5 = tail call i64 (...) @rand()
%6 = uitofp i64 %5 to double
%7 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str, i64 0, i64 0), double %6)
%8 = load i32, i32* @CLOCK_REALTIME
%9 = call i32 @clock_gettime(i32 %8, %struct.timespec* %1)
%10 = call i32 @LocalCall(i64 %5, i64* undef)
%11 = load i32, i32* @CLOCK_REALTIME
%12 = call i32 @clock_gettime(i32 %11, %struct.timespec* %2)
%13 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 0
%14 = load i32, i32* %13
%15 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 0
%16 = load i32, i32* %15
%17 = sub nsw i32 %14, %16
%18 = mul nsw i32 %17, 1000000000
%19 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 1
%20 = load i32, i32* %19
%21 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 1
%22 = load i32, i32* %21
%23 = sub i32 %20, %22
%24 = add nsw i32 %23, %18
%25 = sitofp i32 %24 to double
%26 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), double 0.000000e+00)
%27 = fdiv double %25, 1.000000e+03
%28 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), double %27, double %25)
ret i32 0
}