#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*/ os_shellexec(char *, char *, int);
int /*<<< orphan*/ printf(char *, char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char const *);
int adb_condition(const char *contents) {
  char buf[2048] = {0};
  char result[8] = {0};
  sprintf(buf, "adb shell \"[ %s ] && echo '1' || echo '0'\"", contents);
  os_shellexec(buf, result, 8);
  printf("$ %s\n%s\n", buf, result);
  if (result[0] == '1') {
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<adb_condition>:
push   %rbp
mov    %rsp,%rbp
sub    $0x820,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x810(%rbp),%rdi
xor    %esi,%esi
mov    $0x800,%edx
call   1040 <memset@plt>
lea    -0x818(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
lea    -0x810(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe79(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x810(%rbp),%rdi
lea    -0x818(%rbp),%rsi
mov    $0x8,%edx
call   1050 <os_shellexec@plt>
lea    -0x810(%rbp),%rsi
lea    -0x818(%rbp),%rdx
lea    0xe72(%rip),%rdi
call   1030 <printf@plt>
movsbl -0x818(%rbp),%eax
cmp    $0x31,%eax
jne    11da <adb_condition+0x9a>
movl   $0x1,-0x4(%rbp)
jmp    11e1 <adb_condition+0xa1>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<adb_condition>:
push   %r14
push   %rbx
sub    $0x818,%rsp
mov    %rdi,%rbx
lea    0x10(%rsp),%r14
mov    $0x800,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
movq   $0x0,0x8(%rsp)
lea    0xe8f(%rip),%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
call   1060 <sprintf@plt>
lea    0x8(%rsp),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x8,%edx
call   1050 <os_shellexec@plt>
lea    0xe93(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1030 <printf@plt>
xor    %eax,%eax
cmpb   $0x31,0x8(%rsp)
sete   %al
add    $0x818,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [43 x i8] c"adb shell \22[ %s ] && echo '1' || echo '0'\22\00"
@.str.1 = [9 x i8] c"$ %s\0A%s\0A\00"
define i32 @adb_condition(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [2048 x i8]
%5 = alloca [8 x i8]
store i8* %0, i8** %3
%6 = bitcast [2048 x i8]* %4 to i8*
%7 = bitcast [8 x i8]* %5 to i8*
%8 = getelementptr inbounds [2048 x i8], [2048 x i8]* %4, i64 0, i64 0
%9 = load i8*, i8** %3
%10 = call i32 @sprintf(i8* %8, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = getelementptr inbounds [2048 x i8], [2048 x i8]* %4, i64 0, i64 0
%12 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%13 = call i32 @os_shellexec(i8* %11, i8* %12, i32 8)
%14 = getelementptr inbounds [2048 x i8], [2048 x i8]* %4, i64 0, i64 0
%15 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%16 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %14, i8* %15)
%17 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 49
br i1 %20, label %21, label %22
21: ; preds = %1
store i32 1, i32* %2
br label %23
22: ; preds = %1
store i32 0, i32* %2
br label %23
23: ; preds = %22, %21
%24 = load i32, i32* %2
ret i32 %24
}

LLVM IR (-O2):
@.str = [43 x i8] c"adb shell \22[ %s ] && echo '1' || echo '0'\22\00"
@.str.1 = [9 x i8] c"$ %s\0A%s\0A\00"
define i32 @adb_condition(i8* %0) {
%2 = alloca [2048 x i8]
%3 = alloca i64
%4 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 0
%5 = bitcast i64* %3 to i8*
store i64 0, i64* %3
%6 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* %0)
%7 = call i32 @os_shellexec(i8* %4, i8* %5, i32 8)
%8 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %4, i8* %5)
%9 = load i8, i8* %5
%10 = icmp eq i8 %9, 49
%11 = zext i1 %10 to i32
ret i32 %11
}