#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 bpa_alive();
char *config_get(char *);
int eth_alive();
int /*<<< orphan*/ eth_up();
int ppp_alive();
scalar_t__ strcmp(char *, char *);
int Internet_Valid(void) {
  char *proto;
  if (!eth_up())
    return 0;
  proto = config_get("wan_proto");
  if (strcmp(proto, "pppoe") == 0 || strcmp(proto, "pptp") == 0 ||
      strcmp(proto, "l2tp") == 0)
    return ppp_alive();
  if (strcmp(proto, "dhcp") == 0 || strcmp(proto, "static") == 0)
    return eth_alive();
  if (strcmp(proto, "bigpond") == 0)
    return bpa_alive();
  return 0;
}


x86 assembly (clang, -O0):
<Internet_Valid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <eth_up@plt>
cmp    $0x0,%eax
jne    1184 <Internet_Valid+0x24>
movl   $0x0,-0x4(%rbp)
jmp    1264 <Internet_Valid+0x104>
lea    0xe75(%rip),%rdi
call   1050 <config_get@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe6b(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     11e2 <Internet_Valid+0x82>
mov    -0x10(%rbp),%rdi
lea    0xe57(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     11e2 <Internet_Valid+0x82>
mov    -0x10(%rbp),%rdi
lea    0xe42(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    11f1 <Internet_Valid+0x91>
mov    $0x0,%al
call   1080 <ppp_alive@plt>
mov    %eax,-0x4(%rbp)
jmp    1264 <Internet_Valid+0x104>
mov    -0x10(%rbp),%rdi
lea    0xe1e(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     1225 <Internet_Valid+0xc5>
mov    -0x10(%rbp),%rdi
lea    0xe09(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1234 <Internet_Valid+0xd4>
mov    $0x0,%al
call   1040 <eth_alive@plt>
mov    %eax,-0x4(%rbp)
jmp    1264 <Internet_Valid+0x104>
mov    -0x10(%rbp),%rdi
lea    0xde7(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    125d <Internet_Valid+0xfd>
mov    $0x0,%al
call   1070 <bpa_alive@plt>
mov    %eax,-0x4(%rbp)
jmp    1264 <Internet_Valid+0x104>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Internet_Valid>:
push   %rbx
xor    %eax,%eax
call   1030 <eth_up@plt>
test   %eax,%eax
je     11f7 <Internet_Valid+0x97>
lea    0xe89(%rip),%rdi
call   1050 <config_get@plt>
mov    %rax,%rbx
lea    0xe84(%rip),%rsi
mov    %rax,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11fb <Internet_Valid+0x9b>
lea    0xe76(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11fb <Internet_Valid+0x9b>
lea    0xe67(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11fb <Internet_Valid+0x9b>
lea    0xe58(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1203 <Internet_Valid+0xa3>
lea    0xe49(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1203 <Internet_Valid+0xa3>
lea    0xe3c(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     120b <Internet_Valid+0xab>
xor    %eax,%eax
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
jmp    1080 <ppp_alive@plt>
xor    %eax,%eax
pop    %rbx
jmp    1040 <eth_alive@plt>
xor    %eax,%eax
pop    %rbx
jmp    1070 <bpa_alive@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"wan_proto\00"
@.str.1 = [6 x i8] c"pppoe\00"
@.str.2 = [5 x i8] c"pptp\00"
@.str.3 = [5 x i8] c"l2tp\00"
@.str.4 = [5 x i8] c"dhcp\00"
@.str.5 = [7 x i8] c"static\00"
@.str.6 = [8 x i8] c"bigpond\00"
define i32 @Internet_Valid() {
%1 = alloca i32
%2 = alloca i8*
%3 = call i32 (...) @eth_up()
%4 = icmp ne i32 %3, 0
br i1 %4, label %6, label %5
5: ; preds = %0
store i32 0, i32* %1
br label %38
6: ; preds = %0
%7 = call i8* @config_get(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
store i8* %7, i8** %2
%8 = load i8*, i8** %2
%9 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %19, label %11
11: ; preds = %6
%12 = load i8*, i8** %2
%13 = call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %19, label %15
15: ; preds = %11
%16 = load i8*, i8** %2
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %15, %11, %6
%20 = call i32 (...) @ppp_alive()
store i32 %20, i32* %1
br label %38
21: ; preds = %15
%22 = load i8*, i8** %2
%23 = call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %29, label %25
25: ; preds = %21
%26 = load i8*, i8** %2
%27 = call i64 @strcmp(i8* %26, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %25, %21
%30 = call i32 (...) @eth_alive()
store i32 %30, i32* %1
br label %38
31: ; preds = %25
%32 = load i8*, i8** %2
%33 = call i64 @strcmp(i8* %32, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %31
%36 = call i32 (...) @bpa_alive()
store i32 %36, i32* %1
br label %38
37: ; preds = %31
store i32 0, i32* %1
br label %38
38: ; preds = %37, %35, %29, %19, %5
%39 = load i32, i32* %1
ret i32 %39
}

LLVM IR (-O2):
@.str = [10 x i8] c"wan_proto\00"
@.str.1 = [6 x i8] c"pppoe\00"
@.str.2 = [5 x i8] c"pptp\00"
@.str.3 = [5 x i8] c"l2tp\00"
@.str.4 = [5 x i8] c"dhcp\00"
@.str.5 = [7 x i8] c"static\00"
@.str.6 = [8 x i8] c"bigpond\00"
define i32 @Internet_Valid() {
%1 = tail call i32 (...) @eth_up()
%2 = icmp eq i32 %1, 0
br i1 %2, label %28, label %3
3: ; preds = %0
%4 = tail call i8* @config_get(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%5 = tail call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %13, label %7
7: ; preds = %3
%8 = tail call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %7
%11 = tail call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10, %7, %3
%14 = tail call i32 (...) @ppp_alive()
br label %28
15: ; preds = %10
%16 = tail call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %15
%19 = tail call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %18, %15
%22 = tail call i32 (...) @eth_alive()
br label %28
23: ; preds = %18
%24 = tail call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = tail call i32 (...) @bpa_alive()
br label %28
28: ; preds = %23, %0, %26, %21, %13
%29 = phi i32 [ %14, %13 ], [ %22, %21 ], [ %27, %26 ], [ 0, %0 ], [ 0, %23 ]
ret i32 %29
}