#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 sscanf(char *, char *, int *, int *, int *, int *, int *, int *);
int parse_sopass(char *src, unsigned char *dest) {
  int count;
  int i;
  int buf[6];
  count = sscanf(src, "%2x:%2x:%2x:%2x:%2x:%2x", &buf[0], &buf[1], &buf[2],
                 &buf[3], &buf[4], &buf[5]);
  if (count != 6) {
    return -1;
  }
  for (i = 0; i < count; i++) {
    dest[i] = buf[i];
  }
  return 0;
}


x86 assembly (clang, -O0):
<parse_sopass>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x40(%rbp),%rdx
lea    -0x40(%rbp),%rcx
add    $0x4,%rcx
lea    -0x40(%rbp),%r8
add    $0x8,%r8
lea    -0x40(%rbp),%r9
add    $0xc,%r9
lea    -0x40(%rbp),%r10
add    $0x10,%r10
lea    -0x40(%rbp),%rax
add    $0x14,%rax
lea    0xea9(%rip),%rsi
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1030 <sscanf@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x6,-0x1c(%rbp)
je     117e <parse_sopass+0x6e>
movl   $0xffffffff,-0x4(%rbp)
jmp    11bb <parse_sopass+0xab>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11b4 <parse_sopass+0xa4>
movslq -0x20(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%eax
mov    %al,%dl
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1185 <parse_sopass+0x75>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_sopass>:
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%rbx
lea    0x4(%rsp),%rcx
lea    0x8(%rsp),%r8
lea    0xc(%rsp),%r9
lea    0x10(%rsp),%r10
lea    0x14(%rsp),%rax
lea    0xed8(%rip),%rsi
mov    %rsp,%rdx
push   %rax
push   %r10
call   1030 <sscanf@plt>
add    $0x10,%rsp
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    $0x6,%ecx
jne    117c <parse_sopass+0x6c>
movdqa (%rsp),%xmm0
pand   0xea0(%rip),%xmm0
packuswb %xmm0,%xmm0
packuswb %xmm0,%xmm0
movd   %xmm0,(%rbx)
mov    0x10(%rsp),%al
mov    %al,0x4(%rbx)
mov    0x14(%rsp),%al
mov    %al,0x5(%rbx)
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [24 x i8] c"%2x:%2x:%2x:%2x:%2x:%2x\00"
define i32 @parse_sopass(i8* nocapture %0, i8* nocapture writeonly %1) {
%3 = alloca [6 x i32]
%4 = bitcast [6 x i32]* %3 to i8*
%5 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 0
%6 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 1
%7 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 2
%8 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 3
%9 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 4
%10 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 5
%11 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32* %5, i32* %6, i32* %7, i32* %8, i32* %9, i32* %10)
%12 = icmp eq i32 %11, 6
br i1 %12, label %13, label %24
13: ; preds = %2
%14 = bitcast [6 x i32]* %3 to <4 x i32>*
%15 = load <4 x i32>, <4 x i32>* %14
%16 = trunc <4 x i32> %15 to <4 x i8>
%17 = bitcast i8* %1 to <4 x i8>*
store <4 x i8> %16, <4 x i8>* %17
%18 = load i32, i32* %9
%19 = trunc i32 %18 to i8
%20 = getelementptr inbounds i8, i8* %1, i64 4
store i8 %19, i8* %20
%21 = load i32, i32* %10
%22 = trunc i32 %21 to i8
%23 = getelementptr inbounds i8, i8* %1, i64 5
store i8 %22, i8* %23
br label %24
24: ; preds = %13, %2
%25 = phi i32 [ -1, %2 ], [ 0, %13 ]
ret i32 %25
}