#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__ isip4(char const *);
scalar_t__ ismac(char const *);
int /*<<< orphan*/ parseip4(char const *);
int /*<<< orphan*/ parseip6(char const *);
int /*<<< orphan*/ parsemac(char const *);
scalar_t__ strncmp(char *, char const *, int);
void parseaddr(const char *a) {
  if (*a == 0)
    return;
  if (strncmp("mac:", a, 4) == 0) {
    parsemac(a + 4);
    return;
  }
  if (strncmp("ip4:", a, 4) == 0) {
    parseip4(a + 4);
    return;
  }
  if (strncmp("ip6:", a, 4) == 0) {
    parseip6(a + 4);
    return;
  }
  if (isip4(a)) {
    parseip4(a);
    return;
  }
  if (ismac(a)) {
    parsemac(a);
    return;
  }
  parseip6(a);
}


x86 assembly (clang, -O0):
<parseaddr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1181 <parseaddr+0x21>
jmp    125f <parseaddr+0xff>
mov    -0x8(%rbp),%rsi
lea    0xe74(%rip),%rdi
mov    $0x4,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    11b2 <parseaddr+0x52>
mov    -0x8(%rbp),%rdi
add    $0x4,%rdi
call   1060 <parsemac@plt>
jmp    125f <parseaddr+0xff>
mov    -0x8(%rbp),%rsi
lea    0xe48(%rip),%rdi
mov    $0x4,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    11e3 <parseaddr+0x83>
mov    -0x8(%rbp),%rdi
add    $0x4,%rdi
call   1070 <parseip4@plt>
jmp    125f <parseaddr+0xff>
mov    -0x8(%rbp),%rsi
lea    0xe1c(%rip),%rdi
mov    $0x4,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    1214 <parseaddr+0xb4>
mov    -0x8(%rbp),%rdi
add    $0x4,%rdi
call   1080 <parseip6@plt>
jmp    125f <parseaddr+0xff>
mov    -0x8(%rbp),%rdi
call   1050 <isip4@plt>
cmp    $0x0,%rax
je     1235 <parseaddr+0xd5>
mov    -0x8(%rbp),%rdi
call   1070 <parseip4@plt>
jmp    125f <parseaddr+0xff>
mov    -0x8(%rbp),%rdi
call   1030 <ismac@plt>
cmp    $0x0,%rax
je     1256 <parseaddr+0xf6>
mov    -0x8(%rbp),%rdi
call   1060 <parsemac@plt>
jmp    125f <parseaddr+0xff>
mov    -0x8(%rbp),%rdi
call   1080 <parseip6@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseaddr>:
push   %rbx
cmpb   $0x0,(%rdi)
je     11d0 <parseaddr+0x70>
mov    %rdi,%rbx
lea    0xe90(%rip),%rdi
mov    %rbx,%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     11d2 <parseaddr+0x72>
lea    0xe7c(%rip),%rdi
mov    %rbx,%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     11df <parseaddr+0x7f>
lea    0xe68(%rip),%rdi
mov    %rbx,%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     11ec <parseaddr+0x8c>
mov    %rbx,%rdi
call   1050 <isip4@plt>
test   %rax,%rax
jne    11e3 <parseaddr+0x83>
mov    %rbx,%rdi
call   1030 <ismac@plt>
test   %rax,%rax
jne    11d6 <parseaddr+0x76>
jmp    11f0 <parseaddr+0x90>
pop    %rbx
ret
add    $0x4,%rbx
mov    %rbx,%rdi
pop    %rbx
jmp    1060 <parsemac@plt>
add    $0x4,%rbx
mov    %rbx,%rdi
pop    %rbx
jmp    1070 <parseip4@plt>
add    $0x4,%rbx
mov    %rbx,%rdi
pop    %rbx
jmp    1080 <parseip6@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"mac:\00"
@.str.1 = [5 x i8] c"ip4:\00"
@.str.2 = [5 x i8] c"ip6:\00"
define void @parseaddr(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = load i8, i8* %3
%5 = sext i8 %4 to i32
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %1
br label %49
8: ; preds = %1
%9 = load i8*, i8** %2
%10 = call i64 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %9, i32 4)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %8
%13 = load i8*, i8** %2
%14 = getelementptr inbounds i8, i8* %13, i64 4
%15 = call i32 @parsemac(i8* %14)
br label %49
16: ; preds = %8
%17 = load i8*, i8** %2
%18 = call i64 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %17, i32 4)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %16
%21 = load i8*, i8** %2
%22 = getelementptr inbounds i8, i8* %21, i64 4
%23 = call i32 @parseip4(i8* %22)
br label %49
24: ; preds = %16
%25 = load i8*, i8** %2
%26 = call i64 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %25, i32 4)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %32
28: ; preds = %24
%29 = load i8*, i8** %2
%30 = getelementptr inbounds i8, i8* %29, i64 4
%31 = call i32 @parseip6(i8* %30)
br label %49
32: ; preds = %24
%33 = load i8*, i8** %2
%34 = call i64 @isip4(i8* %33)
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %32
%37 = load i8*, i8** %2
%38 = call i32 @parseip4(i8* %37)
br label %49
39: ; preds = %32
%40 = load i8*, i8** %2
%41 = call i64 @ismac(i8* %40)
%42 = icmp ne i64 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %39
%44 = load i8*, i8** %2
%45 = call i32 @parsemac(i8* %44)
br label %49
46: ; preds = %39
%47 = load i8*, i8** %2
%48 = call i32 @parseip6(i8* %47)
br label %49
49: ; preds = %46, %43, %36, %28, %20, %12, %7
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"mac:\00"
@.str.1 = [5 x i8] c"ip4:\00"
@.str.2 = [5 x i8] c"ip6:\00"
define void @parseaddr(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %34, label %4
4: ; preds = %1
%5 = tail call i64 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %0, i32 4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %4
%8 = getelementptr inbounds i8, i8* %0, i64 4
%9 = tail call i32 @parsemac(i8* %8)
br label %34
10: ; preds = %4
%11 = tail call i64 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 4)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = getelementptr inbounds i8, i8* %0, i64 4
%15 = tail call i32 @parseip4(i8* %14)
br label %34
16: ; preds = %10
%17 = tail call i64 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %0, i32 4)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = getelementptr inbounds i8, i8* %0, i64 4
%21 = tail call i32 @parseip6(i8* %20)
br label %34
22: ; preds = %16
%23 = tail call i64 @isip4(i8* %0)
%24 = icmp eq i64 %23, 0
br i1 %24, label %27, label %25
25: ; preds = %22
%26 = tail call i32 @parseip4(i8* %0)
br label %34
27: ; preds = %22
%28 = tail call i64 @ismac(i8* %0)
%29 = icmp eq i64 %28, 0
br i1 %29, label %32, label %30
30: ; preds = %27
%31 = tail call i32 @parsemac(i8* %0)
br label %34
32: ; preds = %27
%33 = tail call i32 @parseip6(i8* %0)
br label %34
34: ; preds = %1, %32, %30, %25, %19, %13, %7
ret void
}