#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 */
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int dump_privop_counts(char *, int);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdout;
scalar_t__ strcmp(char *, char *);
int zero_privop_counts(char *, int);
int main(int argc, char *argv[]) {
  static char buf[8192];
  int res;
  if (argc == 1)
    res = dump_privop_counts(buf, sizeof(buf));
  else if (argc == 2 && strcmp(argv[1], "--clear") == 0)
    res = zero_privop_counts(buf, sizeof(buf));
  else {
    printf("usage: %s [--clear]\n", argv[0]);
    return 1;
  }
  printf("res=%d\n", res);
  fputs(buf, stdout);
  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)
cmpl   $0x1,-0x8(%rbp)
jne    1189 <main+0x39>
lea    0x2ee9(%rip),%rdi
mov    $0x2000,%esi
call   1030 <dump_privop_counts@plt>
mov    %eax,-0x14(%rbp)
jmp    11f0 <main+0xa0>
cmpl   $0x2,-0x8(%rbp)
jne    11ca <main+0x7a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe5e(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    11ca <main+0x7a>
lea    0x2ea8(%rip),%rdi
mov    $0x2000,%esi
call   1070 <zero_privop_counts@plt>
mov    %eax,-0x14(%rbp)
jmp    11eb <main+0x9b>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    121d <main+0xcd>
jmp    11f0 <main+0xa0>
mov    -0x14(%rbp),%esi
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2dd8(%rip),%rax
mov    (%rax),%esi
lea    0x2e4f(%rip),%rdi
call   1050 <fputs@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
cmp    $0x2,%edi
je     1171 <main+0x21>
cmp    $0x1,%edi
jne    1186 <main+0x36>
lea    0x2efb(%rip),%rdi
mov    $0x2000,%esi
call   1030 <dump_privop_counts@plt>
jmp    11af <main+0x5f>
mov    0x8(%rbx),%rdi
lea    0xe84(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     119e <main+0x4e>
mov    (%rbx),%rsi
lea    0xe78(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%ebx
jmp    11d6 <main+0x86>
lea    0x2ebb(%rip),%rdi
mov    $0x2000,%esi
call   1070 <zero_privop_counts@plt>
lea    0xe67(%rip),%rdi
xor    %ebx,%ebx
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e18(%rip),%rax
mov    (%rax),%esi
lea    0x2e8f(%rip),%rdi
call   1050 <fputs@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@main.buf = internal global [8192 x i8] zeroinitializer
@.str = [8 x i8] c"--clear\00"
@.str.1 = [21 x i8] c"usage: %s [--clear]\0A\00"
@.str.2 = [8 x i8] c"res=%d\0A\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 @dump_privop_counts(i8* getelementptr inbounds ([8192 x i8], [8192 x i8]* @main.buf, i64 0, i64 0), i32 8192)
store i32 %10, i32* %6
br label %28
11: ; preds = %2
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, 2
br i1 %13, label %14, label %22
14: ; preds = %11
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %14
%21 = call i32 @zero_privop_counts(i8* getelementptr inbounds ([8192 x i8], [8192 x i8]* @main.buf, i64 0, i64 0), i32 8192)
store i32 %21, i32* %6
br label %27
22: ; preds = %14, %11
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 0
%25 = load i8*, i8** %24
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %25)
store i32 1, i32* %3
br label %33
27: ; preds = %20
br label %28
28: ; preds = %27, %9
%29 = load i32, i32* %6
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %29)
%31 = load i32, i32* @stdout
%32 = call i32 @fputs(i8* getelementptr inbounds ([8192 x i8], [8192 x i8]* @main.buf, i64 0, i64 0), i32 %31)
store i32 0, i32* %3
br label %33
33: ; preds = %28, %22
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
@main.buf = internal global [8192 x i8] zeroinitializer
@.str = [8 x i8] c"--clear\00"
@.str.1 = [21 x i8] c"usage: %s [--clear]\0A\00"
@.str.2 = [8 x i8] c"res=%d\0A\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
switch i32 %0, label %12 [
i32 1, label %3
i32 2, label %5
]
3: ; preds = %2
%4 = tail call i32 @dump_privop_counts(i8* getelementptr inbounds ([8192 x i8], [8192 x i8]* @main.buf, i64 0, i64 0), i32 8192)
br label %15
5: ; preds = %2
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = tail call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %5
%11 = tail call i32 @zero_privop_counts(i8* getelementptr inbounds ([8192 x i8], [8192 x i8]* @main.buf, i64 0, i64 0), i32 8192)
br label %15
12: ; preds = %2, %5
%13 = load i8*, i8** %1
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %13)
br label %20
15: ; preds = %10, %3
%16 = phi i32 [ %4, %3 ], [ %11, %10 ]
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%18 = load i32, i32* @stdout
%19 = tail call i32 @fputs(i8* getelementptr inbounds ([8192 x i8], [8192 x i8]* @main.buf, i64 0, i64 0), i32 %18)
br label %20
20: ; preds = %15, %12
%21 = phi i32 [ 0, %15 ], [ 1, %12 ]
ret i32 %21
}