#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 */
void *mmemcpy(void *s, const void *src, size_t num) {
  unsigned char *Ptr = NULL;
  Ptr = (unsigned char *)s;
  unsigned const char *source = NULL;
  source = (unsigned const char *)src;
  unsigned int count;
  for (count = 0; count < num; count++) {
    Ptr[count] = source[count];
  }
  Ptr[count] = '\0';
  return (void *)0;
}


x86 assembly (clang, -O0):
<mmemcpy>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x18(%rbp),%rax
jae    1166 <mmemcpy+0x66>
mov    -0x28(%rbp),%rax
mov    -0x2c(%rbp),%ecx
mov    (%rax,%rcx,1),%dl
mov    -0x20(%rbp),%rax
mov    -0x2c(%rbp),%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1137 <mmemcpy+0x37>
mov    -0x20(%rbp),%rax
mov    -0x2c(%rbp),%ecx
movb   $0x0,(%rax,%rcx,1)
xor    %eax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<mmemcpy>:
xor    %eax,%eax
test   %rdx,%rdx
je     1121 <mmemcpy+0x21>
nopw   0x0(%rax,%rax,1)
movzbl (%rsi,%rax,1),%ecx
mov    %cl,(%rdi,%rax,1)
add    $0x1,%eax
cmp    %rdx,%rax
jb     1110 <mmemcpy+0x10>
mov    %eax,%eax
movb   $0x0,(%rdi,%rax,1)
xor    %eax,%eax
ret

LLVM IR (-O0):
define i8* @mmemcpy(i8* %0, i8* %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
store i8* null, i8** %7
%10 = load i8*, i8** %4
store i8* %10, i8** %7
store i8* null, i8** %8
%11 = load i8*, i8** %5
store i8* %11, i8** %8
store i32 0, i32* %9
br label %12
12: ; preds = %27, %3
%13 = load i32, i32* %9
%14 = zext i32 %13 to i64
%15 = load i64, i64* %6
%16 = icmp ult i64 %14, %15
br i1 %16, label %17, label %30
17: ; preds = %12
%18 = load i8*, i8** %8
%19 = load i32, i32* %9
%20 = zext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
%22 = load i8, i8* %21
%23 = load i8*, i8** %7
%24 = load i32, i32* %9
%25 = zext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
store i8 %22, i8* %26
br label %27
27: ; preds = %17
%28 = load i32, i32* %9
%29 = add i32 %28, 1
store i32 %29, i32* %9
br label %12
30: ; preds = %12
%31 = load i8*, i8** %7
%32 = load i32, i32* %9
%33 = zext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
store i8 0, i8* %34
ret i8* null
}

LLVM IR (-O2):
define noalias i8* @mmemcpy(i8* nocapture writeonly %0, i8* nocapture %1, i64 %2) {
%4 = icmp eq i64 %2, 0
br i1 %4, label %16, label %5
5: ; preds = %3, %5
%6 = phi i64 [ %12, %5 ], [ 0, %3 ]
%7 = trunc i64 %6 to i32
%8 = getelementptr inbounds i8, i8* %1, i64 %6
%9 = load i8, i8* %8
%10 = getelementptr inbounds i8, i8* %0, i64 %6
store i8 %9, i8* %10
%11 = add i32 %7, 1
%12 = zext i32 %11 to i64
%13 = icmp ult i64 %12, %2
br i1 %13, label %5, label %14
14: ; preds = %5
%15 = zext i32 %11 to i64
br label %16
16: ; preds = %3, %14
%17 = phi i64 [ %15, %14 ], [ 0, %3 ]
%18 = getelementptr inbounds i8, i8* %0, i64 %17
store i8 0, i8* %18
ret i8* null
}