#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 */
scalar_t__ osSystem_GetOutput(char *, char *, int);
int /*<<< orphan*/ utilStrTrim(char *);
long cfgWanIfName(char *sDataBuf, int iDataLen) {
  if (sDataBuf == (0) || iDataLen <= 0)
    return (-1);
  if (osSystem_GetOutput("wandataif.sh", sDataBuf, iDataLen) < 0)
    return (-1);
  utilStrTrim(sDataBuf);
  return (0);
}


x86 assembly (clang, -O0):
<cfgWanIfName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1144 <cfgWanIfName+0x24>
cmpl   $0x0,-0x14(%rbp)
jg     1151 <cfgWanIfName+0x31>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    118c <cfgWanIfName+0x6c>
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    0xea1(%rip),%rdi
call   1030 <osSystem_GetOutput@plt>
cmp    $0x0,%rax
jge    117b <cfgWanIfName+0x5b>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    118c <cfgWanIfName+0x6c>
mov    -0x10(%rbp),%rdi
call   1040 <utilStrTrim@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cfgWanIfName>:
push   %r14
push   %rbx
push   %rax
mov    $0xffffffffffffffff,%r14
test   %rdi,%rdi
je     1158 <cfgWanIfName+0x38>
mov    %esi,%edx
test   %esi,%esi
jle    1158 <cfgWanIfName+0x38>
mov    %rdi,%rbx
lea    0xec0(%rip),%rdi
mov    %rbx,%rsi
call   1030 <osSystem_GetOutput@plt>
test   %rax,%rax
js     1158 <cfgWanIfName+0x38>
mov    %rbx,%rdi
call   1040 <utilStrTrim@plt>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [13 x i8] c"wandataif.sh\00"
define i64 @cfgWanIfName(i8* %0, i32 %1) {
%3 = icmp eq i8* %0, null
%4 = icmp slt i32 %1, 1
%5 = or i1 %3, %4
br i1 %5, label %11, label %6
6: ; preds = %2
%7 = tail call i64 @osSystem_GetOutput(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %1)
%8 = icmp slt i64 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %6
%10 = tail call i32 @utilStrTrim(i8* %0)
br label %11
11: ; preds = %6, %2, %9
%12 = phi i64 [ 0, %9 ], [ -1, %2 ], [ -1, %6 ]
ret i64 %12
}