#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 */
unsigned int IFF_LOOPBACK;
unsigned int IFF_NOARP;
unsigned int IFF_UP;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, char const *);
int check_ifflags(unsigned int ifflags, int fatal, const char *devname) {
  if (!(ifflags & IFF_UP)) {
    if (fatal) {
      printf("Interface \"%s\" is down\n", devname);
      exit(2);
    }
    return -1;
  }
  if (ifflags & (IFF_NOARP | IFF_LOOPBACK)) {
    if (fatal) {
      printf("Interface \"%s\" is not ARPable\n", devname);
      exit(2);
    }
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<check_ifflags>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    0x2e9c(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jne    1177 <check_ifflags+0x57>
cmpl   $0x0,-0xc(%rbp)
je     116b <check_ifflags+0x4b>
mov    -0x18(%rbp),%rsi
lea    0xea4(%rip),%rdi
call   1030 <printf@plt>
mov    $0x2,%edi
call   1040 <exit@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ce <check_ifflags+0xae>
mov    -0x8(%rbp),%eax
mov    0x2e5f(%rip),%rcx
mov    (%rcx),%ecx
mov    0x2e6e(%rip),%rdx
or     (%rdx),%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     11c7 <check_ifflags+0xa7>
cmpl   $0x0,-0xc(%rbp)
je     11bb <check_ifflags+0x9b>
mov    -0x18(%rbp),%rsi
lea    0xe6c(%rip),%rdi
call   1030 <printf@plt>
mov    $0x2,%edi
call   1040 <exit@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ce <check_ifflags+0xae>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_ifflags>:
push   %rax
mov    0x2eb0(%rip),%rax
test   %edi,(%rax)
je     114d <check_ifflags+0x2d>
mov    0x2ead(%rip),%rax
mov    0x2ebe(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
test   %edi,%ecx
je     115f <check_ifflags+0x3f>
mov    $0xffffffff,%eax
test   %esi,%esi
jne    1163 <check_ifflags+0x43>
pop    %rcx
ret
mov    $0xffffffff,%eax
test   %esi,%esi
je     114b <check_ifflags+0x2b>
lea    0xea3(%rip),%rdi
jmp    116a <check_ifflags+0x4a>
xor    %eax,%eax
pop    %rcx
ret
lea    0xeae(%rip),%rdi
mov    %rdx,%rsi
call   1030 <printf@plt>
mov    $0x2,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@IFF_UP = global i32 0
@.str = [24 x i8] c"Interface \22%s\22 is down\0A\00"
@IFF_NOARP = global i32 0
@IFF_LOOPBACK = global i32 0
@.str.1 = [31 x i8] c"Interface \22%s\22 is not ARPable\0A\00"
define i32 @check_ifflags(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
store i32 %0, i32* %5
store i32 %1, i32* %6
store i8* %2, i8** %7
%8 = load i32, i32* %5
%9 = load i32, i32* @IFF_UP
%10 = and i32 %8, %9
%11 = icmp ne i32 %10, 0
br i1 %11, label %20, label %12
12: ; preds = %3
%13 = load i32, i32* %6
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %12
%16 = load i8*, i8** %7
%17 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = call i32 @exit(i32 2)
unreachable
19: ; preds = %12
store i32 -1, i32* %4
br label %36
20: ; preds = %3
%21 = load i32, i32* %5
%22 = load i32, i32* @IFF_NOARP
%23 = load i32, i32* @IFF_LOOPBACK
%24 = or i32 %22, %23
%25 = and i32 %21, %24
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %35
27: ; preds = %20
%28 = load i32, i32* %6
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %34
30: ; preds = %27
%31 = load i8*, i8** %7
%32 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %31)
%33 = call i32 @exit(i32 2)
unreachable
34: ; preds = %27
store i32 -1, i32* %4
br label %36
35: ; preds = %20
store i32 0, i32* %4
br label %36
36: ; preds = %35, %34, %19
%37 = load i32, i32* %4
ret i32 %37
}

LLVM IR (-O2):
@IFF_UP = global i32 0
@.str = [24 x i8] c"Interface \22%s\22 is down\0A\00"
@IFF_NOARP = global i32 0
@IFF_LOOPBACK = global i32 0
@.str.1 = [31 x i8] c"Interface \22%s\22 is not ARPable\0A\00"
define i32 @check_ifflags(i32 %0, i32 %1, i8* %2) {
%4 = load i32, i32* @IFF_UP
%5 = and i32 %4, %0
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %12
7: ; preds = %3
%8 = icmp eq i32 %1, 0
br i1 %8, label %23, label %9
9: ; preds = %7
%10 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %2)
%11 = tail call i32 @exit(i32 2)
unreachable
12: ; preds = %3
%13 = load i32, i32* @IFF_NOARP
%14 = load i32, i32* @IFF_LOOPBACK
%15 = or i32 %14, %13
%16 = and i32 %15, %0
%17 = icmp eq i32 %16, 0
br i1 %17, label %23, label %18
18: ; preds = %12
%19 = icmp eq i32 %1, 0
br i1 %19, label %23, label %20
20: ; preds = %18
%21 = tail call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%22 = tail call i32 @exit(i32 2)
unreachable
23: ; preds = %12, %18, %7
%24 = phi i32 [ -1, %7 ], [ -1, %18 ], [ 0, %12 ]
ret i32 %24
}