#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int sql_data();
int /*<<< orphan*/ system(char *);
scalar_t__ wan_monitor();
int main() {
  printf("\n------------------------------\n");
  printf("wan_start : start!\n");
  printf("-------------------------------\n");
  int sh;
  char sh_path[256] = {0};
  if (wan_monitor() == 0) {
    printf("wan : started!\n");
    exit(0);
  }
  sh = sql_data();
  if (sh == 0) {
    printf("no wan needed!");
    exit(0);
  }
  if (sh == 1) {
    printf("3G module : LC5730\n");
    printf("pppd call gprs-connect\n");
    system("pppd call gprs-connect &");
  }
  if (sh == 2) {
    printf("3G module : MC2716\n");
    printf("pppd call evdo-connect\n");
    system("pppd call evdo-connect &");
  }
  if (sh == 3) {
    printf("3G module : MF210\n");
    printf("pppd call wcdma-connect\n");
    system("pppd call wcdma-connect &");
  }
  if (sh == 4) {
    printf("3G module : LS6300v\n");
    printf("pppd call wcdma-ls-connect\n");
    system("pppd call wcdma-ls-connect &");
  }
  if (sh == 10)
    printf("usb/wifi module\n");
  if (sh == 20)
    printf("usb/ethernet module\n");
  printf("wan_start : complete!\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe87(%rip),%rdi
call   1040 <printf@plt>
lea    0xe9c(%rip),%rdi
call   1040 <printf@plt>
lea    0xea4(%rip),%rdi
call   1040 <printf@plt>
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1060 <memset@plt>
mov    $0x0,%al
call   1050 <wan_monitor@plt>
cmp    $0x0,%rax
jne    11cd <main+0x6d>
lea    0xe95(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
mov    $0x0,%al
call   1080 <sql_data@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    11f4 <main+0x94>
lea    0xe7e(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
cmpl   $0x1,-0x8(%rbp)
jne    1222 <main+0xc2>
lea    0xe70(%rip),%rdi
call   1040 <printf@plt>
lea    0xe78(%rip),%rdi
call   1040 <printf@plt>
lea    0xe84(%rip),%rdi
call   1030 <system@plt>
cmpl   $0x2,-0x8(%rbp)
jne    1250 <main+0xf0>
lea    0xe87(%rip),%rdi
call   1040 <printf@plt>
lea    0xe8f(%rip),%rdi
call   1040 <printf@plt>
lea    0xe9b(%rip),%rdi
call   1030 <system@plt>
cmpl   $0x3,-0x8(%rbp)
jne    127e <main+0x11e>
lea    0xe9e(%rip),%rdi
call   1040 <printf@plt>
lea    0xea5(%rip),%rdi
call   1040 <printf@plt>
lea    0xeb2(%rip),%rdi
call   1030 <system@plt>
cmpl   $0x4,-0x8(%rbp)
jne    12ac <main+0x14c>
lea    0xeb6(%rip),%rdi
call   1040 <printf@plt>
lea    0xebf(%rip),%rdi
call   1040 <printf@plt>
lea    0xecf(%rip),%rdi
call   1030 <system@plt>
cmpl   $0xa,-0x8(%rbp)
jne    12c2 <main+0x162>
lea    0xed6(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0x14,-0x8(%rbp)
jne    12d8 <main+0x178>
lea    0xed1(%rip),%rdi
call   1040 <printf@plt>
lea    0xeda(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xf64(%rip),%rdi
call   1030 <puts@plt>
lea    0xf78(%rip),%rdi
call   1030 <puts@plt>
lea    0xf7f(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1060 <wan_monitor@plt>
test   %rax,%rax
je     1277 <main+0x117>
xor    %eax,%eax
call   1080 <sql_data@plt>
cmp    $0x14,%eax
ja     1267 <main+0x107>
mov    %eax,%eax
lea    0xe52(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0x101e(%rip),%rdi
call   1030 <puts@plt>
lea    0x1025(%rip),%rdi
call   1030 <puts@plt>
lea    0xe8d(%rip),%rdi
call   1040 <system@plt>
jmp    1267 <main+0x107>
lea    0xfcb(%rip),%rdi
call   1030 <puts@plt>
lea    0xfd2(%rip),%rdi
call   1030 <puts@plt>
lea    0xe7d(%rip),%rdi
call   1040 <system@plt>
jmp    1267 <main+0x107>
lea    0xf7b(%rip),%rdi
call   1030 <puts@plt>
lea    0xf81(%rip),%rdi
call   1030 <puts@plt>
lea    0xe70(%rip),%rdi
call   1040 <system@plt>
jmp    1267 <main+0x107>
lea    0xf26(%rip),%rdi
call   1030 <puts@plt>
lea    0xf2e(%rip),%rdi
call   1030 <puts@plt>
lea    0xe64(%rip),%rdi
call   1040 <system@plt>
jmp    1267 <main+0x107>
lea    0xef0(%rip),%rdi
jmp    1262 <main+0x102>
lea    0xed3(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb1(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret
lea    0xf88(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1070 <exit@plt>
lea    0xdc3(%rip),%rdi
call   1050 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [33 x i8] c"\0A------------------------------\0A\00"
@.str.1 = [20 x i8] c"wan_start : start!\0A\00"
@.str.2 = [33 x i8] c"-------------------------------\0A\00"
@.str.3 = [16 x i8] c"wan : started!\0A\00"
@.str.4 = [15 x i8] c"no wan needed!\00"
@.str.5 = [20 x i8] c"3G module : LC5730\0A\00"
@.str.6 = [24 x i8] c"pppd call gprs-connect\0A\00"
@.str.7 = [25 x i8] c"pppd call gprs-connect &\00"
@.str.8 = [20 x i8] c"3G module : MC2716\0A\00"
@.str.9 = [24 x i8] c"pppd call evdo-connect\0A\00"
@.str.10 = [25 x i8] c"pppd call evdo-connect &\00"
@.str.11 = [19 x i8] c"3G module : MF210\0A\00"
@.str.12 = [25 x i8] c"pppd call wcdma-connect\0A\00"
@.str.13 = [26 x i8] c"pppd call wcdma-connect &\00"
@.str.14 = [21 x i8] c"3G module : LS6300v\0A\00"
@.str.15 = [28 x i8] c"pppd call wcdma-ls-connect\0A\00"
@.str.16 = [29 x i8] c"pppd call wcdma-ls-connect &\00"
@.str.17 = [17 x i8] c"usb/wifi module\0A\00"
@.str.18 = [21 x i8] c"usb/ethernet module\0A\00"
@.str.19 = [23 x i8] c"wan_start : complete!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [256 x i8]
store i32 0, i32* %1
%4 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%7 = bitcast [256 x i8]* %3 to i8*
%8 = call i64 (...) @wan_monitor()
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %0
%11 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @exit(i32 0)
unreachable
13: ; preds = %0
%14 = call i32 (...) @sql_data()
store i32 %14, i32* %2
%15 = load i32, i32* %2
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %13
%18 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%19 = call i32 @exit(i32 0)
unreachable
20: ; preds = %13
%21 = load i32, i32* %2
%22 = icmp eq i32 %21, 1
br i1 %22, label %23, label %27
23: ; preds = %20
%24 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
%25 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0))
%26 = call i32 @system(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0))
br label %27
27: ; preds = %23, %20
%28 = load i32, i32* %2
%29 = icmp eq i32 %28, 2
br i1 %29, label %30, label %34
30: ; preds = %27
%31 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0))
%32 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0))
%33 = call i32 @system(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.10, i64 0, i64 0))
br label %34
34: ; preds = %30, %27
%35 = load i32, i32* %2
%36 = icmp eq i32 %35, 3
br i1 %36, label %37, label %41
37: ; preds = %34
%38 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.11, i64 0, i64 0))
%39 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.12, i64 0, i64 0))
%40 = call i32 @system(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.13, i64 0, i64 0))
br label %41
41: ; preds = %37, %34
%42 = load i32, i32* %2
%43 = icmp eq i32 %42, 4
br i1 %43, label %44, label %48
44: ; preds = %41
%45 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.14, i64 0, i64 0))
%46 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.15, i64 0, i64 0))
%47 = call i32 @system(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.16, i64 0, i64 0))
br label %48
48: ; preds = %44, %41
%49 = load i32, i32* %2
%50 = icmp eq i32 %49, 10
br i1 %50, label %51, label %53
51: ; preds = %48
%52 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.17, i64 0, i64 0))
br label %53
53: ; preds = %51, %48
%54 = load i32, i32* %2
%55 = icmp eq i32 %54, 20
br i1 %55, label %56, label %58
56: ; preds = %53
%57 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.18, i64 0, i64 0))
br label %58
58: ; preds = %56, %53
%59 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.19, i64 0, i64 0))
%60 = load i32, i32* %1
ret i32 %60
}

