#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 */
scalar_t__ parse_octet(char *, int *, char, int, int /*<<< orphan*/, int, int);
int /*<<< orphan*/ printf(char *, ...);
int checketh(char *s) {
  int eth[6];
  if (parse_octet(s, eth, ':', 6, 0, 255, 16)) {
    printf("eth: %02x:%02x:%02x:%02x:%02x:%02x\n", eth[0], eth[1], eth[2],
           eth[3], eth[4], eth[5]);
  } else {
    printf("eth: '%s' - INVALID\n", s);
  }
}


x86 assembly (clang, -O0):
<checketh>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    $0x3a,%edx
mov    $0x6,%ecx
xor    %r8d,%r8d
mov    $0xff,%r9d
movl   $0x10,(%rsp)
call   1040 <parse_octet@plt>
cmp    $0x0,%rax
je     1187 <checketh+0x67>
mov    -0x30(%rbp),%esi
mov    -0x2c(%rbp),%edx
mov    -0x28(%rbp),%ecx
mov    -0x24(%rbp),%r8d
mov    -0x20(%rbp),%r9d
mov    -0x1c(%rbp),%eax
lea    0xe88(%rip),%rdi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1199 <checketh+0x79>
mov    -0x10(%rbp),%rsi
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checketh>:
push   %rbx
sub    $0x30,%rsp
mov    %rdi,%rbx
movl   $0x10,(%rsp)
lea    0x10(%rsp),%rsi
mov    $0x3a,%edx
mov    $0x6,%ecx
xor    %r8d,%r8d
mov    $0xff,%r9d
call   1040 <parse_octet@plt>
test   %rax,%rax
je     117e <checketh+0x5e>
mov    0x10(%rsp),%esi
mov    0x14(%rsp),%edx
mov    0x18(%rsp),%ecx
mov    0x1c(%rsp),%r8d
mov    0x20(%rsp),%r9d
mov    0x24(%rsp),%eax
mov    %eax,(%rsp)
lea    0xe8b(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    118f <checketh+0x6f>
lea    0xe9f(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [36 x i8] c"eth: %02x:%02x:%02x:%02x:%02x:%02x\0A\00"
@.str.1 = [21 x i8] c"eth: '%s' - INVALID\0A\00"
define i32 @checketh(i8* %0) {
%2 = alloca [6 x i32]
%3 = bitcast [6 x i32]* %2 to i8*
%4 = getelementptr inbounds [6 x i32], [6 x i32]* %2, i64 0, i64 0
%5 = call i64 @parse_octet(i8* %0, i32* %4, i8 signext 58, i32 6, i32 0, i32 255, i32 16)
%6 = icmp eq i64 %5, 0
br i1 %6, label %20, label %7
7: ; preds = %1
%8 = load i32, i32* %4
%9 = getelementptr inbounds [6 x i32], [6 x i32]* %2, i64 0, i64 1
%10 = load i32, i32* %9
%11 = getelementptr inbounds [6 x i32], [6 x i32]* %2, i64 0, i64 2
%12 = load i32, i32* %11
%13 = getelementptr inbounds [6 x i32], [6 x i32]* %2, i64 0, i64 3
%14 = load i32, i32* %13
%15 = getelementptr inbounds [6 x i32], [6 x i32]* %2, i64 0, i64 4
%16 = load i32, i32* %15
%17 = getelementptr inbounds [6 x i32], [6 x i32]* %2, i64 0, i64 5
%18 = load i32, i32* %17
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %10, i32 %12, i32 %14, i32 %16, i32 %18)
br label %22
20: ; preds = %1
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %22
22: ; preds = %20, %7
ret i32 undef
}