#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 */
unsigned char read_byte(unsigned char *, char);
void read_mac(unsigned char *c, unsigned char *mac) {
  int i;
  for (i = 0; i < 6; i++) {
    mac[i] = read_byte(c + (i * 3), ':');
  }
}


x86 assembly (clang, -O0):
<read_mac>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x6,-0x14(%rbp)
jge    1163 <read_mac+0x53>
mov    -0x8(%rbp),%rdi
imul   $0x3,-0x14(%rbp),%eax
cltq
add    %rax,%rdi
mov    $0x3a,%esi
call   1030 <read_byte@plt>
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1127 <read_mac+0x17>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_mac>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x3a,%esi
call   1030 <read_byte@plt>
mov    %al,(%r14)
lea    0x3(%rbx),%rdi
mov    $0x3a,%esi
call   1030 <read_byte@plt>
mov    %al,0x1(%r14)
lea    0x6(%rbx),%rdi
mov    $0x3a,%esi
call   1030 <read_byte@plt>
mov    %al,0x2(%r14)
lea    0x9(%rbx),%rdi
mov    $0x3a,%esi
call   1030 <read_byte@plt>
mov    %al,0x3(%r14)
lea    0xc(%rbx),%rdi
mov    $0x3a,%esi
call   1030 <read_byte@plt>
mov    %al,0x4(%r14)
add    $0xf,%rbx
mov    %rbx,%rdi
mov    $0x3a,%esi
call   1030 <read_byte@plt>
mov    %al,0x5(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @read_mac(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %5
br label %6
6: ; preds = %20, %2
%7 = load i32, i32* %5
%8 = icmp slt i32 %7, 6
br i1 %8, label %9, label %23
9: ; preds = %6
%10 = load i8*, i8** %3
%11 = load i32, i32* %5
%12 = mul nsw i32 %11, 3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %10, i64 %13
%15 = call zeroext i8 @read_byte(i8* %14, i8 signext 58)
%16 = load i8*, i8** %4
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
store i8 %15, i8* %19
br label %20
20: ; preds = %9
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
store i32 %22, i32* %5
br label %6
23: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @read_mac(i8* %0, i8* nocapture writeonly %1) {
%3 = tail call zeroext i8 @read_byte(i8* %0, i8 signext 58)
store i8 %3, i8* %1
%4 = getelementptr inbounds i8, i8* %0, i64 3
%5 = tail call zeroext i8 @read_byte(i8* %4, i8 signext 58)
%6 = getelementptr inbounds i8, i8* %1, i64 1
store i8 %5, i8* %6
%7 = getelementptr inbounds i8, i8* %0, i64 6
%8 = tail call zeroext i8 @read_byte(i8* %7, i8 signext 58)
%9 = getelementptr inbounds i8, i8* %1, i64 2
store i8 %8, i8* %9
%10 = getelementptr inbounds i8, i8* %0, i64 9
%11 = tail call zeroext i8 @read_byte(i8* %10, i8 signext 58)
%12 = getelementptr inbounds i8, i8* %1, i64 3
store i8 %11, i8* %12
%13 = getelementptr inbounds i8, i8* %0, i64 12
%14 = tail call zeroext i8 @read_byte(i8* %13, i8 signext 58)
%15 = getelementptr inbounds i8, i8* %1, i64 4
store i8 %14, i8* %15
%16 = getelementptr inbounds i8, i8* %0, i64 15
%17 = tail call zeroext i8 @read_byte(i8* %16, i8 signext 58)
%18 = getelementptr inbounds i8, i8* %1, i64 5
store i8 %17, i8* %18
ret void
}