#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 */

/* Variables and functions */
int /*<<< orphan*/ free(char *);
scalar_t__ get_time();
scalar_t__ malloc(int);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
double duracion_borrado_clasico(int iter, char *str, int first, int last) {
  int i;
  double time = 0;
  int tam_str = strlen(str);
  for (i = 0; i < iter; i++) {
    char *temp = (char *)malloc(tam_str * sizeof(char));
    get_time();
    strncpy(temp, str, first);
    strcpy(temp + first, str + last);
    time += get_time();
    free(temp);
  }
  return time;
}


x86 assembly (clang, -O0):
<duracion_borrado_clasico>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x2c(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    120e <duracion_borrado_clasico+0xae>
movslq -0x2c(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    $0x0,%al
call   1070 <get_time@plt>
mov    -0x38(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1040 <strncpy@plt>
mov    -0x38(%rbp),%rdi
movslq -0x14(%rbp),%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
movslq -0x18(%rbp),%rax
add    %rax,%rsi
call   1050 <strcpy@plt>
mov    $0x0,%al
call   1070 <get_time@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1190 <duracion_borrado_clasico+0x30>
movsd  -0x28(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<duracion_borrado_clasico>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r12d
mov    %edx,%ebx
mov    %rsi,%r15
mov    %edi,%ebp
mov    %rsi,%rdi
call   1060 <strlen@plt>
test   %ebp,%ebp
jle    11f8 <duracion_borrado_clasico+0x98>
mov    %eax,%r14d
movslq %ebx,%r13
movslq %r12d,%r12
add    %r15,%r12
xorpd  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
cs nopw 0x0(%rax,%rax,1)
mov    %r14d,%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1070 <get_time@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r13d,%edx
call   1040 <strncpy@plt>
lea    (%rbx,%r13,1),%rdi
mov    %r12,%rsi
call   1050 <strcpy@plt>
xor    %eax,%eax
call   1070 <get_time@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  (%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
mov    %rbx,%rdi
call   1030 <free@plt>
add    $0xffffffff,%ebp
jne    11a0 <duracion_borrado_clasico+0x40>
jmp    1201 <duracion_borrado_clasico+0xa1>
xorpd  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
movsd  (%rsp),%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @duracion_borrado_clasico(i32 %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca double
%11 = alloca i32
%12 = alloca i8*
store i32 %0, i32* %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store double 0.000000e+00, double* %10
%13 = load i8*, i8** %6
%14 = call i32 @strlen(i8* %13)
store i32 %14, i32* %11
store i32 0, i32* %9
br label %15
15: ; preds = %46, %4
%16 = load i32, i32* %9
%17 = load i32, i32* %5
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %49
19: ; preds = %15
%20 = load i32, i32* %11
%21 = sext i32 %20 to i64
%22 = mul i64 %21, 1
%23 = trunc i64 %22 to i32
%24 = call i64 @malloc(i32 %23)
%25 = inttoptr i64 %24 to i8*
store i8* %25, i8** %12
%26 = call i64 (...) @get_time()
%27 = load i8*, i8** %12
%28 = load i8*, i8** %6
%29 = load i32, i32* %7
%30 = call i32 @strncpy(i8* %27, i8* %28, i32 %29)
%31 = load i8*, i8** %12
%32 = load i32, i32* %7
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
%35 = load i8*, i8** %6
%36 = load i32, i32* %8
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
%39 = call i32 @strcpy(i8* %34, i8* %38)
%40 = call i64 (...) @get_time()
%41 = sitofp i64 %40 to double
%42 = load double, double* %10
%43 = fadd double %42, %41
store double %43, double* %10
%44 = load i8*, i8** %12
%45 = call i32 @free(i8* %44)
br label %46
46: ; preds = %19
%47 = load i32, i32* %9
%48 = add nsw i32 %47, 1
store i32 %48, i32* %9
br label %15
49: ; preds = %15
%50 = load double, double* %10
ret double %50
}

LLVM IR (-O2):
define double @duracion_borrado_clasico(i32 %0, i8* %1, i32 %2, i32 %3) {
%5 = tail call i32 @strlen(i8* %1)
%6 = icmp sgt i32 %0, 0
br i1 %6, label %7, label %26
7: ; preds = %4
%8 = sext i32 %2 to i64
%9 = sext i32 %3 to i64
%10 = getelementptr inbounds i8, i8* %1, i64 %9
br label %11
11: ; preds = %7, %11
%12 = phi i32 [ 0, %7 ], [ %24, %11 ]
%13 = phi double [ 0.000000e+00, %7 ], [ %22, %11 ]
%14 = tail call i64 @malloc(i32 %5)
%15 = inttoptr i64 %14 to i8*
%16 = tail call i64 (...) @get_time()
%17 = tail call i32 @strncpy(i8* %15, i8* %1, i32 %2)
%18 = getelementptr inbounds i8, i8* %15, i64 %8
%19 = tail call i32 @strcpy(i8* %18, i8* %10)
%20 = tail call i64 (...) @get_time()
%21 = sitofp i64 %20 to double
%22 = fadd double %13, %21
%23 = tail call i32 @free(i8* %15)
%24 = add nuw nsw i32 %12, 1
%25 = icmp eq i32 %24, %0
br i1 %25, label %26, label %11
26: ; preds = %11, %4
%27 = phi double [ 0.000000e+00, %4 ], [ %22, %11 ]
ret double %27
}