#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 character_count(char, char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ get_line(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *, char, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int main(int argc, char **argv) {
  char buffer[1024];
  char character;
  char delimiter;
  int count;
  if (argc != 2) {
    fprintf(stderr, "Usage: %s character\n", argv[0]);
    exit(1);
  }
  character = *argv[1];
  if (character == ',')
    delimiter = '|';
  else
    delimiter = ',';
  while (get_line(buffer, stdin)) {
    count = character_count(character, buffer);
    printf("%s%c%d\n", buffer, delimiter, count);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1199 <main+0x49>
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe76(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%al
mov    %al,-0x411(%rbp)
movsbl -0x411(%rbp),%eax
cmp    $0x2c,%eax
jne    11c5 <main+0x75>
movb   $0x7c,-0x412(%rbp)
jmp    11cc <main+0x7c>
movb   $0x2c,-0x412(%rbp)
jmp    11d1 <main+0x81>
lea    -0x410(%rbp),%rdi
mov    0x2e09(%rip),%rax
mov    (%rax),%esi
call   1030 <get_line@plt>
cmp    $0x0,%rax
je     1232 <main+0xe2>
mov    -0x411(%rbp),%al
lea    -0x410(%rbp),%rsi
movsbl %al,%edi
call   1060 <character_count@plt>
mov    %eax,-0x418(%rbp)
lea    -0x410(%rbp),%rsi
mov    -0x412(%rbp),%al
mov    -0x418(%rbp),%ecx
lea    0xdf0(%rip),%rdi
movsbl %al,%edx
call   1040 <printf@plt>
jmp    11d1 <main+0x81>
xor    %eax,%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x400,%rsp
cmp    $0x2,%edi
jne    11ed <main+0x9d>
mov    0x8(%rsi),%rax
mov    (%rax),%bl
cmp    $0x2c,%bl
mov    $0x7c,%eax
mov    $0x2c,%ebp
cmove  %eax,%ebp
mov    0x2e63(%rip),%r12
mov    (%r12),%esi
mov    %rsp,%rdi
call   1030 <get_line@plt>
test   %rax,%rax
je     11db <main+0x8b>
movsbl %bl,%r14d
mov    %rsp,%rbx
movzbl %bpl,%ebp
lea    0xe6d(%rip),%r15
nopl   0x0(%rax,%rax,1)
mov    %r14d,%edi
mov    %rbx,%rsi
call   1060 <character_count@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
mov    %eax,%ecx
call   1040 <printf@plt>
mov    (%r12),%esi
mov    %rbx,%rdi
call   1030 <get_line@plt>
test   %rax,%rax
jne    11b0 <main+0x60>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2de4(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xe00(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

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

LLVM IR (-O2):
@stderr = global i32 0
@.str = [21 x i8] c"Usage: %s character\0A\00"
@stdin = global i32 0
@.str.1 = [8 x i8] c"%s%c%d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 2
br i1 %5, label %11, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 44
%16 = select i1 %15, i8 124, i8 44
%17 = load i32, i32* @stdin
%18 = call i64 @get_line(i8* %4, i32 %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %26, label %20
20: ; preds = %11, %20
%21 = call i32 @character_count(i8 signext %14, i8* %4)
%22 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %4, i8 signext %16, i32 %21)
%23 = load i32, i32* @stdin
%24 = call i64 @get_line(i8* %4, i32 %23)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %20
26: ; preds = %20, %11
ret i32 0
}