#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*/ cdoAbort(char *, char *);
int operatorStreamInCnt(char *);
int operatorStreamOutCnt(char *);
int skipInputStreams(int, char **, int, int);
char *strchr(char *, char);
int getGlobArgc(int argc, char *argv[], int globArgc) {
  int streamInCnt;
  int streamOutCnt;
  char *opername;
  char *comma_position;
  opername = &argv[globArgc][1];
  comma_position = strchr(opername, ',');
  if (comma_position)
    *comma_position = 0;
  streamInCnt = operatorStreamInCnt(opername);
  streamOutCnt = operatorStreamOutCnt(opername);
  if (streamInCnt == -1)
    streamInCnt = 1;
  if (streamOutCnt > 1)
    cdoAbort(
        "More than one output stream not allowed in CDO pipes (Operator %s)!",
        opername);
  globArgc++;
  if (streamInCnt > 0)
    globArgc = skipInputStreams(argc, argv, globArgc, streamInCnt);
  if (comma_position)
    *comma_position = ',';
  return (globArgc);
}


x86 assembly (clang, -O0):
<getGlobArgc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    $0x2c,%esi
call   1040 <strchr@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     119a <getGlobArgc+0x4a>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x28(%rbp),%rdi
call   1070 <operatorStreamInCnt@plt>
mov    %eax,-0x18(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <operatorStreamOutCnt@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    11c3 <getGlobArgc+0x73>
movl   $0x1,-0x18(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jle    11dd <getGlobArgc+0x8d>
mov    -0x28(%rbp),%rsi
lea    0xe28(%rip),%rdi
call   1060 <cdoAbort@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x18(%rbp)
jle    1205 <getGlobArgc+0xb5>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1030 <skipInputStreams@plt>
mov    %eax,-0x14(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     1217 <getGlobArgc+0xc7>
mov    -0x30(%rbp),%rax
movb   $0x2c,(%rax)
mov    -0x14(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getGlobArgc>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r13d
mov    %rsi,%r15
mov    %edi,0x4(%rsp)
movslq %edx,%rax
mov    (%rsi,%rax,8),%rbp
add    $0x1,%rbp
mov    %rbp,%rdi
mov    $0x2c,%esi
call   1040 <strchr@plt>
mov    %rax,%r14
test   %rax,%rax
je     1189 <getGlobArgc+0x39>
movb   $0x0,(%r14)
mov    %rbp,%rdi
call   1070 <operatorStreamInCnt@plt>
mov    %eax,%r12d
mov    %rbp,%rdi
call   1050 <operatorStreamOutCnt@plt>
cmp    $0xffffffff,%r12d
mov    $0x1,%ebx
cmovne %r12d,%ebx
cmp    $0x2,%eax
jl     11bd <getGlobArgc+0x6d>
lea    0xe4b(%rip),%rdi
mov    %rbp,%rsi
call   1060 <cdoAbort@plt>
add    $0x1,%r13d
test   %ebx,%ebx
jle    11d9 <getGlobArgc+0x89>
mov    0x4(%rsp),%edi
mov    %r15,%rsi
mov    %r13d,%edx
mov    %ebx,%ecx
call   1030 <skipInputStreams@plt>
mov    %eax,%r13d
test   %r14,%r14
je     11e2 <getGlobArgc+0x92>
movb   $0x2c,(%r14)
mov    %r13d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [68 x i8] c"More than one output stream not allowed in CDO pipes (Operator %s)!\00"
define i32 @getGlobArgc(i32 %0, i8** %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 %2, i32* %6
%11 = load i8**, i8*** %5
%12 = load i32, i32* %6
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8*, i8** %11, i64 %13
%15 = load i8*, i8** %14
%16 = getelementptr inbounds i8, i8* %15, i64 1
store i8* %16, i8** %9
%17 = load i8*, i8** %9
%18 = call i8* @strchr(i8* %17, i8 signext 44)
store i8* %18, i8** %10
%19 = load i8*, i8** %10
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %23
21: ; preds = %3
%22 = load i8*, i8** %10
store i8 0, i8* %22
br label %23
23: ; preds = %21, %3
%24 = load i8*, i8** %9
%25 = call i32 @operatorStreamInCnt(i8* %24)
store i32 %25, i32* %7
%26 = load i8*, i8** %9
%27 = call i32 @operatorStreamOutCnt(i8* %26)
store i32 %27, i32* %8
%28 = load i32, i32* %7
%29 = icmp eq i32 %28, -1
br i1 %29, label %30, label %31
30: ; preds = %23
store i32 1, i32* %7
br label %31
31: ; preds = %30, %23
%32 = load i32, i32* %8
%33 = icmp sgt i32 %32, 1
br i1 %33, label %34, label %37
34: ; preds = %31
%35 = load i8*, i8** %9
%36 = call i32 @cdoAbort(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str, i64 0, i64 0), i8* %35)
br label %37
37: ; preds = %34, %31
%38 = load i32, i32* %6
%39 = add nsw i32 %38, 1
store i32 %39, i32* %6
%40 = load i32, i32* %7
%41 = icmp sgt i32 %40, 0
br i1 %41, label %42, label %48
42: ; preds = %37
%43 = load i32, i32* %4
%44 = load i8**, i8*** %5
%45 = load i32, i32* %6
%46 = load i32, i32* %7
%47 = call i32 @skipInputStreams(i32 %43, i8** %44, i32 %45, i32 %46)
store i32 %47, i32* %6
br label %48
48: ; preds = %42, %37
%49 = load i8*, i8** %10
%50 = icmp ne i8* %49, null
br i1 %50, label %51, label %53
51: ; preds = %48
%52 = load i8*, i8** %10
store i8 44, i8* %52
br label %53
53: ; preds = %51, %48
%54 = load i32, i32* %6
ret i32 %54
}

LLVM IR (-O2):
@.str = [68 x i8] c"More than one output stream not allowed in CDO pipes (Operator %s)!\00"
define i32 @getGlobArgc(i32 %0, i8** %1, i32 %2) {
%4 = sext i32 %2 to i64
%5 = getelementptr inbounds i8*, i8** %1, i64 %4
%6 = load i8*, i8** %5
%7 = getelementptr inbounds i8, i8* %6, i64 1
%8 = tail call i8* @strchr(i8* %7, i8 signext 44)
%9 = icmp eq i8* %8, null
br i1 %9, label %11, label %10
10: ; preds = %3
store i8 0, i8* %8
br label %11
11: ; preds = %10, %3
%12 = tail call i32 @operatorStreamInCnt(i8* %7)
%13 = tail call i32 @operatorStreamOutCnt(i8* %7)
%14 = icmp eq i32 %12, -1
%15 = select i1 %14, i32 1, i32 %12
%16 = icmp sgt i32 %13, 1
br i1 %16, label %17, label %19
17: ; preds = %11
%18 = tail call i32 @cdoAbort(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str, i64 0, i64 0), i8* %7)
br label %19
19: ; preds = %17, %11
%20 = add nsw i32 %2, 1
%21 = icmp sgt i32 %15, 0
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = tail call i32 @skipInputStreams(i32 %0, i8** %1, i32 %20, i32 %15)
br label %24
24: ; preds = %22, %19
%25 = phi i32 [ %23, %22 ], [ %20, %19 ]
br i1 %9, label %27, label %26
26: ; preds = %24
store i8 44, i8* %8
br label %27
27: ; preds = %26, %24
ret i32 %25
}