#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 */
scalar_t__ mac_verify(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *mac_get_hex(char *full_mac) {
  if (mac_verify(full_mac))
    return ("INVALID_MAC");
  int i;
  static char addr_buffer[18] = {0};
  strncpy(addr_buffer, full_mac, 17);
  for (i = 2; i < 17; i += 3)
    addr_buffer[i] = 45;
  return (addr_buffer);
}


x86 assembly (clang, -O0):
<mac_get_hex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <mac_verify@plt>
cmp    $0x0,%rax
je     114f <mac_get_hex+0x2f>
lea    0xeba(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    119d <mac_get_hex+0x7d>
mov    -0x10(%rbp),%rsi
lea    0x2ee6(%rip),%rdi
mov    $0x11,%edx
call   1030 <strncpy@plt>
movl   $0x2,-0x14(%rbp)
cmpl   $0x11,-0x14(%rbp)
jge    1192 <mac_get_hex+0x72>
movslq -0x14(%rbp),%rcx
lea    0x2ec0(%rip),%rax
movb   $0x2d,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x14(%rbp)
jmp    116b <mac_get_hex+0x4b>
lea    0x2ea7(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mac_get_hex>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1040 <mac_verify@plt>
test   %rax,%rax
je     113a <mac_get_hex+0x1a>
lea    0xec8(%rip),%r14
jmp    1174 <mac_get_hex+0x54>
lea    0x2eff(%rip),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x11,%edx
call   1030 <strncpy@plt>
movb   $0x2d,0x2eea(%rip)
movb   $0x2d,0x2ee6(%rip)
movb   $0x2d,0x2ee2(%rip)
movb   $0x2d,0x2ede(%rip)
movb   $0x2d,0x2eda(%rip)
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [12 x i8] c"INVALID_MAC\00"
@mac_get_hex.addr_buffer = internal global [18 x i8] zeroinitializer
define i8* @mac_get_hex(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i64 @mac_verify(i8* %5)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %1
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %2
br label %23
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = call i32 @strncpy(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @mac_get_hex.addr_buffer, i64 0, i64 0), i8* %10, i32 17)
store i32 2, i32* %4
br label %12
12: ; preds = %19, %9
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 17
br i1 %14, label %15, label %22
15: ; preds = %12
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [18 x i8], [18 x i8]* @mac_get_hex.addr_buffer, i64 0, i64 %17
store i8 45, i8* %18
br label %19
19: ; preds = %15
%20 = load i32, i32* %4
%21 = add nsw i32 %20, 3
store i32 %21, i32* %4
br label %12
22: ; preds = %12
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @mac_get_hex.addr_buffer, i64 0, i64 0), i8** %2
br label %23
23: ; preds = %22, %8
%24 = load i8*, i8** %2
ret i8* %24
}

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