#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 const *, char *, unsigned char *, unsigned char *,
           unsigned char *, unsigned char *, unsigned char *, unsigned char *);
int parse_mac(const char *mac_str, unsigned char *buf) {
  int t;
  t = sscanf(mac_str, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx", &buf[0],
             &buf[1], &buf[2], &buf[3], &buf[4], &buf[5]);
  if (t != 6)
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<parse_mac>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x18(%rbp),%rcx
add    $0x1,%rcx
mov    -0x18(%rbp),%r8
add    $0x2,%r8
mov    -0x18(%rbp),%r9
add    $0x3,%r9
mov    -0x18(%rbp),%r10
add    $0x4,%r10
mov    -0x18(%rbp),%rax
add    $0x5,%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_mac+0x6e>
movl   $0x1,-0x4(%rbp)
jmp    1185 <parse_mac+0x75>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_mac>:
push   %rax
mov    %rsi,%rdx
lea    0x1(%rsi),%rcx
lea    0x2(%rsi),%r8
lea    0x3(%rsi),%r9
lea    0x4(%rsi),%r10
lea    0x5(%rsi),%rax
lea    0xed1(%rip),%rsi
push   %rax
push   %r10
call   1030 <sscanf@plt>
add    $0x10,%rsp
xor    %ecx,%ecx
cmp    $0x6,%eax
setne  %cl
mov    %ecx,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [42 x i8] c"%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx\00"
define i32 @parse_mac(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %4
%8 = load i8*, i8** %5
%9 = getelementptr inbounds i8, i8* %8, i64 0
%10 = load i8*, i8** %5
%11 = getelementptr inbounds i8, i8* %10, i64 1
%12 = load i8*, i8** %5
%13 = getelementptr inbounds i8, i8* %12, i64 2
%14 = load i8*, i8** %5
%15 = getelementptr inbounds i8, i8* %14, i64 3
%16 = load i8*, i8** %5
%17 = getelementptr inbounds i8, i8* %16, i64 4
%18 = load i8*, i8** %5
%19 = getelementptr inbounds i8, i8* %18, i64 5
%20 = call i32 @sscanf(i8* %7, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i8* %9, i8* %11, i8* %13, i8* %15, i8* %17, i8* %19)
store i32 %20, i32* %6
%21 = load i32, i32* %6
%22 = icmp ne i32 %21, 6
br i1 %22, label %23, label %24
23: ; preds = %2
store i32 1, i32* %3
br label %25
24: ; preds = %2
store i32 0, i32* %3
br label %25
25: ; preds = %24, %23
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
@.str = [42 x i8] c"%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx\00"
define i32 @parse_mac(i8* nocapture %0, i8* %1) {
%3 = getelementptr inbounds i8, i8* %1, i64 1
%4 = getelementptr inbounds i8, i8* %1, i64 2
%5 = getelementptr inbounds i8, i8* %1, i64 3
%6 = getelementptr inbounds i8, i8* %1, i64 4
%7 = getelementptr inbounds i8, i8* %1, i64 5
%8 = tail call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %3, i8* %4, i8* %5, i8* %6, i8* %7)
%9 = icmp ne i32 %8, 6
%10 = zext i1 %9 to i32
ret i32 %10
}