#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*/ temp;

/* Variables and functions */
int /*<<< orphan*/ Free(char *, int);
char *Malloc(int /*<<< orphan*/);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ strtok(char *, char *);
char xtoi(int /*<<< orphan*/);
char *getmymac(char *token) {
  static char mac[6];
  char *temp = Malloc(strlen(token));
  strcpy(temp, token);
  mac[0] = xtoi(strtok(temp, ":"));
  mac[1] = xtoi(strtok(0, ":"));
  mac[2] = xtoi(strtok(0, ":"));
  mac[3] = xtoi(strtok(0, ":"));
  mac[4] = xtoi(strtok(0, ":"));
  mac[5] = xtoi(strtok(0, ":"));
  Free(temp, sizeof(temp));
  return mac;
}


x86 assembly (clang, -O0):
<getmymac>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%edi
call   1030 <Malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x10(%rbp),%rdi
lea    0xe68(%rip),%rsi
call   1080 <strtok@plt>
mov    %eax,%edi
call   1070 <xtoi@plt>
mov    %al,0x2ea7(%rip)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe4b(%rip),%rsi
call   1080 <strtok@plt>
mov    %eax,%edi
call   1070 <xtoi@plt>
mov    %al,0x2e8b(%rip)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe2e(%rip),%rsi
call   1080 <strtok@plt>
mov    %eax,%edi
call   1070 <xtoi@plt>
mov    %al,0x2e6f(%rip)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe11(%rip),%rsi
call   1080 <strtok@plt>
mov    %eax,%edi
call   1070 <xtoi@plt>
mov    %al,0x2e53(%rip)
xor    %eax,%eax
mov    %eax,%edi
lea    0xdf4(%rip),%rsi
call   1080 <strtok@plt>
mov    %eax,%edi
call   1070 <xtoi@plt>
mov    %al,0x2e37(%rip)
xor    %eax,%eax
mov    %eax,%edi
lea    0xdd7(%rip),%rsi
call   1080 <strtok@plt>
mov    %eax,%edi
call   1070 <xtoi@plt>
mov    %al,0x2e1b(%rip)
mov    -0x10(%rbp),%rdi
mov    $0x8,%esi
call   1060 <Free@plt>
lea    0x2e01(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getmymac>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1050 <strlen@plt>
mov    %eax,%edi
call   1030 <Malloc@plt>
mov    %rax,%r15
mov    %rax,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
lea    0xe77(%rip),%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1080 <strtok@plt>
mov    %eax,%edi
call   1070 <xtoi@plt>
mov    %al,0x2eb0(%rip)
lea    0x2ea9(%rip),%r14
xor    %edi,%edi
mov    %rbx,%rsi
call   1080 <strtok@plt>
mov    %eax,%edi
call   1070 <xtoi@plt>
mov    %al,0x2e93(%rip)
xor    %edi,%edi
mov    %rbx,%rsi
call   1080 <strtok@plt>
mov    %eax,%edi
call   1070 <xtoi@plt>
mov    %al,0x2e7d(%rip)
xor    %edi,%edi
mov    %rbx,%rsi
call   1080 <strtok@plt>
mov    %eax,%edi
call   1070 <xtoi@plt>
mov    %al,0x2e67(%rip)
xor    %edi,%edi
mov    %rbx,%rsi
call   1080 <strtok@plt>
mov    %eax,%edi
call   1070 <xtoi@plt>
mov    %al,0x2e51(%rip)
xor    %edi,%edi
mov    %rbx,%rsi
call   1080 <strtok@plt>
mov    %eax,%edi
call   1070 <xtoi@plt>
mov    %al,0x2e3b(%rip)
mov    %r15,%rdi
mov    $0x8,%esi
call   1060 <Free@plt>
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@getmymac.mac = internal global [6 x i8] zeroinitializer
@.str = [2 x i8] c":\00"
define i8* @getmymac(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 @strlen(i8* %4)
%6 = call i8* @Malloc(i32 %5)
store i8* %6, i8** %3
%7 = load i8*, i8** %3
%8 = load i8*, i8** %2
%9 = call i32 @strcpy(i8* %7, i8* %8)
%10 = load i8*, i8** %3
%11 = call i32 @strtok(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = call signext i8 @xtoi(i32 %11)
store i8 %12, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @getmymac.mac, i64 0, i64 0)
%13 = call i32 @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = call signext i8 @xtoi(i32 %13)
store i8 %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @getmymac.mac, i64 0, i64 1)
%15 = call i32 @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%16 = call signext i8 @xtoi(i32 %15)
store i8 %16, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @getmymac.mac, i64 0, i64 2)
%17 = call i32 @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%18 = call signext i8 @xtoi(i32 %17)
store i8 %18, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @getmymac.mac, i64 0, i64 3)
%19 = call i32 @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%20 = call signext i8 @xtoi(i32 %19)
store i8 %20, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @getmymac.mac, i64 0, i64 4)
%21 = call i32 @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%22 = call signext i8 @xtoi(i32 %21)
store i8 %22, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @getmymac.mac, i64 0, i64 5)
%23 = load i8*, i8** %3
%24 = call i32 @Free(i8* %23, i32 8)
ret i8* getelementptr inbounds ([6 x i8], [6 x i8]* @getmymac.mac, i64 0, i64 0)
}

LLVM IR (-O2):
@getmymac.mac = internal global [6 x i8] zeroinitializer
@.str = [2 x i8] c":\00"
define i8* @getmymac(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = tail call i8* @Malloc(i32 %2)
%4 = tail call i32 @strcpy(i8* %3, i8* %0)
%5 = tail call i32 @strtok(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = tail call signext i8 @xtoi(i32 %5)
store i8 %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @getmymac.mac, i64 0, i64 0)
%7 = tail call i32 @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = tail call signext i8 @xtoi(i32 %7)
store i8 %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @getmymac.mac, i64 0, i64 1)
%9 = tail call i32 @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = tail call signext i8 @xtoi(i32 %9)
store i8 %10, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @getmymac.mac, i64 0, i64 2)
%11 = tail call i32 @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = tail call signext i8 @xtoi(i32 %11)
store i8 %12, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @getmymac.mac, i64 0, i64 3)
%13 = tail call i32 @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = tail call signext i8 @xtoi(i32 %13)
store i8 %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @getmymac.mac, i64 0, i64 4)
%15 = tail call i32 @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%16 = tail call signext i8 @xtoi(i32 %15)
store i8 %16, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @getmymac.mac, i64 0, i64 5)
%17 = tail call i32 @Free(i8* %3, i32 8)
ret i8* getelementptr inbounds ([6 x i8], [6 x i8]* @getmymac.mac, i64 0, i64 0)
}