#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 AF_INET;
int AF_INET6;
int MAXNAMLEN;
int /*<<< orphan*/ inetDNSResolution(char *);
int /*<<< orphan*/ inetipForwarding(char *, int);
int isValidIpv4Address(char *);
int /*<<< orphan*/ ntkDNSResolution(char *);
int /*<<< orphan*/ ntkipForwarding(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *strstr(char *, char *);
void inet_mode(char *domain) {
  printf("inet_mode: %s\n", domain);
  char *ret;
  char *ret1;
  char new_domain[MAXNAMLEN];
  int rt_value;
  strcpy(new_domain, domain);
  ret = strstr(new_domain, ".ntk");
  if (ret != NULL) {
    printf("inet_mode .ntk\n");
    goto inet_mode_ntk_rslv;
  }
  ret = strstr(new_domain, ".inet");
  ret1 = strstr(new_domain, ".inet");
  if (ret1 != NULL) {
    new_domain[strlen(new_domain) - 5] = '\0';
    printf("inet_mode abbrevate: %s\n", new_domain);
  }
  if (ret == NULL || ret1 != NULL) {
    rt_value = isValidIpv4Address(new_domain);
    if (rt_value == AF_INET)
      inetipForwarding(new_domain, AF_INET);
    if (rt_value == AF_INET6)
      inetipForwarding(new_domain, AF_INET6);
    if (rt_value == 0)
      inetDNSResolution(new_domain);
    printf("inet_mode normal\n");
    return;
  }
  ret = strstr(new_domain, ".ntk");
  if (ret != NULL) {
  inet_mode_ntk_rslv:
    new_domain[strlen(new_domain) - 4] = '\0';
    rt_value = isValidIpv4Address(new_domain);
    if (rt_value == AF_INET)
      ntkipForwarding(new_domain, AF_INET);
    if (rt_value == AF_INET6)
      ntkipForwarding(new_domain, AF_INET6);
    if (rt_value == 0)
      ntkDNSResolution(new_domain);
    printf("inet_mode abnormal\n");
    return;
  }
  return;
}


x86 assembly (clang, -O0):
<inet_mode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe59(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2e1b(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x38(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x38(%rbp),%rdi
lea    0xe21(%rip),%rsi
call   10b0 <strstr@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1215 <inet_mode+0x85>
lea    0xe0b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1327 <inet_mode+0x197>
mov    -0x38(%rbp),%rdi
lea    0xe04(%rip),%rsi
call   10b0 <strstr@plt>
mov    -0x38(%rbp),%rdi
mov    %rax,-0x10(%rbp)
lea    0xdf0(%rip),%rsi
call   10b0 <strstr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     126c <inet_mode+0xdc>
mov    -0x38(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x38(%rbp),%rsi
sub    $0x5,%eax
cltq
movb   $0x0,(%rsi,%rax,1)
lea    0xdc5(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
cmpq   $0x0,-0x10(%rbp)
je     1282 <inet_mode+0xf2>
cmpq   $0x0,-0x18(%rbp)
je     1303 <inet_mode+0x173>
mov    -0x38(%rbp),%rdi
call   1080 <isValidIpv4Address@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    0x2d50(%rip),%rcx
cmp    (%rcx),%eax
jne    12b2 <inet_mode+0x122>
mov    -0x38(%rbp),%rdi
mov    0x2d3d(%rip),%rax
mov    (%rax),%esi
call   1090 <inetipForwarding@plt>
mov    -0x2c(%rbp),%eax
mov    0x2d24(%rip),%rcx
cmp    (%rcx),%eax
jne    12d6 <inet_mode+0x146>
mov    -0x38(%rbp),%rdi
mov    0x2d11(%rip),%rax
mov    (%rax),%esi
call   1090 <inetipForwarding@plt>
cmpl   $0x0,-0x2c(%rbp)
jne    12e9 <inet_mode+0x159>
mov    -0x38(%rbp),%rdi
call   1070 <inetDNSResolution@plt>
lea    0xd53(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x30(%rbp)
jmp    13c1 <inet_mode+0x231>
mov    -0x38(%rbp),%rdi
lea    0xd01(%rip),%rsi
call   10b0 <strstr@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     13ba <inet_mode+0x22a>
jmp    1327 <inet_mode+0x197>
mov    -0x38(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x38(%rbp),%rdi
sub    $0x4,%eax
cltq
movb   $0x0,(%rdi,%rax,1)
call   1080 <isValidIpv4Address@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    0x2c99(%rip),%rcx
cmp    (%rcx),%eax
jne    1369 <inet_mode+0x1d9>
mov    -0x38(%rbp),%rdi
mov    0x2c86(%rip),%rax
mov    (%rax),%esi
call   1050 <ntkipForwarding@plt>
mov    -0x2c(%rbp),%eax
mov    0x2c6d(%rip),%rcx
cmp    (%rcx),%eax
jne    138d <inet_mode+0x1fd>
mov    -0x38(%rbp),%rdi
mov    0x2c5a(%rip),%rax
mov    (%rax),%esi
call   1050 <ntkipForwarding@plt>
cmpl   $0x0,-0x2c(%rbp)
jne    13a0 <inet_mode+0x210>
mov    -0x38(%rbp),%rdi
call   10a0 <ntkDNSResolution@plt>
lea    0xcae(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x30(%rbp)
jmp    13c1 <inet_mode+0x231>
movl   $0x1,-0x30(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inet_mode>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xe4c(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x2e0b(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
lea    0xe72(%rip),%rsi
mov    %rbx,%rdi
call   10c0 <strstr@plt>
test   %rax,%rax
je     1268 <inet_mode+0xc8>
lea    0xe54(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
movb   $0x0,-0x4(%rax,%rbx,1)
mov    %rbx,%rdi
call   1090 <isValidIpv4Address@plt>
mov    %eax,%r15d
mov    0x2dc4(%rip),%rax
cmp    (%rax),%r15d
jne    1234 <inet_mode+0x94>
mov    %rbx,%rdi
mov    %r15d,%esi
call   1060 <ntkipForwarding@plt>
mov    0x2da5(%rip),%rax
cmp    (%rax),%r15d
jne    124b <inet_mode+0xab>
mov    %rbx,%rdi
mov    %r15d,%esi
call   1060 <ntkipForwarding@plt>
lea    0xddc(%rip),%r14
test   %r15d,%r15d
jne    12e9 <inet_mode+0x149>
mov    %rbx,%rdi
call   10b0 <ntkDNSResolution@plt>
jmp    12e9 <inet_mode+0x149>
lea    0xda0(%rip),%rsi
mov    %rbx,%rdi
call   10c0 <strstr@plt>
test   %rax,%rax
je     129c <inet_mode+0xfc>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
movb   $0x0,-0x5(%rax,%rbx,1)
lea    0xd83(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
call   1090 <isValidIpv4Address@plt>
mov    %eax,%r15d
mov    0x2d3a(%rip),%rax
cmp    (%rax),%r15d
jne    12be <inet_mode+0x11e>
mov    %rbx,%rdi
mov    %r15d,%esi
call   10a0 <inetipForwarding@plt>
mov    0x2d1b(%rip),%rax
cmp    (%rax),%r15d
jne    12d5 <inet_mode+0x135>
mov    %rbx,%rdi
mov    %r15d,%esi
call   10a0 <inetipForwarding@plt>
lea    0xd65(%rip),%r14
test   %r15d,%r15d
jne    12e9 <inet_mode+0x149>
mov    %rbx,%rdi
call   1080 <inetDNSResolution@plt>
mov    %r14,%rdi
call   1040 <puts@plt>
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"inet_mode: %s\0A\00"
@MAXNAMLEN = global i32 0
@.str.1 = [5 x i8] c".ntk\00"
@.str.2 = [16 x i8] c"inet_mode .ntk\0A\00"
@.str.3 = [6 x i8] c".inet\00"
@.str.4 = [25 x i8] c"inet_mode abbrevate: %s\0A\00"
@AF_INET = global i32 0
@AF_INET6 = global i32 0
@.str.5 = [18 x i8] c"inet_mode normal\0A\00"
@.str.6 = [20 x i8] c"inet_mode abnormal\0A\00"
define void @inet_mode(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %2
%9 = load i8*, i8** %2
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = load i32, i32* @MAXNAMLEN
%12 = zext i32 %11 to i64
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %5
%14 = alloca i8, i64 %12
store i64 %12, i64* %6
%15 = load i8*, i8** %2
%16 = call i32 @strcpy(i8* %14, i8* %15)
%17 = call i8* @strstr(i8* %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i8* %17, i8** %3
%18 = load i8*, i8** %3
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %22
20: ; preds = %1
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %66
22: ; preds = %1
%23 = call i8* @strstr(i8* %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
store i8* %23, i8** %3
%24 = call i8* @strstr(i8* %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
store i8* %24, i8** %4
%25 = load i8*, i8** %4
%26 = icmp ne i8* %25, null
br i1 %26, label %27, label %33
27: ; preds = %22
%28 = call i32 @strlen(i8* %14)
%29 = sub nsw i32 %28, 5
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %14, i64 %30
store i8 0, i8* %31
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8* %14)
br label %33
33: ; preds = %27, %22
%34 = load i8*, i8** %3
%35 = icmp eq i8* %34, null
br i1 %35, label %39, label %36
36: ; preds = %33
%37 = load i8*, i8** %4
%38 = icmp ne i8* %37, null
br i1 %38, label %39, label %61
39: ; preds = %36, %33
%40 = call i32 @isValidIpv4Address(i8* %14)
store i32 %40, i32* %7
%41 = load i32, i32* %7
%42 = load i32, i32* @AF_INET
%43 = icmp eq i32 %41, %42
br i1 %43, label %44, label %47
44: ; preds = %39
%45 = load i32, i32* @AF_INET
%46 = call i32 @inetipForwarding(i8* %14, i32 %45)
br label %47
47: ; preds = %44, %39
%48 = load i32, i32* %7
%49 = load i32, i32* @AF_INET6
%50 = icmp eq i32 %48, %49
br i1 %50, label %51, label %54
51: ; preds = %47
%52 = load i32, i32* @AF_INET6
%53 = call i32 @inetipForwarding(i8* %14, i32 %52)
br label %54
54: ; preds = %51, %47
%55 = load i32, i32* %7
%56 = icmp eq i32 %55, 0
br i1 %56, label %57, label %59
57: ; preds = %54
%58 = call i32 @inetDNSResolution(i8* %14)
br label %59
59: ; preds = %57, %54
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %8
br label %93
61: ; preds = %36
%62 = call i8* @strstr(i8* %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i8* %62, i8** %3
%63 = load i8*, i8** %3
%64 = icmp ne i8* %63, null
br i1 %64, label %65, label %92
65: ; preds = %61
br label %66
66: ; preds = %65, %20
%67 = call i32 @strlen(i8* %14)
%68 = sub nsw i32 %67, 4
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i8, i8* %14, i64 %69
store i8 0, i8* %70
%71 = call i32 @isValidIpv4Address(i8* %14)
store i32 %71, i32* %7
%72 = load i32, i32* %7
%73 = load i32, i32* @AF_INET
%74 = icmp eq i32 %72, %73
br i1 %74, label %75, label %78
75: ; preds = %66
%76 = load i32, i32* @AF_INET
%77 = call i32 @ntkipForwarding(i8* %14, i32 %76)
br label %78
78: ; preds = %75, %66
%79 = load i32, i32* %7
%80 = load i32, i32* @AF_INET6
%81 = icmp eq i32 %79, %80
br i1 %81, label %82, label %85
82: ; preds = %78
%83 = load i32, i32* @AF_INET6
%84 = call i32 @ntkipForwarding(i8* %14, i32 %83)
br label %85
85: ; preds = %82, %78
%86 = load i32, i32* %7
%87 = icmp eq i32 %86, 0
br i1 %87, label %88, label %90
88: ; preds = %85
%89 = call i32 @ntkDNSResolution(i8* %14)
br label %90
90: ; preds = %88, %85
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %8
br label %93
92: ; preds = %61
store i32 1, i32* %8
br label %93
93: ; preds = %92, %90, %59
%94 = load i8*, i8** %5
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"inet_mode: %s\0A\00"
@MAXNAMLEN = global i32 0
@.str.1 = [5 x i8] c".ntk\00"
@.str.3 = [6 x i8] c".inet\00"
@.str.4 = [25 x i8] c"inet_mode abbrevate: %s\0A\00"
@AF_INET = global i32 0
@AF_INET6 = global i32 0
@str = [19 x i8] c"inet_mode abnormal\00"
@str.7 = [17 x i8] c"inet_mode normal\00"
@str.8 = [15 x i8] c"inet_mode .ntk\00"
define void @inet_mode(i8* %0) {
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %0)
%3 = load i32, i32* @MAXNAMLEN
%4 = zext i32 %3 to i64
%5 = alloca i8, i64 %4
%6 = call i32 @strcpy(i8* %5, i8* %0)
%7 = call i8* @strstr(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i8* %7, null
br i1 %8, label %18, label %9
9: ; preds = %1
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.8, i64 0, i64 0))
%11 = call i32 @strlen(i8* %5)
%12 = add nsw i32 %11, -4
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %5, i64 %13
store i8 0, i8* %14
%15 = call i32 @isValidIpv4Address(i8* %5)
%16 = load i32, i32* @AF_INET
%17 = icmp eq i32 %15, %16
br i1 %17, label %42, label %44
18: ; preds = %1
%19 = call i8* @strstr(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%20 = icmp eq i8* %19, null
br i1 %20, label %27, label %21
21: ; preds = %18
%22 = call i32 @strlen(i8* %5)
%23 = add nsw i32 %22, -5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %5, i64 %24
store i8 0, i8* %25
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8* %5)
br label %27
27: ; preds = %18, %21
%28 = call i32 @isValidIpv4Address(i8* %5)
%29 = load i32, i32* @AF_INET
%30 = icmp eq i32 %28, %29
br i1 %30, label %31, label %33
31: ; preds = %27
%32 = call i32 @inetipForwarding(i8* %5, i32 %28)
br label %33
33: ; preds = %31, %27
%34 = load i32, i32* @AF_INET6
%35 = icmp eq i32 %28, %34
br i1 %35, label %36, label %38
36: ; preds = %33
%37 = call i32 @inetipForwarding(i8* %5, i32 %28)
br label %38
38: ; preds = %36, %33
%39 = icmp eq i32 %28, 0
br i1 %39, label %40, label %53
40: ; preds = %38
%41 = call i32 @inetDNSResolution(i8* %5)
br label %53
42: ; preds = %9
%43 = call i32 @ntkipForwarding(i8* %5, i32 %15)
br label %44
44: ; preds = %42, %9
%45 = load i32, i32* @AF_INET6
%46 = icmp eq i32 %15, %45
br i1 %46, label %47, label %49
47: ; preds = %44
%48 = call i32 @ntkipForwarding(i8* %5, i32 %15)
br label %49
49: ; preds = %47, %44
%50 = icmp eq i32 %15, 0
br i1 %50, label %51, label %53
51: ; preds = %49
%52 = call i32 @ntkDNSResolution(i8* %5)
br label %53
53: ; preds = %49, %51, %38, %40
%54 = phi i8* [ getelementptr inbounds ([17 x i8], [17 x i8]* @str.7, i64 0, i64 0), %40 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @str.7, i64 0, i64 0), %38 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0), %51 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0), %49 ]
%55 = call i32 @puts(i8* dereferenceable(1) %54)
ret void
}