#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 dummy;
};
struct iovec {
  int dummy;
};

/* Variables and functions */
double diff_time(struct timeval *, struct timeval *);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ imprime_tiempos(int /*<<< orphan*/, int, double, int);
int /*<<< orphan*/ str_insert_v(struct iovec *, int, struct iovec *, int, int);
int tam_str_v(struct iovec *, int);
int duracion_insertado(int iter, struct iovec *src, int nodos_src,
                       struct iovec *dest, int nodos_dest, int pos_in) {
  struct timeval t_ini, t_fin;
  int i, tam = 0;
  double time = 0;
  gettimeofday(&t_ini, NULL);
  for (i = 0; i < iter; i++)
    str_insert_v(src, nodos_src, dest, nodos_dest, pos_in);
  gettimeofday(&t_fin, NULL);
  time = diff_time(&t_ini, &t_fin);
  tam = tam_str_v(src, nodos_src);
  imprime_tiempos(0, iter, time, tam);
}


x86 assembly (clang, -O0):
<duracion_insertado>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9d,-0x28(%rbp)
movl   $0x0,-0x40(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
lea    -0x30(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11c2 <duracion_insertado+0x72>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%r8d
call   1060 <str_insert_v@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1191 <duracion_insertado+0x41>
lea    -0x38(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
lea    -0x30(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   1070 <diff_time@plt>
movsd  %xmm0,-0x48(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <tam_str_v@plt>
mov    %eax,-0x40(%rbp)
mov    -0x8(%rbp),%esi
movsd  -0x48(%rbp),%xmm0
mov    -0x40(%rbp),%edx
xor    %edi,%edi
call   1040 <imprime_tiempos@plt>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<duracion_insertado>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9d,%r13d
mov    %r8d,%ebx
mov    %rcx,%rbp
mov    %edx,%r15d
mov    %rsi,%r12
mov    %edi,%r14d
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    %r14d,0xc(%rsp)
test   %r14d,%r14d
jle    11a9 <duracion_insertado+0x59>
mov    0xc(%rsp),%r14d
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %r15d,%esi
mov    %rbp,%rdx
mov    %ebx,%ecx
mov    %r13d,%r8d
call   1060 <str_insert_v@plt>
add    $0xffffffff,%r14d
jne    1190 <duracion_insertado+0x40>
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
lea    0x10(%rsp),%rdi
mov    %rbx,%rsi
call   1070 <diff_time@plt>
movsd  %xmm0,0x18(%rsp)
mov    %r12,%rdi
mov    %r15d,%esi
call   1050 <tam_str_v@plt>
xor    %edi,%edi
mov    0xc(%rsp),%esi
movsd  0x18(%rsp),%xmm0
mov    %eax,%edx
call   1040 <imprime_tiempos@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.iovec = type { i32 }
%struct.timeval = type { i32 }
define i32 @duracion_insertado(i32 %0, %struct.iovec* %1, i32 %2, %struct.iovec* %3, i32 %4, i32 %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.iovec*
%10 = alloca i32
%11 = alloca %struct.iovec*
%12 = alloca i32
%13 = alloca i32
%14 = alloca %struct.timeval
%15 = alloca %struct.timeval
%16 = alloca i32
%17 = alloca i32
%18 = alloca double
store i32 %0, i32* %8
store %struct.iovec* %1, %struct.iovec** %9
store i32 %2, i32* %10
store %struct.iovec* %3, %struct.iovec** %11
store i32 %4, i32* %12
store i32 %5, i32* %13
store i32 0, i32* %17
store double 0.000000e+00, double* %18
%19 = call i32 @gettimeofday(%struct.timeval* %14, i32* null)
store i32 0, i32* %16
br label %20
20: ; preds = %31, %6
%21 = load i32, i32* %16
%22 = load i32, i32* %8
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %34
24: ; preds = %20
%25 = load %struct.iovec*, %struct.iovec** %9
%26 = load i32, i32* %10
%27 = load %struct.iovec*, %struct.iovec** %11
%28 = load i32, i32* %12
%29 = load i32, i32* %13
%30 = call i32 @str_insert_v(%struct.iovec* %25, i32 %26, %struct.iovec* %27, i32 %28, i32 %29)
br label %31
31: ; preds = %24
%32 = load i32, i32* %16
%33 = add nsw i32 %32, 1
store i32 %33, i32* %16
br label %20
34: ; preds = %20
%35 = call i32 @gettimeofday(%struct.timeval* %15, i32* null)
%36 = call double @diff_time(%struct.timeval* %14, %struct.timeval* %15)
store double %36, double* %18
%37 = load %struct.iovec*, %struct.iovec** %9
%38 = load i32, i32* %10
%39 = call i32 @tam_str_v(%struct.iovec* %37, i32 %38)
store i32 %39, i32* %17
%40 = load i32, i32* %8
%41 = load double, double* %18
%42 = load i32, i32* %17
%43 = call i32 @imprime_tiempos(i32 0, i32 %40, double %41, i32 %42)
%44 = load i32, i32* %7
ret i32 %44
}

LLVM IR (-O2):
%struct.iovec = type { i32 }
%struct.timeval = type { i32 }
define i32 @duracion_insertado(i32 %0, %struct.iovec* %1, i32 %2, %struct.iovec* %3, i32 %4, i32 %5) {
%7 = alloca %struct.timeval
%8 = alloca %struct.timeval
%9 = bitcast %struct.timeval* %7 to i8*
%10 = bitcast %struct.timeval* %8 to i8*
%11 = call i32 @gettimeofday(%struct.timeval* %7, i32* null)
%12 = icmp sgt i32 %0, 0
br i1 %12, label %13, label %18
13: ; preds = %6, %13
%14 = phi i32 [ %16, %13 ], [ 0, %6 ]
%15 = tail call i32 @str_insert_v(%struct.iovec* %1, i32 %2, %struct.iovec* %3, i32 %4, i32 %5)
%16 = add nuw nsw i32 %14, 1
%17 = icmp eq i32 %16, %0
br i1 %17, label %18, label %13
18: ; preds = %13, %6
%19 = call i32 @gettimeofday(%struct.timeval* %8, i32* null)
%20 = call double @diff_time(%struct.timeval* %7, %struct.timeval* %8)
%21 = call i32 @tam_str_v(%struct.iovec* %1, i32 %2)
%22 = call i32 @imprime_tiempos(i32 0, i32 %0, double %20, i32 %21)
ret i32 undef
}