void usnic_write_gid_if_id_from_mac(char *mac, char *raw_gid) {
  raw_gid[8] = mac[0] ^ 2;
  raw_gid[9] = mac[1];
  raw_gid[10] = mac[2];
  raw_gid[11] = 0xff;
  raw_gid[12] = 0xfe;
  raw_gid[13] = mac[3];
  raw_gid[14] = mac[4];
  raw_gid[15] = mac[5];
}


x86 assembly (clang, -O0):
<usnic_write_gid_if_id_from_mac>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
xor    $0x2,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x8(%rax)
mov    -0x8(%rbp),%rax
mov    0x1(%rax),%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x9(%rax)
mov    -0x8(%rbp),%rax
mov    0x2(%rax),%cl
mov    -0x10(%rbp),%rax
mov    %cl,0xa(%rax)
mov    -0x10(%rbp),%rax
movb   $0xff,0xb(%rax)
mov    -0x10(%rbp),%rax
movb   $0xfe,0xc(%rax)
mov    -0x8(%rbp),%rax
mov    0x3(%rax),%cl
mov    -0x10(%rbp),%rax
mov    %cl,0xd(%rax)
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%cl
mov    -0x10(%rbp),%rax
mov    %cl,0xe(%rax)
mov    -0x8(%rbp),%rax
mov    0x5(%rax),%cl
mov    -0x10(%rbp),%rax
mov    %cl,0xf(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<usnic_write_gid_if_id_from_mac>:
mov    (%rdi),%al
xor    $0x2,%al
mov    %al,0x8(%rsi)
mov    0x1(%rdi),%al
mov    %al,0x9(%rsi)
mov    0x2(%rdi),%al
mov    %al,0xa(%rsi)
movw   $0xfeff,0xb(%rsi)
mov    0x3(%rdi),%al
mov    %al,0xd(%rsi)
mov    0x4(%rdi),%al
mov    %al,0xe(%rsi)
mov    0x5(%rdi),%al
mov    %al,0xf(%rsi)
ret

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

LLVM IR (-O2):
define void @usnic_write_gid_if_id_from_mac(i8* nocapture %0, i8* nocapture writeonly %1) {
%3 = load i8, i8* %0
%4 = xor i8 %3, 2
%5 = getelementptr inbounds i8, i8* %1, i64 8
store i8 %4, i8* %5
%6 = getelementptr inbounds i8, i8* %0, i64 1
%7 = load i8, i8* %6
%8 = getelementptr inbounds i8, i8* %1, i64 9
store i8 %7, i8* %8
%9 = getelementptr inbounds i8, i8* %0, i64 2
%10 = load i8, i8* %9
%11 = getelementptr inbounds i8, i8* %1, i64 10
store i8 %10, i8* %11
%12 = getelementptr inbounds i8, i8* %1, i64 11
store i8 -1, i8* %12
%13 = getelementptr inbounds i8, i8* %1, i64 12
store i8 -2, i8* %13
%14 = getelementptr inbounds i8, i8* %0, i64 3
%15 = load i8, i8* %14
%16 = getelementptr inbounds i8, i8* %1, i64 13
store i8 %15, i8* %16
%17 = getelementptr inbounds i8, i8* %0, i64 4
%18 = load i8, i8* %17
%19 = getelementptr inbounds i8, i8* %1, i64 14
store i8 %18, i8* %19
%20 = getelementptr inbounds i8, i8* %0, i64 5
%21 = load i8, i8* %20
%22 = getelementptr inbounds i8, i8* %1, i64 15
store i8 %21, i8* %22
ret void
}