#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 /*<<< orphan*/ mib_get(scalar_t__, void *);
int isAccessFromLocal(unsigned int ip) {
  unsigned int uLanIp;
  unsigned int uLanMask;
  char secondIpEn;
  unsigned int uSecondIp;
  unsigned int uSecondMask;
  if (!mib_get(0 + 1, (void *)&uLanIp))
    return -1;
  if (!mib_get(0 + 2, (void *)&uLanMask))
    return -1;
  if ((ip & uLanMask) == (uLanIp & uLanMask)) {
    return 1;
  } else {
    if (!mib_get(0 + 12, (void *)&secondIpEn))
      return -1;
    if (secondIpEn == 1) {
      if (!mib_get(0 + 3, (void *)&uSecondIp))
        return -1;
      if (!mib_get(0 + 4, (void *)&uSecondMask))
        return -1;
      if ((ip & uSecondMask) == (uSecondIp & uSecondMask))
        return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<isAccessFromLocal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
lea    -0xc(%rbp),%rsi
mov    $0x1,%edi
call   1030 <mib_get@plt>
cmp    $0x0,%eax
jne    113e <isAccessFromLocal+0x2e>
movl   $0xffffffff,-0x4(%rbp)
jmp    1228 <isAccessFromLocal+0x118>
lea    -0x10(%rbp),%rsi
mov    $0x2,%edi
call   1030 <mib_get@plt>
cmp    $0x0,%eax
jne    1161 <isAccessFromLocal+0x51>
movl   $0xffffffff,-0x4(%rbp)
jmp    1228 <isAccessFromLocal+0x118>
mov    -0x8(%rbp),%eax
and    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
and    -0x10(%rbp),%ecx
cmp    %ecx,%eax
jne    1181 <isAccessFromLocal+0x71>
movl   $0x1,-0x4(%rbp)
jmp    1228 <isAccessFromLocal+0x118>
mov    $0xc,%edi
lea    -0x11(%rbp),%rsi
call   1030 <mib_get@plt>
cmp    $0x0,%eax
jne    11a4 <isAccessFromLocal+0x94>
movl   $0xffffffff,-0x4(%rbp)
jmp    1228 <isAccessFromLocal+0x118>
movsbl -0x11(%rbp),%eax
cmp    $0x1,%eax
jne    121c <isAccessFromLocal+0x10c>
lea    -0x18(%rbp),%rsi
mov    $0x3,%edi
call   1030 <mib_get@plt>
cmp    $0x0,%eax
jne    11d4 <isAccessFromLocal+0xc4>
movl   $0xffffffff,-0x4(%rbp)
jmp    1228 <isAccessFromLocal+0x118>
lea    -0x1c(%rbp),%rsi
mov    $0x4,%edi
call   1030 <mib_get@plt>
cmp    $0x0,%eax
jne    11f7 <isAccessFromLocal+0xe7>
movl   $0xffffffff,-0x4(%rbp)
jmp    1228 <isAccessFromLocal+0x118>
mov    -0x8(%rbp),%eax
and    -0x1c(%rbp),%eax
mov    -0x18(%rbp),%ecx
and    -0x1c(%rbp),%ecx
cmp    %ecx,%eax
jne    1217 <isAccessFromLocal+0x107>
movl   $0x1,-0x4(%rbp)
jmp    1228 <isAccessFromLocal+0x118>
jmp    121c <isAccessFromLocal+0x10c>
jmp    1221 <isAccessFromLocal+0x111>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isAccessFromLocal>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %edi,%ebp
lea    0x14(%rsp),%rsi
mov    $0x1,%edi
call   1030 <mib_get@plt>
mov    $0xffffffff,%ebx
test   %eax,%eax
je     11a7 <isAccessFromLocal+0x97>
lea    0x10(%rsp),%rsi
mov    $0x2,%edi
call   1030 <mib_get@plt>
test   %eax,%eax
je     11a7 <isAccessFromLocal+0x97>
mov    0x14(%rsp),%eax
xor    %ebp,%eax
test   %eax,0x10(%rsp)
je     11a2 <isAccessFromLocal+0x92>
lea    0x7(%rsp),%rsi
mov    $0xc,%edi
call   1030 <mib_get@plt>
test   %eax,%eax
je     11a7 <isAccessFromLocal+0x97>
cmpb   $0x1,0x7(%rsp)
jne    119e <isAccessFromLocal+0x8e>
lea    0xc(%rsp),%rsi
mov    $0x3,%edi
call   1030 <mib_get@plt>
test   %eax,%eax
je     11a7 <isAccessFromLocal+0x97>
lea    0x8(%rsp),%rsi
mov    $0x4,%edi
call   1030 <mib_get@plt>
test   %eax,%eax
je     11a7 <isAccessFromLocal+0x97>
xor    0xc(%rsp),%ebp
mov    $0x1,%ebx
test   %ebp,0x8(%rsp)
je     11a7 <isAccessFromLocal+0x97>
xor    %ebx,%ebx
jmp    11a7 <isAccessFromLocal+0x97>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @isAccessFromLocal(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %3
%9 = bitcast i32* %4 to i8*
%10 = call i32 @mib_get(i64 1, i8* %9)
%11 = icmp ne i32 %10, 0
br i1 %11, label %13, label %12
12: ; preds = %1
store i32 -1, i32* %2
br label %57
13: ; preds = %1
%14 = bitcast i32* %5 to i8*
%15 = call i32 @mib_get(i64 2, i8* %14)
%16 = icmp ne i32 %15, 0
br i1 %16, label %18, label %17
17: ; preds = %13
store i32 -1, i32* %2
br label %57
18: ; preds = %13
%19 = load i32, i32* %3
%20 = load i32, i32* %5
%21 = and i32 %19, %20
%22 = load i32, i32* %4
%23 = load i32, i32* %5
%24 = and i32 %22, %23
%25 = icmp eq i32 %21, %24
br i1 %25, label %26, label %27
26: ; preds = %18
store i32 1, i32* %2
br label %57
27: ; preds = %18
%28 = call i32 @mib_get(i64 12, i8* %6)
%29 = icmp ne i32 %28, 0
br i1 %29, label %31, label %30
30: ; preds = %27
store i32 -1, i32* %2
br label %57
31: ; preds = %27
%32 = load i8, i8* %6
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 1
br i1 %34, label %35, label %55
35: ; preds = %31
%36 = bitcast i32* %7 to i8*
%37 = call i32 @mib_get(i64 3, i8* %36)
%38 = icmp ne i32 %37, 0
br i1 %38, label %40, label %39
39: ; preds = %35
store i32 -1, i32* %2
br label %57
40: ; preds = %35
%41 = bitcast i32* %8 to i8*
%42 = call i32 @mib_get(i64 4, i8* %41)
%43 = icmp ne i32 %42, 0
br i1 %43, label %45, label %44
44: ; preds = %40
store i32 -1, i32* %2
br label %57
45: ; preds = %40
%46 = load i32, i32* %3
%47 = load i32, i32* %8
%48 = and i32 %46, %47
%49 = load i32, i32* %7
%50 = load i32, i32* %8
%51 = and i32 %49, %50
%52 = icmp eq i32 %48, %51
br i1 %52, label %53, label %54
53: ; preds = %45
store i32 1, i32* %2
br label %57
54: ; preds = %45
br label %55
55: ; preds = %54, %31
br label %56
56: ; preds = %55
store i32 0, i32* %2
br label %57
57: ; preds = %56, %53, %44, %39, %30, %26, %17, %12
%58 = load i32, i32* %2
ret i32 %58
}

LLVM IR (-O2):
define i32 @isAccessFromLocal(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8
%5 = alloca i32
%6 = alloca i32
%7 = bitcast i32* %2 to i8*
%8 = bitcast i32* %3 to i8*
%9 = bitcast i32* %5 to i8*
%10 = bitcast i32* %6 to i8*
%11 = call i32 @mib_get(i64 1, i8* %7)
%12 = icmp eq i32 %11, 0
br i1 %12, label %41, label %13
13: ; preds = %1
%14 = call i32 @mib_get(i64 2, i8* %8)
%15 = icmp eq i32 %14, 0
br i1 %15, label %41, label %16
16: ; preds = %13
%17 = load i32, i32* %3
%18 = load i32, i32* %2
%19 = xor i32 %18, %0
%20 = and i32 %19, %17
%21 = icmp eq i32 %20, 0
br i1 %21, label %41, label %22
22: ; preds = %16
%23 = call i32 @mib_get(i64 12, i8* %4)
%24 = icmp eq i32 %23, 0
br i1 %24, label %41, label %25
25: ; preds = %22
%26 = load i8, i8* %4
%27 = icmp eq i8 %26, 1
br i1 %27, label %28, label %40
28: ; preds = %25
%29 = call i32 @mib_get(i64 3, i8* %9)
%30 = icmp eq i32 %29, 0
br i1 %30, label %41, label %31
31: ; preds = %28
%32 = call i32 @mib_get(i64 4, i8* %10)
%33 = icmp eq i32 %32, 0
br i1 %33, label %41, label %34
34: ; preds = %31
%35 = load i32, i32* %6
%36 = load i32, i32* %5
%37 = xor i32 %36, %0
%38 = and i32 %37, %35
%39 = icmp eq i32 %38, 0
br i1 %39, label %41, label %40
40: ; preds = %25, %34
br label %41
41: ; preds = %34, %31, %28, %22, %16, %13, %1, %40
%42 = phi i32 [ 0, %40 ], [ -1, %1 ], [ -1, %13 ], [ 1, %16 ], [ -1, %22 ], [ -1, %28 ], [ -1, %31 ], [ 1, %34 ]
ret i32 %42
}