#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*/ memcpy(char *, char *, int);
int mangle_double_times(char arr[64], int arr_len, int times) {
  if (((arr_len * times) + arr_len) >= 64)
    return (arr_len);
  int orig_len = arr_len;
  int i;
  for (i = 0; i < times; i++) {
    memcpy(&arr[arr_len], arr, orig_len);
    arr_len += orig_len;
  }
  return (arr_len);
}


x86 assembly (clang, -O0):
<mangle_double_times>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    -0x14(%rbp),%eax
imul   -0x18(%rbp),%eax
add    -0x14(%rbp),%eax
cmp    $0x40,%eax
jl     1140 <mangle_double_times+0x30>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    118d <mangle_double_times+0x7d>
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1187 <mangle_double_times+0x77>
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <memcpy@plt>
mov    -0x1c(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    114d <mangle_double_times+0x3d>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mangle_double_times>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r15d
mov    %edx,%eax
imul   %esi,%eax
add    %esi,%eax
cmp    $0x3f,%eax
jg     115c <mangle_double_times+0x4c>
mov    %edx,%r13d
test   %edx,%edx
jle    115c <mangle_double_times+0x4c>
mov    %rdi,%r14
movslq %r15d,%r12
lea    (%rdi,%r12,1),%rbp
mov    %r15d,%ebx
xchg   %ax,%ax
mov    %rbp,%rdi
mov    %r14,%rsi
mov    %r12d,%edx
call   1030 <memcpy@plt>
add    %r12,%rbp
add    %r15d,%ebx
add    $0xffffffff,%r13d
jne    1140 <mangle_double_times+0x30>
jmp    115f <mangle_double_times+0x4f>
mov    %r15d,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @mangle_double_times(i8* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%10 = load i32, i32* %6
%11 = load i32, i32* %7
%12 = mul nsw i32 %10, %11
%13 = load i32, i32* %6
%14 = add nsw i32 %12, %13
%15 = icmp sge i32 %14, 64
br i1 %15, label %16, label %18
16: ; preds = %3
%17 = load i32, i32* %6
store i32 %17, i32* %4
br label %40
18: ; preds = %3
%19 = load i32, i32* %6
store i32 %19, i32* %8
store i32 0, i32* %9
br label %20
20: ; preds = %35, %18
%21 = load i32, i32* %9
%22 = load i32, i32* %7
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %38
24: ; preds = %20
%25 = load i8*, i8** %5
%26 = load i32, i32* %6
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = load i8*, i8** %5
%30 = load i32, i32* %8
%31 = call i32 @memcpy(i8* %28, i8* %29, i32 %30)
%32 = load i32, i32* %8
%33 = load i32, i32* %6
%34 = add nsw i32 %33, %32
store i32 %34, i32* %6
br label %35
35: ; preds = %24
%36 = load i32, i32* %9
%37 = add nsw i32 %36, 1
store i32 %37, i32* %9
br label %20
38: ; preds = %20
%39 = load i32, i32* %6
store i32 %39, i32* %4
br label %40
40: ; preds = %38, %16
%41 = load i32, i32* %4
ret i32 %41
}

LLVM IR (-O2):
define i32 @mangle_double_times(i8* %0, i32 %1, i32 %2) {
%4 = mul nsw i32 %2, %1
%5 = add nsw i32 %4, %1
%6 = icmp slt i32 %5, 64
%7 = icmp sgt i32 %2, 0
%8 = and i1 %6, %7
br i1 %8, label %9, label %21
9: ; preds = %3
%10 = sext i32 %1 to i64
br label %11
11: ; preds = %9, %11
%12 = phi i64 [ %10, %9 ], [ %16, %11 ]
%13 = phi i32 [ 0, %9 ], [ %17, %11 ]
%14 = getelementptr inbounds i8, i8* %0, i64 %12
%15 = tail call i32 @memcpy(i8* %14, i8* %0, i32 %1)
%16 = add i64 %12, %10
%17 = add nuw nsw i32 %13, 1
%18 = icmp eq i32 %17, %2
br i1 %18, label %19, label %11
19: ; preds = %11
%20 = trunc i64 %16 to i32
br label %21
21: ; preds = %19, %3
%22 = phi i32 [ %1, %3 ], [ %20, %19 ]
ret i32 %22
}