#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 getGlobArgc(int, char **, int);
int getStreamCnt(int argc, char *argv[]) {
  int streamCnt = 0;
  int globArgc = 1;
  while (globArgc < argc) {
    if (argv[globArgc][0] == '-') {
      globArgc = getGlobArgc(argc, argv, globArgc);
    } else
      globArgc++;
    streamCnt++;
  }
  return (streamCnt);
}


x86 assembly (clang, -O0):
<getStreamCnt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    117f <getStreamCnt+0x6f>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    1168 <getStreamCnt+0x58>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%edx
call   1030 <getGlobArgc@plt>
mov    %eax,-0x18(%rbp)
jmp    1171 <getStreamCnt+0x61>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    112d <getStreamCnt+0x1d>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getStreamCnt>:
push   %rbp
push   %r14
push   %rbx
xor    %ebx,%ebx
cmp    $0x2,%edi
jl     1154 <getStreamCnt+0x44>
mov    %rsi,%r14
mov    %edi,%ebp
xor    %ebx,%ebx
mov    $0x1,%eax
jmp    113a <getStreamCnt+0x2a>
nopl   0x0(%rax)
add    $0x1,%eax
add    $0x1,%ebx
cmp    %ebp,%eax
jge    1154 <getStreamCnt+0x44>
movslq %eax,%rcx
mov    (%r14,%rcx,8),%rcx
cmpb   $0x2d,(%rcx)
jne    1130 <getStreamCnt+0x20>
mov    %ebp,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <getGlobArgc@plt>
jmp    1133 <getStreamCnt+0x23>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @getStreamCnt(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
store i32 0, i32* %5
store i32 1, i32* %6
br label %7
7: ; preds = %29, %2
%8 = load i32, i32* %6
%9 = load i32, i32* %3
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %32
11: ; preds = %7
%12 = load i8**, i8*** %4
%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 = getelementptr inbounds i8, i8* %16, i64 0
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 45
br i1 %20, label %21, label %26
21: ; preds = %11
%22 = load i32, i32* %3
%23 = load i8**, i8*** %4
%24 = load i32, i32* %6
%25 = call i32 @getGlobArgc(i32 %22, i8** %23, i32 %24)
store i32 %25, i32* %6
br label %29
26: ; preds = %11
%27 = load i32, i32* %6
%28 = add nsw i32 %27, 1
store i32 %28, i32* %6
br label %29
29: ; preds = %26, %21
%30 = load i32, i32* %5
%31 = add nsw i32 %30, 1
store i32 %31, i32* %5
br label %7
32: ; preds = %7
%33 = load i32, i32* %5
ret i32 %33
}

LLVM IR (-O2):
define i32 @getStreamCnt(i32 %0, i8** %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %20
4: ; preds = %2, %16
%5 = phi i32 [ %17, %16 ], [ 1, %2 ]
%6 = phi i32 [ %18, %16 ], [ 0, %2 ]
%7 = sext i32 %5 to i64
%8 = getelementptr inbounds i8*, i8** %1, i64 %7
%9 = load i8*, i8** %8
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 45
br i1 %11, label %12, label %14
12: ; preds = %4
%13 = tail call i32 @getGlobArgc(i32 %0, i8** %1, i32 %5)
br label %16
14: ; preds = %4
%15 = add nsw i32 %5, 1
br label %16
16: ; preds = %14, %12
%17 = phi i32 [ %13, %12 ], [ %15, %14 ]
%18 = add nuw nsw i32 %6, 1
%19 = icmp slt i32 %17, %0
br i1 %19, label %4, label %20
20: ; preds = %16, %2
%21 = phi i32 [ 0, %2 ], [ %18, %16 ]
ret i32 %21
}