#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);
void *block_Mbyte() {
  int i;
  char *mem = malloc(100 * 1024 * 1024);
  char *mem1 = malloc(1024 * 1024 * 100);
  for (i = 0; i < 100; i++) {
    memcpy(mem1, mem, 1024 * 1024);
    mem1 = mem1 + 1024 * 1024;
    mem = mem + 1024 * 1024;
  }
}


x86 assembly (clang, -O0):
<block_Mbyte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x6400000,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    $0x6400000,%edi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x64,-0xc(%rbp)
jge    1191 <block_Mbyte+0x71>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x100000,%edx
call   1030 <memcpy@plt>
mov    -0x20(%rbp),%rax
add    $0x100000,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
add    $0x100000,%rax
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114b <block_Mbyte+0x2b>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<block_Mbyte>:
push   %r15
push   %r14
push   %rbx
mov    $0x6400000,%edi
call   1040 <malloc@plt>
mov    %rax,%r14
mov    $0x6400000,%edi
call   1040 <malloc@plt>
mov    %rax,%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    (%r15,%rbx,1),%rdi
lea    (%r14,%rbx,1),%rsi
mov    $0x100000,%edx
call   1030 <memcpy@plt>
add    $0x100000,%rbx
cmp    $0x6400000,%ebx
jne    1150 <block_Mbyte+0x30>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @block_Mbyte() {
%1 = alloca i8*
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = call i8* @malloc(i32 104857600)
store i8* %5, i8** %3
%6 = call i8* @malloc(i32 104857600)
store i8* %6, i8** %4
store i32 0, i32* %2
br label %7
7: ; preds = %18, %0
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 100
br i1 %9, label %10, label %21
10: ; preds = %7
%11 = load i8*, i8** %4
%12 = load i8*, i8** %3
%13 = call i32 @memcpy(i8* %11, i8* %12, i32 1048576)
%14 = load i8*, i8** %4
%15 = getelementptr inbounds i8, i8* %14, i64 1048576
store i8* %15, i8** %4
%16 = load i8*, i8** %3
%17 = getelementptr inbounds i8, i8* %16, i64 1048576
store i8* %17, i8** %3
br label %18
18: ; preds = %10
%19 = load i32, i32* %2
%20 = add nsw i32 %19, 1
store i32 %20, i32* %2
br label %7
21: ; preds = %7
%22 = load i8*, i8** %1
ret i8* %22
}

LLVM IR (-O2):
define noalias i8* @block_Mbyte() {
%1 = tail call dereferenceable_or_null(104857600) i8* @malloc(i32 104857600)
%2 = tail call dereferenceable_or_null(104857600) i8* @malloc(i32 104857600)
br label %3
3: ; preds = %0, %3
%4 = phi i8* [ %2, %0 ], [ %8, %3 ]
%5 = phi i8* [ %1, %0 ], [ %9, %3 ]
%6 = phi i32 [ 0, %0 ], [ %10, %3 ]
%7 = tail call i32 @memcpy(i8* %4, i8* %5, i32 1048576)
%8 = getelementptr inbounds i8, i8* %4, i64 1048576
%9 = getelementptr inbounds i8, i8* %5, i64 1048576
%10 = add nuw nsw i32 %6, 1
%11 = icmp eq i32 %10, 100
br i1 %11, label %12, label %3
12: ; preds = %3
ret i8* undef
}