#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*/ memcpy2(unsigned char *, unsigned char const *, int);
void EthernetCreateResponse(unsigned char *packetOut,
                            const unsigned char *packet, int length) {
  memcpy2(packetOut, packet, length);
  memcpy2(packetOut + 0, packet + 6, 6);
  memcpy2(packetOut + 6, packet + 0, 6);
  if (packet[12 + 1] == 0x00) {
    memcpy2(packetOut + 26, packet + 30, 4);
    memcpy2(packetOut + 30, packet + 26, 4);
    if (packet[23] == 0x06 || packet[23] == 0x11) {
      memcpy2(packetOut + 34, packet + 36, 2);
      memcpy2(packetOut + 36, packet + 34, 2);
    }
  }
}


x86 assembly (clang, -O0):
<EthernetCreateResponse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <memcpy2@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x6,%rsi
mov    $0x6,%edx
call   1030 <memcpy2@plt>
mov    -0x8(%rbp),%rdi
add    $0x6,%rdi
mov    -0x10(%rbp),%rsi
mov    $0x6,%edx
call   1030 <memcpy2@plt>
mov    -0x10(%rbp),%rax
movzbl 0xd(%rax),%eax
cmp    $0x0,%eax
jne    11ff <EthernetCreateResponse+0xef>
mov    -0x8(%rbp),%rdi
add    $0x1a,%rdi
mov    -0x10(%rbp),%rsi
add    $0x1e,%rsi
mov    $0x4,%edx
call   1030 <memcpy2@plt>
mov    -0x8(%rbp),%rdi
add    $0x1e,%rdi
mov    -0x10(%rbp),%rsi
add    $0x1a,%rsi
mov    $0x4,%edx
call   1030 <memcpy2@plt>
mov    -0x10(%rbp),%rax
movzbl 0x17(%rax),%eax
cmp    $0x6,%eax
je     11c6 <EthernetCreateResponse+0xb6>
mov    -0x10(%rbp),%rax
movzbl 0x17(%rax),%eax
cmp    $0x11,%eax
jne    11fa <EthernetCreateResponse+0xea>
mov    -0x8(%rbp),%rdi
add    $0x22,%rdi
mov    -0x10(%rbp),%rsi
add    $0x24,%rsi
mov    $0x2,%edx
call   1030 <memcpy2@plt>
mov    -0x8(%rbp),%rdi
add    $0x24,%rdi
mov    -0x10(%rbp),%rsi
add    $0x22,%rsi
mov    $0x2,%edx
call   1030 <memcpy2@plt>
jmp    11ff <EthernetCreateResponse+0xef>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<EthernetCreateResponse>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
call   1030 <memcpy2@plt>
lea    0x6(%rbx),%rsi
mov    %r14,%rdi
mov    $0x6,%edx
call   1030 <memcpy2@plt>
lea    0x6(%r14),%rdi
mov    %rbx,%rsi
mov    $0x6,%edx
call   1030 <memcpy2@plt>
cmpb   $0x0,0xd(%rbx)
je     114f <EthernetCreateResponse+0x3f>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0x1a(%r14),%rdi
lea    0x1e(%rbx),%rsi
mov    $0x4,%edx
call   1030 <memcpy2@plt>
lea    0x1e(%r14),%rdi
lea    0x1a(%rbx),%rsi
mov    $0x4,%edx
call   1030 <memcpy2@plt>
mov    0x17(%rbx),%al
cmp    $0x11,%al
je     117e <EthernetCreateResponse+0x6e>
cmp    $0x6,%al
jne    1147 <EthernetCreateResponse+0x37>
lea    0x22(%r14),%rdi
lea    0x24(%rbx),%rsi
mov    $0x2,%edx
call   1030 <memcpy2@plt>
add    $0x24,%r14
add    $0x22,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x2,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <memcpy2@plt>

