#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 */
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char **, int);
int /*<<< orphan*/ printf(char *, ...);
int sscanf(char *, char *, unsigned char *, unsigned char *, unsigned char *,
           unsigned char *, unsigned char *, unsigned char *);
int mac_import(char *input, unsigned char *OUT) {
  unsigned char MAC_in[6];
  int i;
  if (sscanf(input, "%2X:%2X:%2X:%2X:%2X:%2X", &MAC_in[0], &MAC_in[1],
             &MAC_in[2], &MAC_in[3], &MAC_in[4], &MAC_in[5]) != 6) {
    printf("Put the MAC in proper format XX:XX:XX:XX:XX:XX.\n");
    return 1;
  }
  printf("Target MAC");
  for (i = 0; i < 6; i++) {
    printf(":%2X", MAC_in[i]);
  }
  printf("\n");
  memcpy(OUT, &MAC_in, 6);
  return 0;
}


x86 assembly (clang, -O0):
<mac_import>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x1e(%rbp),%rdx
lea    -0x1e(%rbp),%rcx
add    $0x1,%rcx
lea    -0x1e(%rbp),%r8
add    $0x2,%r8
lea    -0x1e(%rbp),%r9
add    $0x3,%r9
lea    -0x1e(%rbp),%r10
add    $0x4,%r10
lea    -0x1e(%rbp),%rax
add    $0x5,%rax
lea    0xe89(%rip),%rsi
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1050 <sscanf@plt>
cmp    $0x6,%eax
je     11a8 <mac_import+0x78>
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1213 <mac_import+0xe3>
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x24(%rbp)
cmpl   $0x6,-0x24(%rbp)
jge    11ec <mac_import+0xbc>
movslq -0x24(%rbp),%rax
movzbl -0x1e(%rbp,%rax,1),%esi
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11bd <mac_import+0x8d>
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x1e(%rbp),%rsi
mov    $0x6,%edx
call   1040 <memcpy@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mac_import>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
lea    0xb(%rsp),%rcx
lea    0xc(%rsp),%r8
lea    0xd(%rsp),%r9
lea    0xe(%rsp),%rax
lea    0xf(%rsp),%rbp
lea    0xe85(%rip),%rsi
lea    0xa(%rsp),%rdx
push   %rbp
push   %rax
call   1070 <sscanf@plt>
add    $0x10,%rsp
cmp    $0x6,%eax
jne    1223 <mac_import+0xd3>
lea    0xe7d(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <printf@plt>
movzbl 0xa(%rsp),%esi
lea    0xe63(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl 0xb(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl 0xc(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl 0xd(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl 0xe(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl 0xf(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xa(%rsp),%rsi
mov    %r14,%rdi
mov    $0x6,%edx
call   1060 <memcpy@plt>
jmp    1234 <mac_import+0xe4>
lea    0xdf9(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"%2X:%2X:%2X:%2X:%2X:%2X\00"
@.str.1 = [49 x i8] c"Put the MAC in proper format XX:XX:XX:XX:XX:XX.\0A\00"
@.str.2 = [11 x i8] c"Target MAC\00"
@.str.3 = [5 x i8] c":%2X\00"
@.str.4 = [2 x i8] c"\0A\00"
define i32 @mac_import(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [6 x i8]
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %4
%9 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 0
%10 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 1
%11 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 2
%12 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 3
%13 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 4
%14 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 5
%15 = call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %9, i8* %10, i8* %11, i8* %12, i8* %13, i8* %14)
%16 = icmp ne i32 %15, 6
br i1 %16, label %17, label %19
17: ; preds = %2
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %39
19: ; preds = %2
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %7
br label %21
21: ; preds = %31, %19
%22 = load i32, i32* %7
%23 = icmp slt i32 %22, 6
br i1 %23, label %24, label %34
24: ; preds = %21
%25 = load i32, i32* %7
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = zext i8 %28 to i32
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %29)
br label %31
31: ; preds = %24
%32 = load i32, i32* %7
%33 = add nsw i32 %32, 1
store i32 %33, i32* %7
br label %21
34: ; preds = %21
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%36 = load i8*, i8** %5
%37 = bitcast [6 x i8]* %6 to i8**
%38 = call i32 @memcpy(i8* %36, i8** %37, i32 6)
store i32 0, i32* %3
br label %39
39: ; preds = %34, %17
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
@.str = [24 x i8] c"%2X:%2X:%2X:%2X:%2X:%2X\00"
@.str.2 = [11 x i8] c"Target MAC\00"
@.str.3 = [5 x i8] c":%2X\00"
@str = [48 x i8] c"Put the MAC in proper format XX:XX:XX:XX:XX:XX.\00"
define i32 @mac_import(i8* nocapture %0, i8* %1) {
%3 = alloca [6 x i8]
%4 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%5 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 1
%6 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 2
%7 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 3
%8 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 4
%9 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 5
%10 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %4, i8* %5, i8* %6, i8* %7, i8* %8, i8* %9)
%11 = icmp eq i32 %10, 6
br i1 %11, label %14, label %12
12: ; preds = %2
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str, i64 0, i64 0))
br label %37
14: ; preds = %2
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%16 = load i8, i8* %4
%17 = zext i8 %16 to i32
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %17)
%19 = load i8, i8* %5
%20 = zext i8 %19 to i32
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %20)
%22 = load i8, i8* %6
%23 = zext i8 %22 to i32
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %23)
%25 = load i8, i8* %7
%26 = zext i8 %25 to i32
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %26)
%28 = load i8, i8* %8
%29 = zext i8 %28 to i32
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %29)
%31 = load i8, i8* %9
%32 = zext i8 %31 to i32
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %32)
%34 = call i32 @putchar(i32 10)
%35 = bitcast [6 x i8]* %3 to i8**
%36 = call i32 @memcpy(i8* %1, i8** %35, i32 6)
br label %37
37: ; preds = %14, %12
%38 = phi i32 [ 1, %12 ], [ 0, %14 ]
ret i32 %38
}