#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ group(char, char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int main(int argc, char **argv) {
  char delimiter = {0};
  char *operation = "count";
  if (argc >= 2)
    delimiter = *argv[1];
  if (argc == 3)
    operation = argv[2];
  if (strcmp(operation, "count") != 0 && strcmp(operation, "sum") != 0) {
    fprintf(stderr, "Usage: %s [delimiter] [count|sum]\n", argv[0]);
    exit(1);
  }
  group(delimiter, operation);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x0,-0x11(%rbp)
lea    0xe9f(%rip),%rax
mov    %rax,-0x20(%rbp)
cmpl   $0x2,-0x8(%rbp)
jl     117c <main+0x3c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%al
mov    %al,-0x11(%rbp)
cmpl   $0x3,-0x8(%rbp)
jne    1192 <main+0x52>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe63(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     11ec <main+0xac>
mov    -0x20(%rbp),%rdi
lea    0xe4f(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     11ec <main+0xac>
mov    0x2e13(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe2d(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x11(%rbp),%al
mov    -0x20(%rbp),%rsi
movsbl %al,%edi
call   1050 <group@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
lea    0xeb2(%rip),%rbx
cmp    $0x2,%edi
jl     1165 <main+0x25>
mov    0x8(%r14),%rax
mov    (%rax),%bpl
cmp    $0x3,%edi
jne    1167 <main+0x27>
mov    0x10(%r14),%rbx
jmp    1167 <main+0x27>
xor    %ebp,%ebp
lea    0xe92(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     118f <main+0x4f>
lea    0xe84(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
jne    11a2 <main+0x62>
movsbl %bpl,%edi
mov    %rbx,%rsi
call   1050 <group@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2e37(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xe55(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"count\00"
@.str.1 = [4 x i8] c"sum\00"
@stderr = global i32 0
@.str.2 = [35 x i8] c"Usage: %s [delimiter] [count|sum]\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8 0, i8* %6
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %7
%8 = load i32, i32* %4
%9 = icmp sge i32 %8, 2
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = load i8, i8* %13
store i8 %14, i8* %6
br label %15
15: ; preds = %10, %2
%16 = load i32, i32* %4
%17 = icmp eq i32 %16, 3
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 2
%21 = load i8*, i8** %20
store i8* %21, i8** %7
br label %22
22: ; preds = %18, %15
%23 = load i8*, i8** %7
%24 = call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %37
26: ; preds = %22
%27 = load i8*, i8** %7
%28 = call i64 @strcmp(i8* %27, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %37
30: ; preds = %26
%31 = load i32, i32* @stderr
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 0
%34 = load i8*, i8** %33
%35 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8* %34)
%36 = call i32 @exit(i32 1)
unreachable
37: ; preds = %26, %22
%38 = load i8, i8* %6
%39 = load i8*, i8** %7
%40 = call i32 @group(i8 signext %38, i8* %39)
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"count\00"
@.str.1 = [4 x i8] c"sum\00"
@stderr = global i32 0
@.str.2 = [35 x i8] c"Usage: %s [delimiter] [count|sum]\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %12
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = load i8, i8* %6
%8 = icmp eq i32 %0, 3
br i1 %8, label %9, label %12
9: ; preds = %4
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
br label %12
12: ; preds = %2, %9, %4
%13 = phi i8 [ %7, %9 ], [ %7, %4 ], [ 0, %2 ]
%14 = phi i8* [ %11, %9 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), %4 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), %2 ]
%15 = tail call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %25, label %17
17: ; preds = %12
%18 = tail call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %25, label %20
20: ; preds = %17
%21 = load i32, i32* @stderr
%22 = load i8*, i8** %1
%23 = tail call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8* %22)
%24 = tail call i32 @exit(i32 1)
unreachable
25: ; preds = %17, %12
%26 = tail call i32 @group(i8 signext %13, i8* %14)
ret i32 0
}