LLVM IR (-O2):
@.str.4 = [15 x i8] c"no wan needed!\00"
@.str.7 = [25 x i8] c"pppd call gprs-connect &\00"
@.str.10 = [25 x i8] c"pppd call evdo-connect &\00"
@.str.13 = [26 x i8] c"pppd call wcdma-connect &\00"
@.str.16 = [29 x i8] c"pppd call wcdma-ls-connect &\00"
@str = [32 x i8] c"\0A------------------------------\00"
@str.20 = [19 x i8] c"wan_start : start!\00"
@str.21 = [32 x i8] c"-------------------------------\00"
@str.22 = [22 x i8] c"wan_start : complete!\00"
@str.23 = [20 x i8] c"usb/ethernet module\00"
@str.24 = [16 x i8] c"usb/wifi module\00"
@str.25 = [20 x i8] c"3G module : LS6300v\00"
@str.26 = [27 x i8] c"pppd call wcdma-ls-connect\00"
@str.27 = [18 x i8] c"3G module : MF210\00"
@str.28 = [24 x i8] c"pppd call wcdma-connect\00"
@str.29 = [19 x i8] c"3G module : MC2716\00"
@str.30 = [23 x i8] c"pppd call evdo-connect\00"
@str.31 = [19 x i8] c"3G module : LC5730\00"
@str.32 = [23 x i8] c"pppd call gprs-connect\00"
@str.33 = [15 x i8] c"wan : started!\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.20, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.21, i64 0, i64 0))
%4 = tail call i64 (...) @wan_monitor()
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %0
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.33, i64 0, i64 0))
%8 = tail call i32 @exit(i32 0)
unreachable
9: ; preds = %0
%10 = tail call i32 (...) @sql_data()
switch i32 %10, label %34 [
i32 0, label %11
i32 1, label %14
i32 2, label %18
i32 3, label %22
i32 4, label %26
i32 10, label %30
i32 20, label %32
]
11: ; preds = %9
%12 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%13 = tail call i32 @exit(i32 0)
unreachable
14: ; preds = %9
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.31, i64 0, i64 0))
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.32, i64 0, i64 0))
%17 = tail call i32 @system(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0))
br label %34
18: ; preds = %9
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.29, i64 0, i64 0))
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.30, i64 0, i64 0))
%21 = tail call i32 @system(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.10, i64 0, i64 0))
br label %34
22: ; preds = %9
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.27, i64 0, i64 0))
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.28, i64 0, i64 0))
%25 = tail call i32 @system(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.13, i64 0, i64 0))
br label %34
26: ; preds = %9
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.25, i64 0, i64 0))
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.26, i64 0, i64 0))
%29 = tail call i32 @system(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.16, i64 0, i64 0))
br label %34
30: ; preds = %9
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.24, i64 0, i64 0))
br label %34
32: ; preds = %9
%33 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.23, i64 0, i64 0))
br label %34
34: ; preds = %30, %26, %22, %18, %14, %9, %32
%35 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.22, i64 0, i64 0))
ret i32 0
}