#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 */
typedef int /*<<< orphan*/ sCmd;

/* Variables and functions */
scalar_t__ osSystem_GetOutput(char *, char *, int);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int /*<<< orphan*/ utilStrTrim(char *);
long cfgWanIfSect(char *sDataBuf, int iDataLen) {
  char sCmd[64];
  if (sDataBuf == (0) || iDataLen <= 0)
    return (-1);
  if (osSystem_GetOutput("wandataif.sh", sDataBuf, iDataLen) < 0)
    return (-1);
  utilStrTrim(sDataBuf);
  if (sDataBuf[0] == '\0')
    return (0);
  snprintf(sCmd, sizeof(sCmd), "if2sect.sh %s", sDataBuf);
  if (osSystem_GetOutput(sCmd, sDataBuf, iDataLen) < 0)
    return (-1);
  utilStrTrim(sDataBuf);
  return (0);
}


x86 assembly (clang, -O0):
<cfgWanIfSect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1154 <cfgWanIfSect+0x24>
cmpl   $0x0,-0x14(%rbp)
jg     1161 <cfgWanIfSect+0x31>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    1202 <cfgWanIfSect+0xd2>
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    0xe91(%rip),%rdi
call   1040 <osSystem_GetOutput@plt>
cmp    $0x0,%rax
jge    118b <cfgWanIfSect+0x5b>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    1202 <cfgWanIfSect+0xd2>
mov    -0x10(%rbp),%rdi
call   1050 <utilStrTrim@plt>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11b1 <cfgWanIfSect+0x81>
movq   $0x0,-0x8(%rbp)
jmp    1202 <cfgWanIfSect+0xd2>
lea    -0x60(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x40,%esi
lea    0xe48(%rip),%rdx
call   1030 <snprintf@plt>
lea    -0x60(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1040 <osSystem_GetOutput@plt>
cmp    $0x0,%rax
jge    11f1 <cfgWanIfSect+0xc1>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    1202 <cfgWanIfSect+0xd2>
mov    -0x10(%rbp),%rdi
call   1050 <utilStrTrim@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cfgWanIfSect>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x48,%rsp
mov    $0xffffffffffffffff,%r14
test   %rdi,%rdi
je     11a9 <cfgWanIfSect+0x79>
mov    %esi,%ebp
test   %esi,%esi
jle    11a9 <cfgWanIfSect+0x79>
mov    %rdi,%rbx
lea    0xeaa(%rip),%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1040 <osSystem_GetOutput@plt>
test   %rax,%rax
js     11a9 <cfgWanIfSect+0x79>
mov    %rbx,%rdi
call   1050 <utilStrTrim@plt>
cmpb   $0x0,(%rbx)
je     11a6 <cfgWanIfSect+0x76>
lea    0xe94(%rip),%rdx
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0x40,%esi
mov    %rbx,%rcx
call   1030 <snprintf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1040 <osSystem_GetOutput@plt>
test   %rax,%rax
js     11a9 <cfgWanIfSect+0x79>
mov    %rbx,%rdi
call   1050 <utilStrTrim@plt>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x48,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"wandataif.sh\00"
@.str.1 = [14 x i8] c"if2sect.sh %s\00"
define i64 @cfgWanIfSect(i8* %0, i32 %1) {
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i32
%6 = alloca [64 x i8]
store i8* %0, i8** %4
store i32 %1, i32* %5
%7 = load i8*, i8** %4
%8 = icmp eq i8* %7, null
br i1 %8, label %12, label %9
9: ; preds = %2
%10 = load i32, i32* %5
%11 = icmp sle i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %9, %2
store i64 -1, i64* %3
br label %41
13: ; preds = %9
%14 = load i8*, i8** %4
%15 = load i32, i32* %5
%16 = call i64 @osSystem_GetOutput(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %14, i32 %15)
%17 = icmp slt i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %13
store i64 -1, i64* %3
br label %41
19: ; preds = %13
%20 = load i8*, i8** %4
%21 = call i32 @utilStrTrim(i8* %20)
%22 = load i8*, i8** %4
%23 = getelementptr inbounds i8, i8* %22, i64 0
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %19
store i64 0, i64* %3
br label %41
28: ; preds = %19
%29 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%30 = load i8*, i8** %4
%31 = call i32 @snprintf(i8* %29, i32 64, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %30)
%32 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%33 = load i8*, i8** %4
%34 = load i32, i32* %5
%35 = call i64 @osSystem_GetOutput(i8* %32, i8* %33, i32 %34)
%36 = icmp slt i64 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %28
store i64 -1, i64* %3
br label %41
38: ; preds = %28
%39 = load i8*, i8** %4
%40 = call i32 @utilStrTrim(i8* %39)
store i64 0, i64* %3
br label %41
41: ; preds = %38, %37, %27, %18, %12
%42 = load i64, i64* %3
ret i64 %42
}

LLVM IR (-O2):
@.str = [13 x i8] c"wandataif.sh\00"
@.str.1 = [14 x i8] c"if2sect.sh %s\00"
define i64 @cfgWanIfSect(i8* %0, i32 %1) {
%3 = alloca [64 x i8]
%4 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%5 = icmp eq i8* %0, null
%6 = icmp slt i32 %1, 1
%7 = or i1 %5, %6
br i1 %7, label %21, label %8
8: ; preds = %2
%9 = tail call i64 @osSystem_GetOutput(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %1)
%10 = icmp slt i64 %9, 0
br i1 %10, label %21, label %11
11: ; preds = %8
%12 = tail call i32 @utilStrTrim(i8* %0)
%13 = load i8, i8* %0
%14 = icmp eq i8 %13, 0
br i1 %14, label %21, label %15
15: ; preds = %11
%16 = call i32 @snprintf(i8* %4, i32 64, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%17 = call i64 @osSystem_GetOutput(i8* %4, i8* %0, i32 %1)
%18 = icmp slt i64 %17, 0
br i1 %18, label %21, label %19
19: ; preds = %15
%20 = call i32 @utilStrTrim(i8* %0)
br label %21
21: ; preds = %15, %11, %8, %2, %19
%22 = phi i64 [ 0, %19 ], [ -1, %2 ], [ -1, %8 ], [ 0, %11 ], [ -1, %15 ]
ret i64 %22
}