#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 unsigned char uint8_t;

/* Variables and functions */
int /*<<< orphan*/ strncpy(char *, char *, int);
scalar_t__ strtoul(char *, int /*<<< orphan*/ *, int);
void read_mac(char *str, uint8_t *mac) {
  char m[3];
  char *c;
  int i = 0;
  c = str;
  for (i = 0; i < 6; i++) {
    strncpy(m, c, 2);
    m[2] = 0;
    mac[i] = (unsigned char)strtoul(m, NULL, 16);
    c += 2;
  }
}


x86 assembly (clang, -O0):
<read_mac>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x6,-0x24(%rbp)
jge    119f <read_mac+0x7f>
lea    -0x13(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0x2,%edx
call   1030 <strncpy@plt>
movb   $0x0,-0x11(%rbp)
lea    -0x13(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1040 <strtoul@plt>
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1146 <read_mac+0x26>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_mac>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xd(%rsp),%r15
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x2,%edx
call   1030 <strncpy@plt>
movb   $0x0,0xf(%rsp)
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <strtoul@plt>
mov    %al,(%r14)
lea    0x2(%rbx),%rsi
mov    %r15,%rdi
mov    $0x2,%edx
call   1030 <strncpy@plt>
movb   $0x0,0xf(%rsp)
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <strtoul@plt>
mov    %al,0x1(%r14)
lea    0x4(%rbx),%rsi
mov    %r15,%rdi
mov    $0x2,%edx
call   1030 <strncpy@plt>
movb   $0x0,0xf(%rsp)
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <strtoul@plt>
mov    %al,0x2(%r14)
lea    0x6(%rbx),%rsi
mov    %r15,%rdi
mov    $0x2,%edx
call   1030 <strncpy@plt>
movb   $0x0,0xf(%rsp)
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <strtoul@plt>
mov    %al,0x3(%r14)
lea    0x8(%rbx),%rsi
mov    %r15,%rdi
mov    $0x2,%edx
call   1030 <strncpy@plt>
movb   $0x0,0xf(%rsp)
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <strtoul@plt>
mov    %al,0x4(%r14)
add    $0xa,%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x2,%edx
call   1030 <strncpy@plt>
movb   $0x0,0xf(%rsp)
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <strtoul@plt>
mov    %al,0x5(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @read_mac(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [3 x i8]
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %7
%8 = load i8*, i8** %3
store i8* %8, i8** %6
store i32 0, i32* %7
br label %9
9: ; preds = %26, %2
%10 = load i32, i32* %7
%11 = icmp slt i32 %10, 6
br i1 %11, label %12, label %29
12: ; preds = %9
%13 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%14 = load i8*, i8** %6
%15 = call i32 @strncpy(i8* %13, i8* %14, i32 2)
%16 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 2
store i8 0, i8* %16
%17 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%18 = call i64 @strtoul(i8* %17, i32* null, i32 16)
%19 = trunc i64 %18 to i8
%20 = load i8*, i8** %4
%21 = load i32, i32* %7
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
store i8 %19, i8* %23
%24 = load i8*, i8** %6
%25 = getelementptr inbounds i8, i8* %24, i64 2
store i8* %25, i8** %6
br label %26
26: ; preds = %12
%27 = load i32, i32* %7
%28 = add nsw i32 %27, 1
store i32 %28, i32* %7
br label %9
29: ; preds = %9
ret void
}

LLVM IR (-O2):
define void @read_mac(i8* %0, i8* nocapture writeonly %1) {
%3 = alloca [3 x i8]
%4 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%5 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 2
%6 = call i32 @strncpy(i8* %4, i8* %0, i32 2)
store i8 0, i8* %5
%7 = call i64 @strtoul(i8* nocapture %4, i32* null, i32 16)
%8 = trunc i64 %7 to i8
store i8 %8, i8* %1
%9 = getelementptr inbounds i8, i8* %0, i64 2
%10 = call i32 @strncpy(i8* %4, i8* %9, i32 2)
store i8 0, i8* %5
%11 = call i64 @strtoul(i8* nocapture %4, i32* null, i32 16)
%12 = trunc i64 %11 to i8
%13 = getelementptr inbounds i8, i8* %1, i64 1
store i8 %12, i8* %13
%14 = getelementptr inbounds i8, i8* %0, i64 4
%15 = call i32 @strncpy(i8* %4, i8* %14, i32 2)
store i8 0, i8* %5
%16 = call i64 @strtoul(i8* nocapture %4, i32* null, i32 16)
%17 = trunc i64 %16 to i8
%18 = getelementptr inbounds i8, i8* %1, i64 2
store i8 %17, i8* %18
%19 = getelementptr inbounds i8, i8* %0, i64 6
%20 = call i32 @strncpy(i8* %4, i8* %19, i32 2)
store i8 0, i8* %5
%21 = call i64 @strtoul(i8* nocapture %4, i32* null, i32 16)
%22 = trunc i64 %21 to i8
%23 = getelementptr inbounds i8, i8* %1, i64 3
store i8 %22, i8* %23
%24 = getelementptr inbounds i8, i8* %0, i64 8
%25 = call i32 @strncpy(i8* %4, i8* %24, i32 2)
store i8 0, i8* %5
%26 = call i64 @strtoul(i8* nocapture %4, i32* null, i32 16)
%27 = trunc i64 %26 to i8
%28 = getelementptr inbounds i8, i8* %1, i64 4
store i8 %27, i8* %28
%29 = getelementptr inbounds i8, i8* %0, i64 10
%30 = call i32 @strncpy(i8* %4, i8* %29, i32 2)
store i8 0, i8* %5
%31 = call i64 @strtoul(i8* nocapture %4, i32* null, i32 16)
%32 = trunc i64 %31 to i8
%33 = getelementptr inbounds i8, i8* %1, i64 5
store i8 %32, i8* %33
ret void
}