#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(unsigned char *, unsigned char *, int);
int create_arp_response_sw(unsigned char *buf, unsigned char *mac,
                           unsigned char *my_ip4) {
  memcpy(buf + 32, buf + 6, 6);
  memcpy(buf + 38, buf + 28, 4);
  memcpy(buf, buf + 6, 6);
  memcpy(buf + 6, mac, 6);
  buf[21] = 0x02;
  memcpy(buf + 22, mac, 6);
  memcpy(buf + 28, my_ip4, 4);
  return 0;
}


x86 assembly (clang, -O0):
<create_arp_response_sw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
add    $0x20,%rdi
mov    -0x8(%rbp),%rsi
add    $0x6,%rsi
mov    $0x6,%edx
call   1030 <memcpy@plt>
mov    -0x8(%rbp),%rdi
add    $0x26,%rdi
mov    -0x8(%rbp),%rsi
add    $0x1c,%rsi
mov    $0x4,%edx
call   1030 <memcpy@plt>
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
add    $0x6,%rsi
mov    $0x6,%edx
call   1030 <memcpy@plt>
mov    -0x8(%rbp),%rdi
add    $0x6,%rdi
mov    -0x10(%rbp),%rsi
mov    $0x6,%edx
call   1030 <memcpy@plt>
mov    -0x8(%rbp),%rax
movb   $0x2,0x15(%rax)
mov    -0x8(%rbp),%rdi
add    $0x16,%rdi
mov    -0x10(%rbp),%rsi
mov    $0x6,%edx
call   1030 <memcpy@plt>
mov    -0x8(%rbp),%rdi
add    $0x1c,%rdi
mov    -0x18(%rbp),%rsi
mov    $0x4,%edx
call   1030 <memcpy@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_arp_response_sw>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
add    $0x20,%rdi
lea    0x6(%rbx),%r12
mov    %r12,%rsi
mov    $0x6,%edx
call   1030 <memcpy@plt>
lea    0x26(%rbx),%rdi
lea    0x1c(%rbx),%r13
mov    %r13,%rsi
mov    $0x4,%edx
call   1030 <memcpy@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x6,%edx
call   1030 <memcpy@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    $0x6,%edx
call   1030 <memcpy@plt>
movb   $0x2,0x15(%rbx)
add    $0x16,%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x6,%edx
call   1030 <memcpy@plt>
mov    %r13,%rdi
mov    %r14,%rsi
mov    $0x4,%edx
call   1030 <memcpy@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @create_arp_response_sw(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%7 = load i8*, i8** %4
%8 = getelementptr inbounds i8, i8* %7, i64 32
%9 = load i8*, i8** %4
%10 = getelementptr inbounds i8, i8* %9, i64 6
%11 = call i32 @memcpy(i8* %8, i8* %10, i32 6)
%12 = load i8*, i8** %4
%13 = getelementptr inbounds i8, i8* %12, i64 38
%14 = load i8*, i8** %4
%15 = getelementptr inbounds i8, i8* %14, i64 28
%16 = call i32 @memcpy(i8* %13, i8* %15, i32 4)
%17 = load i8*, i8** %4
%18 = load i8*, i8** %4
%19 = getelementptr inbounds i8, i8* %18, i64 6
%20 = call i32 @memcpy(i8* %17, i8* %19, i32 6)
%21 = load i8*, i8** %4
%22 = getelementptr inbounds i8, i8* %21, i64 6
%23 = load i8*, i8** %5
%24 = call i32 @memcpy(i8* %22, i8* %23, i32 6)
%25 = load i8*, i8** %4
%26 = getelementptr inbounds i8, i8* %25, i64 21
store i8 2, i8* %26
%27 = load i8*, i8** %4
%28 = getelementptr inbounds i8, i8* %27, i64 22
%29 = load i8*, i8** %5
%30 = call i32 @memcpy(i8* %28, i8* %29, i32 6)
%31 = load i8*, i8** %4
%32 = getelementptr inbounds i8, i8* %31, i64 28
%33 = load i8*, i8** %6
%34 = call i32 @memcpy(i8* %32, i8* %33, i32 4)
ret i32 0
}

LLVM IR (-O2):
define i32 @create_arp_response_sw(i8* %0, i8* %1, i8* %2) {
%4 = getelementptr inbounds i8, i8* %0, i64 32
%5 = getelementptr inbounds i8, i8* %0, i64 6
%6 = tail call i32 @memcpy(i8* %4, i8* %5, i32 6)
%7 = getelementptr inbounds i8, i8* %0, i64 38
%8 = getelementptr inbounds i8, i8* %0, i64 28
%9 = tail call i32 @memcpy(i8* %7, i8* %8, i32 4)
%10 = tail call i32 @memcpy(i8* %0, i8* %5, i32 6)
%11 = tail call i32 @memcpy(i8* %5, i8* %1, i32 6)
%12 = getelementptr inbounds i8, i8* %0, i64 21
store i8 2, i8* %12
%13 = getelementptr inbounds i8, i8* %0, i64 22
%14 = tail call i32 @memcpy(i8* %13, i8* %1, i32 6)
%15 = tail call i32 @memcpy(i8* %8, i8* %2, i32 4)
ret i32 0
}