#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*/ ho_memcpy(char *, char *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ write(int, int /*<<< orphan*/, int);
int main() {
  char buf[128] = "";
  write(1, ho_memcpy(buf, "12345", 5), 5);
  printf("\n");
  write(1, ho_memcpy(buf, "12", 2), 2);
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1060 <memset@plt>
lea    -0x90(%rbp),%rdi
lea    0xe8d(%rip),%rsi
mov    $0x5,%edx
call   1040 <ho_memcpy@plt>
mov    %eax,%esi
mov    $0x1,%edi
mov    $0x5,%edx
call   1030 <write@plt>
lea    0xe71(%rip),%rdi
call   1050 <printf@plt>
lea    -0x90(%rbp),%rdi
lea    0xe60(%rip),%rsi
mov    $0x2,%edx
call   1040 <ho_memcpy@plt>
mov    %eax,%esi
mov    $0x1,%edi
mov    $0x2,%edx
call   1030 <write@plt>
lea    0xe3c(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x80,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
lea    0xe97(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x5,%edx
call   1050 <ho_memcpy@plt>
mov    $0x1,%edi
mov    %eax,%esi
mov    $0x5,%edx
call   1040 <write@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe6b(%rip),%rsi
mov    %rbx,%rdi
mov    $0x2,%edx
call   1050 <ho_memcpy@plt>
mov    $0x1,%edi
mov    %eax,%esi
mov    $0x2,%edx
call   1040 <write@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"12345\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [3 x i8] c"12\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [128 x i8]
store i32 0, i32* %1
%3 = bitcast [128 x i8]* %2 to i8*
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%5 = call i32 @ho_memcpy(i8* %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 5)
%6 = call i32 @write(i32 1, i32 %5, i32 5)
%7 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%8 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%9 = call i32 @ho_memcpy(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 2)
%10 = call i32 @write(i32 1, i32 %9, i32 2)
%11 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"12345\00"
@.str.2 = [3 x i8] c"12\00"
define i32 @main() {
%1 = alloca [128 x i8]
%2 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
%3 = call i32 @ho_memcpy(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 5)
%4 = call i32 @write(i32 1, i32 %3, i32 5)
%5 = call i32 @putchar(i32 10)
%6 = call i32 @ho_memcpy(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 2)
%7 = call i32 @write(i32 1, i32 %6, i32 2)
%8 = call i32 @putchar(i32 10)
ret i32 0
}