#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 */
struct __sk_buff {
  int dummy;
};

/* Variables and functions */
unsigned char load_byte(struct __sk_buff *, int);
void fill_haddr(struct __sk_buff *skb, int offset, unsigned char *mac) {
  mac[0] = load_byte(skb, offset);
  mac[1] = load_byte(skb, offset + 1);
  mac[2] = load_byte(skb, offset + 2);
  mac[3] = load_byte(skb, offset + 3);
  mac[4] = load_byte(skb, offset + 4);
  mac[5] = load_byte(skb, offset + 5);
}


x86 assembly (clang, -O0):
<fill_haddr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <load_byte@plt>
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
add    $0x1,%esi
call   1030 <load_byte@plt>
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
add    $0x2,%esi
call   1030 <load_byte@plt>
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
add    $0x3,%esi
call   1030 <load_byte@plt>
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,0x3(%rax)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
add    $0x4,%esi
call   1030 <load_byte@plt>
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,0x4(%rax)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
add    $0x5,%esi
call   1030 <load_byte@plt>
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,0x5(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fill_haddr>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %esi,%ebx
mov    %rdi,%r15
call   1030 <load_byte@plt>
mov    %al,(%r14)
lea    0x1(%rbx),%esi
mov    %r15,%rdi
call   1030 <load_byte@plt>
mov    %al,0x1(%r14)
lea    0x2(%rbx),%esi
mov    %r15,%rdi
call   1030 <load_byte@plt>
mov    %al,0x2(%r14)
lea    0x3(%rbx),%esi
mov    %r15,%rdi
call   1030 <load_byte@plt>
mov    %al,0x3(%r14)
lea    0x4(%rbx),%esi
mov    %r15,%rdi
call   1030 <load_byte@plt>
mov    %al,0x4(%r14)
add    $0x5,%ebx
mov    %r15,%rdi
mov    %ebx,%esi
call   1030 <load_byte@plt>
mov    %al,0x5(%r14)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.__sk_buff = type { i32 }
define void @fill_haddr(%struct.__sk_buff* %0, i32 %1, i8* %2) {
%4 = alloca %struct.__sk_buff*
%5 = alloca i32
%6 = alloca i8*
store %struct.__sk_buff* %0, %struct.__sk_buff** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%7 = load %struct.__sk_buff*, %struct.__sk_buff** %4
%8 = load i32, i32* %5
%9 = call zeroext i8 @load_byte(%struct.__sk_buff* %7, i32 %8)
%10 = load i8*, i8** %6
%11 = getelementptr inbounds i8, i8* %10, i64 0
store i8 %9, i8* %11
%12 = load %struct.__sk_buff*, %struct.__sk_buff** %4
%13 = load i32, i32* %5
%14 = add nsw i32 %13, 1
%15 = call zeroext i8 @load_byte(%struct.__sk_buff* %12, i32 %14)
%16 = load i8*, i8** %6
%17 = getelementptr inbounds i8, i8* %16, i64 1
store i8 %15, i8* %17
%18 = load %struct.__sk_buff*, %struct.__sk_buff** %4
%19 = load i32, i32* %5
%20 = add nsw i32 %19, 2
%21 = call zeroext i8 @load_byte(%struct.__sk_buff* %18, i32 %20)
%22 = load i8*, i8** %6
%23 = getelementptr inbounds i8, i8* %22, i64 2
store i8 %21, i8* %23
%24 = load %struct.__sk_buff*, %struct.__sk_buff** %4
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 3
%27 = call zeroext i8 @load_byte(%struct.__sk_buff* %24, i32 %26)
%28 = load i8*, i8** %6
%29 = getelementptr inbounds i8, i8* %28, i64 3
store i8 %27, i8* %29
%30 = load %struct.__sk_buff*, %struct.__sk_buff** %4
%31 = load i32, i32* %5
%32 = add nsw i32 %31, 4
%33 = call zeroext i8 @load_byte(%struct.__sk_buff* %30, i32 %32)
%34 = load i8*, i8** %6
%35 = getelementptr inbounds i8, i8* %34, i64 4
store i8 %33, i8* %35
%36 = load %struct.__sk_buff*, %struct.__sk_buff** %4
%37 = load i32, i32* %5
%38 = add nsw i32 %37, 5
%39 = call zeroext i8 @load_byte(%struct.__sk_buff* %36, i32 %38)
%40 = load i8*, i8** %6
%41 = getelementptr inbounds i8, i8* %40, i64 5
store i8 %39, i8* %41
ret void
}

LLVM IR (-O2):
%struct.__sk_buff = type { i32 }
define void @fill_haddr(%struct.__sk_buff* %0, i32 %1, i8* nocapture writeonly %2) {
%4 = tail call zeroext i8 @load_byte(%struct.__sk_buff* %0, i32 %1)
store i8 %4, i8* %2
%5 = add nsw i32 %1, 1
%6 = tail call zeroext i8 @load_byte(%struct.__sk_buff* %0, i32 %5)
%7 = getelementptr inbounds i8, i8* %2, i64 1
store i8 %6, i8* %7
%8 = add nsw i32 %1, 2
%9 = tail call zeroext i8 @load_byte(%struct.__sk_buff* %0, i32 %8)
%10 = getelementptr inbounds i8, i8* %2, i64 2
store i8 %9, i8* %10
%11 = add nsw i32 %1, 3
%12 = tail call zeroext i8 @load_byte(%struct.__sk_buff* %0, i32 %11)
%13 = getelementptr inbounds i8, i8* %2, i64 3
store i8 %12, i8* %13
%14 = add nsw i32 %1, 4
%15 = tail call zeroext i8 @load_byte(%struct.__sk_buff* %0, i32 %14)
%16 = getelementptr inbounds i8, i8* %2, i64 4
store i8 %15, i8* %16
%17 = add nsw i32 %1, 5
%18 = tail call zeroext i8 @load_byte(%struct.__sk_buff* %0, i32 %17)
%19 = getelementptr inbounds i8, i8* %2, i64 5
store i8 %18, i8* %19
ret void
}