#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 ntk_mode(char *domain) {
  printf("ntk_mode: %s\n", domain);
  char *ret;
  char *ret1;
  char new_domain[MAXNAMLEN];
  int rt_value;
  strcpy(new_domain, domain);
  ret = strstr(new_domain, ".inet");
  if (ret != NULL) {
    printf("ntk_mode .inet\n");
    goto ntk_mode_inet_rslv;
  }
  ret = strstr(new_domain, ".ntk");
  ret1 = strstr(new_domain, ".ntk");
  if (ret1 != NULL) {
    new_domain[strlen(new_domain) - 4] = '\0';
    printf("ntk_mode abbrevate: %s\n", new_domain);
  }
  if (ret == NULL || ret1 != NULL) {
    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("ntk_mode normal\n");
  }
  ret = strstr(new_domain, ".inet");
  if (ret != NULL) {
  ntk_mode_inet_rslv:
    new_domain[strlen(new_domain) - 5] = '\0';
    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("ntk_mode abnormal\n");
  }
}


x86 assembly (clang, -O0):
<ntk_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    0xe20(%rip),%rsi
call   10b0 <strstr@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1215 <ntk_mode+0x85>
lea    0xe0b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    131b <ntk_mode+0x18b>
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 <ntk_mode+0xdc>
mov    -0x38(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x38(%rbp),%rsi
sub    $0x4,%eax
cltq
movb   $0x0,(%rsi,%rax,1)
lea    0xdc4(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
cmpq   $0x0,-0x10(%rbp)
je     1282 <ntk_mode+0xf2>
cmpq   $0x0,-0x18(%rbp)
je     12f7 <ntk_mode+0x167>
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 <ntk_mode+0x122>
mov    -0x38(%rbp),%rdi
mov    0x2d3d(%rip),%rax
mov    (%rax),%esi
call   1050 <ntkipForwarding@plt>
mov    -0x2c(%rbp),%eax
mov    0x2d24(%rip),%rcx
cmp    (%rcx),%eax
jne    12d6 <ntk_mode+0x146>
mov    -0x38(%rbp),%rdi
mov    0x2d11(%rip),%rax
mov    (%rax),%esi
call   1050 <ntkipForwarding@plt>
cmpl   $0x0,-0x2c(%rbp)
jne    12e9 <ntk_mode+0x159>
mov    -0x38(%rbp),%rdi
call   10a0 <ntkDNSResolution@plt>
lea    0xd51(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x38(%rbp),%rdi
lea    0xd0c(%rip),%rsi
call   10b0 <strstr@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     13a2 <ntk_mode+0x212>
jmp    131b <ntk_mode+0x18b>
mov    -0x38(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x38(%rbp),%rdi
sub    $0x5,%eax
cltq
movb   $0x0,(%rdi,%rax,1)
call   1080 <isValidIpv4Address@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    0x2ca5(%rip),%rcx
cmp    (%rcx),%eax
jne    135d <ntk_mode+0x1cd>
mov    -0x38(%rbp),%rdi
mov    0x2c92(%rip),%rax
mov    (%rax),%esi
call   1090 <inetipForwarding@plt>
mov    -0x2c(%rbp),%eax
mov    0x2c79(%rip),%rcx
cmp    (%rcx),%eax
jne    1381 <ntk_mode+0x1f1>
mov    -0x38(%rbp),%rdi
mov    0x2c66(%rip),%rax
mov    (%rax),%esi
call   1090 <inetipForwarding@plt>
cmpl   $0x0,-0x2c(%rbp)
jne    1394 <ntk_mode+0x204>
mov    -0x38(%rbp),%rdi
call   1070 <inetDNSResolution@plt>
lea    0xcb7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ntk_mode>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xe4c(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x2e0b(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%r15
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
lea    0xe6c(%rip),%rsi
mov    %r15,%rdi
call   10c0 <strstr@plt>
test   %rax,%rax
je     1208 <ntk_mode+0x68>
lea    0xe4f(%rip),%rdi
call   1040 <puts@plt>
jmp    12a3 <ntk_mode+0x103>
lea    0xdff(%rip),%rsi
mov    %r15,%rdi
call   10c0 <strstr@plt>
test   %rax,%rax
je     123d <ntk_mode+0x9d>
mov    %r15,%rdi
call   1050 <strlen@plt>
cltq
movb   $0x0,-0x4(%rax,%r15,1)
lea    0xde0(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r15,%rdi
call   1090 <isValidIpv4Address@plt>
mov    %eax,%r14d
mov    0x2d99(%rip),%rax
cmp    (%rax),%r14d
jne    125f <ntk_mode+0xbf>
mov    %r15,%rdi
mov    %r14d,%esi
call   1060 <ntkipForwarding@plt>
mov    0x2d7a(%rip),%rax
cmp    (%rax),%r14d
jne    1276 <ntk_mode+0xd6>
mov    %r15,%rdi
mov    %r14d,%esi
call   1060 <ntkipForwarding@plt>
test   %r14d,%r14d
jne    1283 <ntk_mode+0xe3>
mov    %r15,%rdi
call   10b0 <ntkDNSResolution@plt>
lea    0xdb3(%rip),%rdi
call   1040 <puts@plt>
lea    0xdc0(%rip),%rsi
mov    %r15,%rdi
call   10c0 <strstr@plt>
test   %rax,%rax
je     12ff <ntk_mode+0x15f>
mov    %r15,%rdi
call   1050 <strlen@plt>
cltq
movb   $0x0,-0x5(%rax,%r15,1)
mov    %r15,%rdi
call   1090 <isValidIpv4Address@plt>
mov    %eax,%ebx
mov    0x2d24(%rip),%rax
cmp    (%rax),%ebx
jne    12d2 <ntk_mode+0x132>
mov    %r15,%rdi
mov    %ebx,%esi
call   10a0 <inetipForwarding@plt>
mov    0x2d07(%rip),%rax
cmp    (%rax),%ebx
jne    12e7 <ntk_mode+0x147>
mov    %r15,%rdi
mov    %ebx,%esi
call   10a0 <inetipForwarding@plt>
test   %ebx,%ebx
jne    12f3 <ntk_mode+0x153>
mov    %r15,%rdi
call   1080 <inetDNSResolution@plt>
lea    0xd31(%rip),%rdi
call   1040 <puts@plt>
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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