#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 */
typedef int /*<<< orphan*/ addr_buffer;

/* Variables and functions */
scalar_t__ mac_verify(char *);
int /*<<< orphan*/ memset(char *, char, int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *mac_obfuscate(char *full_mac) {
  if (mac_verify(full_mac))
    return ("INVALID_MAC");
  static char addr_buffer[18] = {0};
  memset(addr_buffer, '\0', sizeof(addr_buffer));
  strncpy(addr_buffer, full_mac, 9);
  strcat(addr_buffer, "XX:XX:XX");
  return (addr_buffer);
}


x86 assembly (clang, -O0):
<mac_obfuscate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <mac_verify@plt>
cmp    $0x0,%rax
je     116f <mac_obfuscate+0x2f>
lea    0xe9a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11b5 <mac_obfuscate+0x75>
lea    0x2eda(%rip),%rdi
xor    %esi,%esi
mov    $0x12,%edx
call   1040 <memset@plt>
mov    -0x10(%rbp),%rsi
lea    0x2ec3(%rip),%rdi
mov    $0x9,%edx
call   1030 <strncpy@plt>
lea    0x2eb2(%rip),%rdi
lea    0xe67(%rip),%rsi
call   1060 <strcat@plt>
lea    0x2e9f(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mac_obfuscate>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1050 <mac_verify@plt>
test   %rax,%rax
je     115a <mac_obfuscate+0x1a>
lea    0xea8(%rip),%rbx
jmp    118f <mac_obfuscate+0x4f>
lea    0x2eef(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x12,%edx
call   1040 <memset@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x9,%edx
call   1030 <strncpy@plt>
lea    0xe85(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [12 x i8] c"INVALID_MAC\00"
@mac_obfuscate.addr_buffer = internal global [18 x i8] zeroinitializer
@.str.1 = [9 x i8] c"XX:XX:XX\00"
define i8* @mac_obfuscate(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i64 @mac_verify(i8* %4)
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %1
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %2
br label %13
8: ; preds = %1
%9 = call i32 @memset(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @mac_obfuscate.addr_buffer, i64 0, i64 0), i8 signext 0, i32 18)
%10 = load i8*, i8** %3
%11 = call i32 @strncpy(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @mac_obfuscate.addr_buffer, i64 0, i64 0), i8* %10, i32 9)
%12 = call i32 @strcat(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @mac_obfuscate.addr_buffer, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @mac_obfuscate.addr_buffer, i64 0, i64 0), i8** %2
br label %13
13: ; preds = %8, %7
%14 = load i8*, i8** %2
ret i8* %14
}

LLVM IR (-O2):
@.str = [12 x i8] c"INVALID_MAC\00"
@mac_obfuscate.addr_buffer = internal global [18 x i8] zeroinitializer
@.str.1 = [9 x i8] c"XX:XX:XX\00"
define i8* @mac_obfuscate(i8* %0) {
%2 = tail call i64 @mac_verify(i8* %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = tail call i32 @memset(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @mac_obfuscate.addr_buffer, i64 0, i64 0), i8 signext 0, i32 18)
%6 = tail call i32 @strncpy(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @mac_obfuscate.addr_buffer, i64 0, i64 0), i8* %0, i32 9)
%7 = tail call i32 @strcat(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @mac_obfuscate.addr_buffer, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %8
8: ; preds = %1, %4
%9 = phi i8* [ getelementptr inbounds ([18 x i8], [18 x i8]* @mac_obfuscate.addr_buffer, i64 0, i64 0), %4 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %9
}