#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 */
char *malloc(int);
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ printf(char *);
int main() {
  int insize = 3;
  int repeat = 7;
  char *input = malloc(sizeof(char) * insize * repeat);
  char to_repeat[] = "abc";
  int i;
  for (i = 0; i < repeat; i++) {
    memcpy(input + i * insize, to_repeat, insize);
  }
  printf(input);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x3,-0x8(%rbp)
movl   $0x7,-0xc(%rbp)
movslq -0x8(%rbp),%rax
shl    $0x0,%rax
movslq -0xc(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    0xe92(%rip),%eax
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11ae <main+0x7e>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%eax
imul   -0x8(%rbp),%eax
cltq
add    %rax,%rdi
lea    -0x1c(%rbp),%rsi
mov    -0x8(%rbp),%edx
call   1040 <memcpy@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1178 <main+0x48>
mov    -0x18(%rbp),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x15,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
movl   $0x636261,0x4(%rsp)
lea    0x4(%rsp),%r14
mov    %rax,%rdi
mov    %r14,%rsi
mov    $0x3,%edx
call   1040 <memcpy@plt>
lea    0x3(%rbx),%rdi
mov    %r14,%rsi
mov    $0x3,%edx
call   1040 <memcpy@plt>
lea    0x6(%rbx),%rdi
mov    %r14,%rsi
mov    $0x3,%edx
call   1040 <memcpy@plt>
lea    0x9(%rbx),%rdi
mov    %r14,%rsi
mov    $0x3,%edx
call   1040 <memcpy@plt>
lea    0xc(%rbx),%rdi
mov    %r14,%rsi
mov    $0x3,%edx
call   1040 <memcpy@plt>
lea    0xf(%rbx),%rdi
mov    %r14,%rsi
mov    $0x3,%edx
call   1040 <memcpy@plt>
lea    0x12(%rbx),%rdi
mov    %r14,%rsi
mov    $0x3,%edx
call   1040 <memcpy@plt>
mov    %rbx,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.to_repeat = [4 x i8] c"abc\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
%5 = alloca [4 x i8]
%6 = alloca i32
store i32 0, i32* %1
store i32 3, i32* %2
store i32 7, i32* %3
%7 = load i32, i32* %2
%8 = sext i32 %7 to i64
%9 = mul i64 1, %8
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = mul i64 %9, %11
%13 = trunc i64 %12 to i32
%14 = call i8* @malloc(i32 %13)
store i8* %14, i8** %4
%15 = bitcast [4 x i8]* %5 to i8*
store i32 0, i32* %6
br label %16
16: ; preds = %30, %0
%17 = load i32, i32* %6
%18 = load i32, i32* %3
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %33
20: ; preds = %16
%21 = load i8*, i8** %4
%22 = load i32, i32* %6
%23 = load i32, i32* %2
%24 = mul nsw i32 %22, %23
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %21, i64 %25
%27 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%28 = load i32, i32* %2
%29 = call i32 @memcpy(i8* %26, i8* %27, i32 %28)
br label %30
30: ; preds = %20
%31 = load i32, i32* %6
%32 = add nsw i32 %31, 1
store i32 %32, i32* %6
br label %16
33: ; preds = %16
%34 = load i8*, i8** %4
%35 = call i32 @printf(i8* %34)
%36 = load i32, i32* %1
ret i32 %36
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca i32
%2 = tail call dereferenceable_or_null(21) i8* @malloc(i32 21)
%3 = bitcast i32* %1 to i8*
store i32 6513249, i32* %1
%4 = call i32 @memcpy(i8* %2, i8* %3, i32 3)
%5 = getelementptr inbounds i8, i8* %2, i64 3
%6 = call i32 @memcpy(i8* %5, i8* %3, i32 3)
%7 = getelementptr inbounds i8, i8* %2, i64 6
%8 = call i32 @memcpy(i8* %7, i8* %3, i32 3)
%9 = getelementptr inbounds i8, i8* %2, i64 9
%10 = call i32 @memcpy(i8* %9, i8* %3, i32 3)
%11 = getelementptr inbounds i8, i8* %2, i64 12
%12 = call i32 @memcpy(i8* %11, i8* %3, i32 3)
%13 = getelementptr inbounds i8, i8* %2, i64 15
%14 = call i32 @memcpy(i8* %13, i8* %3, i32 3)
%15 = getelementptr inbounds i8, i8* %2, i64 18
%16 = call i32 @memcpy(i8* %15, i8* %3, i32 3)
%17 = call i32 @printf(i8* dereferenceable(1) %2)
ret i32 0
}