#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*/ Usage(char *);
int arg_rest(char **);
scalar_t__ isOption(char *);
int /*<<< orphan*/ sprintf(char *, char const *, int, int);
int howmany_tags(char *argv[], int group) {
  int result = 0;
  int have;
  const char *format = "Expected %d arguments, found only %d";
  char temp[80];
  while (argv[0] != 0) {
    if (isOption(argv[0]))
      break;
    if ((have = arg_rest(argv)) < group) {
      sprintf(temp, format, group, have);
      Usage(temp);
    }
    argv += group;
    result++;
  }
  return result;
}


x86 assembly (clang, -O0):
<howmany_tags>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xea3(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
je     11de <howmany_tags+0x9e>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1030 <isOption@plt>
cmp    $0x0,%rax
je     118a <howmany_tags+0x4a>
jmp    11de <howmany_tags+0x9e>
mov    -0x8(%rbp),%rdi
call   1050 <arg_rest@plt>
mov    %eax,-0x14(%rbp)
cmp    -0xc(%rbp),%eax
jge    11bb <howmany_tags+0x7b>
lea    -0x70(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0xc(%rbp),%edx
mov    -0x14(%rbp),%ecx
call   1060 <sprintf@plt>
lea    -0x70(%rbp),%rdi
call   1040 <Usage@plt>
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1161 <howmany_tags+0x21>
mov    -0x10(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<howmany_tags>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rdi,%rbx
mov    (%rdi),%rdi
test   %rdi,%rdi
je     11c0 <howmany_tags+0x80>
mov    %esi,%r14d
movslq %esi,%r13
shl    $0x3,%r13
xor    %ebp,%ebp
lea    0xe94(%rip),%r15
mov    %rsp,%r12
jmp    118f <howmany_tags+0x4f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebp
mov    (%rbx,%r13,1),%rdi
add    %r13,%rbx
test   %rdi,%rdi
je     11c2 <howmany_tags+0x82>
call   1030 <isOption@plt>
test   %rax,%rax
jne    11c2 <howmany_tags+0x82>
mov    %rbx,%rdi
call   1050 <arg_rest@plt>
cmp    %r14d,%eax
jge    1180 <howmany_tags+0x40>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r14d,%edx
mov    %eax,%ecx
call   1060 <sprintf@plt>
mov    %r12,%rdi
call   1040 <Usage@plt>
jmp    1180 <howmany_tags+0x40>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [37 x i8] c"Expected %d arguments, found only %d\00"
define i32 @howmany_tags(i8** %0, i32 %1) {
%3 = alloca [80 x i8]
%4 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%5 = load i8*, i8** %0
%6 = icmp eq i8* %5, null
br i1 %6, label %26, label %7
7: ; preds = %2
%8 = sext i32 %1 to i64
br label %9
9: ; preds = %7, %21
%10 = phi i8* [ %5, %7 ], [ %24, %21 ]
%11 = phi i8** [ %0, %7 ], [ %22, %21 ]
%12 = phi i32 [ 0, %7 ], [ %23, %21 ]
%13 = call i64 @isOption(i8* %10)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %26
15: ; preds = %9
%16 = call i32 @arg_rest(i8** %11)
%17 = icmp slt i32 %16, %1
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %16)
%20 = call i32 @Usage(i8* %4)
br label %21
21: ; preds = %18, %15
%22 = getelementptr inbounds i8*, i8** %11, i64 %8
%23 = add nuw nsw i32 %12, 1
%24 = load i8*, i8** %22
%25 = icmp eq i8* %24, null
br i1 %25, label %26, label %9
26: ; preds = %21, %9, %2
%27 = phi i32 [ 0, %2 ], [ %12, %9 ], [ %23, %21 ]
ret i32 %27
}