#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 */
char *strstr(char const *, char *);
unsigned char toupper(char);
int tl_is_rooted(const char *nwk) {
  char *rootcmd = NULL;
  rootcmd = strstr(nwk, "[&");
  if (rootcmd) {
    rootcmd = rootcmd + 2;
    if (toupper(*rootcmd) == 'R') {
      return 1;
    } else if (toupper(*rootcmd) == 'U') {
      return 0;
    }
  }
  return -1;
}


x86 assembly (clang, -O0):
<tl_is_rooted>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xec1(%rip),%rsi
call   1040 <strstr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11b1 <tl_is_rooted+0x91>
mov    -0x18(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
movzbl %al,%eax
cmp    $0x52,%eax
jne    1183 <tl_is_rooted+0x63>
movl   $0x1,-0x4(%rbp)
jmp    11b8 <tl_is_rooted+0x98>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
movzbl %al,%eax
cmp    $0x55,%eax
jne    11a7 <tl_is_rooted+0x87>
movl   $0x0,-0x4(%rbp)
jmp    11b8 <tl_is_rooted+0x98>
jmp    11ac <tl_is_rooted+0x8c>
jmp    11b1 <tl_is_rooted+0x91>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tl_is_rooted>:
push   %rbx
lea    0xed8(%rip),%rsi
call   1040 <strstr@plt>
test   %rax,%rax
je     115c <tl_is_rooted+0x3c>
mov    %rax,%rbx
movsbl 0x2(%rax),%edi
call   1030 <toupper@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    $0x52,%cl
je     1161 <tl_is_rooted+0x41>
movsbl 0x2(%rbx),%edi
call   1030 <toupper@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x55,%cl
je     1161 <tl_is_rooted+0x41>
mov    $0xffffffff,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"[&\00"
define i32 @tl_is_rooted(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
store i8* null, i8** %4
%5 = load i8*, i8** %3
%6 = call i8* @strstr(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %6, i8** %4
%7 = load i8*, i8** %4
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %27
9: ; preds = %1
%10 = load i8*, i8** %4
%11 = getelementptr inbounds i8, i8* %10, i64 2
store i8* %11, i8** %4
%12 = load i8*, i8** %4
%13 = load i8, i8* %12
%14 = call zeroext i8 @toupper(i8 signext %13)
%15 = zext i8 %14 to i32
%16 = icmp eq i32 %15, 82
br i1 %16, label %17, label %18
17: ; preds = %9
store i32 1, i32* %2
br label %28
18: ; preds = %9
%19 = load i8*, i8** %4
%20 = load i8, i8* %19
%21 = call zeroext i8 @toupper(i8 signext %20)
%22 = zext i8 %21 to i32
%23 = icmp eq i32 %22, 85
br i1 %23, label %24, label %25
24: ; preds = %18
store i32 0, i32* %2
br label %28
25: ; preds = %18
br label %26
26: ; preds = %25
br label %27
27: ; preds = %26, %1
store i32 -1, i32* %2
br label %28
28: ; preds = %27, %24, %17
%29 = load i32, i32* %2
ret i32 %29
}

LLVM IR (-O2):
@.str = [3 x i8] c"[&\00"
define i32 @tl_is_rooted(i8* %0) {
%2 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i8* %2, null
br i1 %3, label %13, label %4
4: ; preds = %1
%5 = getelementptr inbounds i8, i8* %2, i64 2
%6 = load i8, i8* %5
%7 = tail call zeroext i8 @toupper(i8 signext %6)
%8 = icmp eq i8 %7, 82
br i1 %8, label %14, label %9
9: ; preds = %4
%10 = load i8, i8* %5
%11 = tail call zeroext i8 @toupper(i8 signext %10)
%12 = icmp eq i8 %11, 85
br i1 %12, label %14, label %13
13: ; preds = %9, %1
br label %14
14: ; preds = %9, %4, %13
%15 = phi i32 [ -1, %13 ], [ 1, %4 ], [ 0, %9 ]
ret i32 %15
}