LLVM IR (-O0):
define void @EthernetCreateResponse(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%7 = load i8*, i8** %4
%8 = load i8*, i8** %5
%9 = load i32, i32* %6
%10 = call i32 @memcpy2(i8* %7, i8* %8, i32 %9)
%11 = load i8*, i8** %4
%12 = getelementptr inbounds i8, i8* %11, i64 0
%13 = load i8*, i8** %5
%14 = getelementptr inbounds i8, i8* %13, i64 6
%15 = call i32 @memcpy2(i8* %12, i8* %14, i32 6)
%16 = load i8*, i8** %4
%17 = getelementptr inbounds i8, i8* %16, i64 6
%18 = load i8*, i8** %5
%19 = getelementptr inbounds i8, i8* %18, i64 0
%20 = call i32 @memcpy2(i8* %17, i8* %19, i32 6)
%21 = load i8*, i8** %5
%22 = getelementptr inbounds i8, i8* %21, i64 13
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %60
26: ; preds = %3
%27 = load i8*, i8** %4
%28 = getelementptr inbounds i8, i8* %27, i64 26
%29 = load i8*, i8** %5
%30 = getelementptr inbounds i8, i8* %29, i64 30
%31 = call i32 @memcpy2(i8* %28, i8* %30, i32 4)
%32 = load i8*, i8** %4
%33 = getelementptr inbounds i8, i8* %32, i64 30
%34 = load i8*, i8** %5
%35 = getelementptr inbounds i8, i8* %34, i64 26
%36 = call i32 @memcpy2(i8* %33, i8* %35, i32 4)
%37 = load i8*, i8** %5
%38 = getelementptr inbounds i8, i8* %37, i64 23
%39 = load i8, i8* %38
%40 = zext i8 %39 to i32
%41 = icmp eq i32 %40, 6
br i1 %41, label %48, label %42
42: ; preds = %26
%43 = load i8*, i8** %5
%44 = getelementptr inbounds i8, i8* %43, i64 23
%45 = load i8, i8* %44
%46 = zext i8 %45 to i32
%47 = icmp eq i32 %46, 17
br i1 %47, label %48, label %59
48: ; preds = %42, %26
%49 = load i8*, i8** %4
%50 = getelementptr inbounds i8, i8* %49, i64 34
%51 = load i8*, i8** %5
%52 = getelementptr inbounds i8, i8* %51, i64 36
%53 = call i32 @memcpy2(i8* %50, i8* %52, i32 2)
%54 = load i8*, i8** %4
%55 = getelementptr inbounds i8, i8* %54, i64 36
%56 = load i8*, i8** %5
%57 = getelementptr inbounds i8, i8* %56, i64 34
%58 = call i32 @memcpy2(i8* %55, i8* %57, i32 2)
br label %59
59: ; preds = %48, %42
br label %60
60: ; preds = %59, %3
ret void
}

LLVM IR (-O2):
define void @EthernetCreateResponse(i8* %0, i8* %1, i32 %2) {
%4 = tail call i32 @memcpy2(i8* %0, i8* %1, i32 %2)
%5 = getelementptr inbounds i8, i8* %1, i64 6
%6 = tail call i32 @memcpy2(i8* %0, i8* %5, i32 6)
%7 = getelementptr inbounds i8, i8* %0, i64 6
%8 = tail call i32 @memcpy2(i8* %7, i8* %1, i32 6)
%9 = getelementptr inbounds i8, i8* %1, i64 13
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 0
br i1 %11, label %12, label %28
12: ; preds = %3
%13 = getelementptr inbounds i8, i8* %0, i64 26
%14 = getelementptr inbounds i8, i8* %1, i64 30
%15 = tail call i32 @memcpy2(i8* %13, i8* %14, i32 4)
%16 = getelementptr inbounds i8, i8* %0, i64 30
%17 = getelementptr inbounds i8, i8* %1, i64 26
%18 = tail call i32 @memcpy2(i8* %16, i8* %17, i32 4)
%19 = getelementptr inbounds i8, i8* %1, i64 23
%20 = load i8, i8* %19
switch i8 %20, label %28 [
i8 6, label %21
i8 17, label %21
]
21: ; preds = %12, %12
%22 = getelementptr inbounds i8, i8* %0, i64 34
%23 = getelementptr inbounds i8, i8* %1, i64 36
%24 = tail call i32 @memcpy2(i8* %22, i8* %23, i32 2)
%25 = getelementptr inbounds i8, i8* %0, i64 36
%26 = getelementptr inbounds i8, i8* %1, i64 34
%27 = tail call i32 @memcpy2(i8* %25, i8* %26, i32 2)
br label %28
28: ; preds = %12, %21, %3
ret void
}