#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*/ strcat(char *, char *);
char *strcpy(char *, char *);
int strlen(char *);
double duracion_concatenacion_clasica(int iter, char *destino, char *origen) {
  int i;
  double time = 0;
  int tam = strlen(origen) + strlen(destino);
  for (i = 0; i < iter; i++) {
    char *temp =
        (char *)malloc(strlen(destino) + strlen(origen) * sizeof(char));
    get_time();
    temp = strcpy(temp, destino);
    strcat(temp, origen);
    time += get_time();
    free(temp);
  }
  return time;
}


x86 assembly (clang, -O0):
<duracion_concatenacion_clasica>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x3c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x2c(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1232 <duracion_concatenacion_clasica+0xd2>
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
cltq
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x48(%rbp),%rax
movslq %ecx,%rcx
shl    $0x0,%rcx
add    %rcx,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    $0x0,%al
call   1060 <get_time@plt>
mov    -0x38(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcpy@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1080 <strcat@plt>
mov    $0x0,%al
call   1060 <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    11a1 <duracion_concatenacion_clasica+0x41>
movsd  -0x28(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<duracion_concatenacion_clasica>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %edi,%ebp
mov    %rdx,%rdi
call   1050 <strlen@plt>
mov    %r15,%rdi
call   1050 <strlen@plt>
xorpd  %xmm0,%xmm0
test   %ebp,%ebp
jle    11f7 <duracion_concatenacion_clasica+0x97>
movsd  %xmm0,(%rsp)
nopl   0x0(%rax)
mov    %r15,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1050 <strlen@plt>
add    %eax,%ebx
mov    %ebx,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1060 <get_time@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1080 <strcat@plt>
xor    %eax,%eax
call   1060 <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    1190 <duracion_concatenacion_clasica+0x30>
jmp    11fc <duracion_concatenacion_clasica+0x9c>
movsd  %xmm0,(%rsp)
movsd  (%rsp),%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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