#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 *);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, double);
unsigned long rand();
int main() {
  unsigned long argumento;
  unsigned long respuesta;
  double tiempo;
  struct timeval ti_usec, tf_usec;
  argumento = rand();
  printf(
      "Se genero un argumento de tipo LONG (4 bytes) que tien el valor %lu\n",
      argumento);
  gettimeofday(&ti_usec, 0);
  LocalCall(argumento, &respuesta);
  gettimeofday(&tf_usec, 0);
  tiempo = (tf_usec.tv_sec - ti_usec.tv_sec) * 1000000 +
           (tf_usec.tv_usec - ti_usec.tv_usec);
  printf("Local Call dio como resultado en la salida: %lu\n", respuesta);
  printf("La llamada a LocalCall demoro %g us\n", tiempo);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,-0x54(%rbp)
call   1060 <rand@plt>
mov    %rax,-0x10(%rbp)
movq   -0x10(%rbp),%xmm0
movaps 0xe97(%rip),%xmm1
movaps %xmm1,-0x50(%rbp)
punpckldq %xmm1,%xmm0
movapd 0xe97(%rip),%xmm1
movaps %xmm1,-0x40(%rbp)
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
lea    0xe8d(%rip),%rdi
call   1030 <printf@plt>
mov    -0x54(%rbp),%esi
lea    -0x28(%rbp),%rdi
call   1040 <gettimeofday@plt>
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <LocalCall@plt>
mov    -0x54(%rbp),%esi
lea    -0x30(%rbp),%rdi
call   1040 <gettimeofday@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   $0xf4240,%eax,%eax
sub    %edx,%ecx
add    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x20(%rbp)
movq   -0x18(%rbp),%xmm0
punpckldq %xmm2,%xmm0
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
lea    0xe60(%rip),%rdi
call   1030 <printf@plt>
movsd  -0x20(%rbp),%xmm0
lea    0xe80(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
xor    %eax,%eax
call   1060 <rand@plt>
mov    %rax,%rbx
movq   %rax,%xmm1
punpckldq 0xea4(%rip),%xmm1
subpd  0xeac(%rip),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
lea    0xea9(%rip),%rdi
call   1030 <printf@plt>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <LocalCall@plt>
mov    %rsp,%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
mov    (%rsp),%eax
sub    0x8(%rsp),%eax
mov    0x4(%rsp),%ecx
imul   $0xf4240,%eax,%eax
sub    0xc(%rsp),%ecx
add    %eax,%ecx
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x18(%rsp),%xmm1
unpcklps 0xe30(%rip),%xmm1
subpd  0xe38(%rip),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
lea    0xe7a(%rip),%rdi
call   1030 <printf@plt>
lea    0xe9f(%rip),%rdi
movsd  0x10(%rsp),%xmm0
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
@.str = [69 x i8] c"Se genero un argumento de tipo LONG (4 bytes) que tien el valor %lu\0A\00"
@.str.1 = [49 x i8] c"Local Call dio como resultado en la salida: %lu\0A\00"
@.str.2 = [37 x i8] c"La llamada a LocalCall demoro %g us\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca double
%5 = alloca %struct.timeval
%6 = alloca %struct.timeval
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 @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str, i64 0, i64 0), double %9)
%11 = call i32 @gettimeofday(%struct.timeval* %5, i32 0)
%12 = load i64, i64* %2
%13 = call i32 @LocalCall(i64 %12, i64* %3)
%14 = call i32 @gettimeofday(%struct.timeval* %6, i32 0)
%15 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%16 = load i32, i32* %15
%17 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 0
%18 = load i32, i32* %17
%19 = sub nsw i32 %16, %18
%20 = mul nsw i32 %19, 1000000
%21 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
%22 = load i32, i32* %21
%23 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 1
%24 = load i32, i32* %23
%25 = sub nsw i32 %22, %24
%26 = add nsw i32 %20, %25
%27 = sitofp i32 %26 to double
store double %27, double* %4
%28 = load i64, i64* %3
%29 = uitofp i64 %28 to double
%30 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), double %29)
%31 = load double, double* %4
%32 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), double %31)
ret i32 0
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
@.str = [69 x i8] c"Se genero un argumento de tipo LONG (4 bytes) que tien el valor %lu\0A\00"
@.str.1 = [49 x i8] c"Local Call dio como resultado en la salida: %lu\0A\00"
@.str.2 = [37 x i8] c"La llamada a LocalCall demoro %g us\0A\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca %struct.timeval
%3 = alloca %struct.timeval
%4 = bitcast i64* %1 to i8*
%5 = bitcast %struct.timeval* %2 to i8*
%6 = bitcast %struct.timeval* %3 to i8*
%7 = tail call i64 (...) @rand()
%8 = uitofp i64 %7 to double
%9 = tail call i32 @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str, i64 0, i64 0), double %8)
%10 = call i32 @gettimeofday(%struct.timeval* %2, i32 0)
%11 = call i32 @LocalCall(i64 %7, i64* %1)
%12 = call i32 @gettimeofday(%struct.timeval* %3, i32 0)
%13 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%14 = load i32, i32* %13
%15 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 0
%16 = load i32, i32* %15
%17 = sub nsw i32 %14, %16
%18 = mul nsw i32 %17, 1000000
%19 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
%20 = load i32, i32* %19
%21 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, 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 = load i64, i64* %1
%27 = uitofp i64 %26 to double
%28 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), double %27)
%29 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), double %25)
ret i32 0
}