#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 int u_int;
typedef int u_char;
typedef int /*<<< orphan*/ n;

/* Variables and functions */
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int sscanf(char *, char *, int *, int *, int *, int *, int *, int *);
int str2e(char *str, u_char *e) {
  int i;
  u_int n[6];
  memset((char *)n, 0, sizeof(n));
  if (sscanf(str, "%x:%x:%x:%x:%x:%x", &n[0], &n[1], &n[2], &n[3], &n[4],
             &n[5]) != 6)
    return (0);
  for (i = 0; i < 6; ++i) {
    if (n[i] > 0xff)
      return (0);
    e[i] = n[i];
  }
  return (1);
}


x86 assembly (clang, -O0):
<str2e>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1030 <memset@plt>
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    0xe89(%rip),%rsi
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1040 <sscanf@plt>
cmp    $0x6,%eax
je     119a <str2e+0x7a>
movl   $0x0,-0x4(%rbp)
jmp    11f1 <str2e+0xd1>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x6,-0x1c(%rbp)
jge    11ea <str2e+0xca>
movslq -0x1c(%rbp),%rax
cmpl   $0xff,-0x40(%rbp,%rax,4)
jle    11c9 <str2e+0xa9>
movl   $0x0,-0x4(%rbp)
jmp    11f1 <str2e+0xd1>
movslq -0x1c(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%edx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a1 <str2e+0x81>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str2e>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsp,%rbp
xor    %r15d,%r15d
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1030 <memset@plt>
lea    0x4(%rsp),%rcx
lea    0x8(%rsp),%r8
lea    0xc(%rsp),%r9
lea    0x10(%rsp),%r10
lea    0x14(%rsp),%rax
lea    0xe9b(%rip),%rsi
mov    %rbx,%rdi
mov    %rbp,%rdx
push   %rax
push   %r10
call   1040 <sscanf@plt>
add    $0x10,%rsp
cmp    $0x6,%eax
jne    11da <str2e+0xba>
mov    (%rsp),%eax
cmp    $0xff,%eax
jg     11da <str2e+0xba>
mov    %eax,(%r14)
mov    0x4(%rsp),%eax
cmp    $0xff,%eax
jg     11da <str2e+0xba>
mov    %eax,0x4(%r14)
mov    0x8(%rsp),%eax
cmp    $0xff,%eax
jg     11da <str2e+0xba>
mov    %eax,0x8(%r14)
mov    0xc(%rsp),%eax
cmp    $0xff,%eax
jg     11da <str2e+0xba>
mov    %eax,0xc(%r14)
mov    0x10(%rsp),%eax
cmp    $0xff,%eax
jg     11da <str2e+0xba>
mov    %eax,0x10(%r14)
mov    0x14(%rsp),%eax
cmp    $0xff,%eax
jg     11da <str2e+0xba>
mov    %eax,0x14(%r14)
mov    $0x1,%r15d
mov    %r15d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [18 x i8] c"%x:%x:%x:%x:%x:%x\00"
define i32 @str2e(i8* nocapture %0, i32* 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 = call i32 @memset(i8* %4, i32 0, i32 24)
%7 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 1
%8 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 2
%9 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 3
%10 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 4
%11 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 5
%12 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32* %5, i32* %7, i32* %8, i32* %9, i32* %10, i32* %11)
%13 = icmp eq i32 %12, 6
br i1 %13, label %14, label %38
14: ; preds = %2
%15 = load i32, i32* %5
%16 = icmp sgt i32 %15, 255
br i1 %16, label %38, label %17
17: ; preds = %14
store i32 %15, i32* %1
%18 = load i32, i32* %7
%19 = icmp sgt i32 %18, 255
br i1 %19, label %38, label %20
20: ; preds = %17
%21 = getelementptr inbounds i32, i32* %1, i64 1
store i32 %18, i32* %21
%22 = load i32, i32* %8
%23 = icmp sgt i32 %22, 255
br i1 %23, label %38, label %24
24: ; preds = %20
%25 = getelementptr inbounds i32, i32* %1, i64 2
store i32 %22, i32* %25
%26 = load i32, i32* %9
%27 = icmp sgt i32 %26, 255
br i1 %27, label %38, label %28
28: ; preds = %24
%29 = getelementptr inbounds i32, i32* %1, i64 3
store i32 %26, i32* %29
%30 = load i32, i32* %10
%31 = icmp sgt i32 %30, 255
br i1 %31, label %38, label %32
32: ; preds = %28
%33 = getelementptr inbounds i32, i32* %1, i64 4
store i32 %30, i32* %33
%34 = load i32, i32* %11
%35 = icmp sgt i32 %34, 255
br i1 %35, label %38, label %36
36: ; preds = %32
%37 = getelementptr inbounds i32, i32* %1, i64 5
store i32 %34, i32* %37
br label %38
38: ; preds = %14, %17, %20, %24, %28, %32, %36, %2
%39 = phi i32 [ 0, %2 ], [ 0, %14 ], [ 0, %17 ], [ 0, %20 ], [ 0, %24 ], [ 0, %28 ], [ 0, %32 ], [ 1, %36 ]
ret i32 %39
}