#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__ queryoid(char *);
int /*<<< orphan*/ strcmp(char *, char *);
scalar_t__ watchcns(int /*<<< orphan*/, int /*<<< orphan*/ *,
                    int /*<<< orphan*/ *);
int cmd_query(int argc, char **argv) {
  int i;
  for (i = 0; i < argc; i++)
    if (!strcmp(argv[i], "-")) {
      if (watchcns(0, NULL, NULL))
        return -1;
    } else if (queryoid(argv[i])) {
      return -1;
    }
  return 0;
}


x86 assembly (clang, -O0):
<cmd_query>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11db <cmd_query+0xab>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe9b(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    119c <cmd_query+0x6c>
xor    %edi,%edi
xor    %eax,%eax
mov    %eax,%edx
mov    %rdx,%rsi
call   1030 <watchcns@plt>
cmp    $0x0,%rax
je     1197 <cmd_query+0x67>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e2 <cmd_query+0xb2>
jmp    11c8 <cmd_query+0x98>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <queryoid@plt>
cmp    $0x0,%rax
je     11c3 <cmd_query+0x93>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e2 <cmd_query+0xb2>
jmp    11c8 <cmd_query+0x98>
jmp    11cd <cmd_query+0x9d>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1146 <cmd_query+0x16>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmd_query>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %edi,%edi
jle    1190 <cmd_query+0x60>
mov    %rsi,%r15
mov    %edi,%r12d
xor    %ebx,%ebx
lea    0xeb4(%rip),%r14
jmp    1169 <cmd_query+0x39>
xchg   %ax,%ax
xor    %edi,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1030 <watchcns@plt>
test   %rax,%rax
jne    1189 <cmd_query+0x59>
add    $0x1,%rbx
cmp    %rbx,%r12
je     1190 <cmd_query+0x60>
mov    (%r15,%rbx,8),%r13
mov    %r13,%rdi
mov    %r14,%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1150 <cmd_query+0x20>
mov    %r13,%rdi
call   1050 <queryoid@plt>
test   %rax,%rax
je     1160 <cmd_query+0x30>
mov    $0xffffffff,%eax
jmp    1192 <cmd_query+0x62>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c"-\00"
define i32 @cmd_query(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 0
br i1 %3, label %4, label %21
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %6
6: ; preds = %4, %18
%7 = phi i64 [ 0, %4 ], [ %19, %18 ]
%8 = getelementptr inbounds i8*, i8** %1, i64 %7
%9 = load i8*, i8** %8
%10 = tail call i32 @strcmp(i8* dereferenceable(1) %9, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %6
%13 = tail call i64 @watchcns(i32 0, i32* null, i32* null)
%14 = icmp eq i64 %13, 0
br i1 %14, label %18, label %21
15: ; preds = %6
%16 = tail call i64 @queryoid(i8* %9)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %12, %15
%19 = add nuw nsw i64 %7, 1
%20 = icmp eq i64 %19, %5
br i1 %20, label %21, label %6
21: ; preds = %12, %15, %18, %2
%22 = phi i32 [ 0, %2 ], [ 0, %18 ], [ -1, %15 ], [ -1, %12 ]
ret i32 %22
}