#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  int /*<<< orphan*/ member_0;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
scalar_t__ get_line(char *, int /*<<< orphan*/);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
scalar_t__ piece(char *, char, char *, int);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ printf(char *, char *, char *);
int /*<<< orphan*/ *stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ *stdout;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main(int argc, char **argv) {
  char input_buffer[1024];
  char group[1024];
  char old_group[1024];
  char value[1024];
  int first_time = 1;
  FILE *p = {0};
  if (argc != 2) {
    fprintf(stderr, "Usage: %s output_heading\n", argv[0]);
    exit(1);
  }
  while (get_line(input_buffer, stdin)) {
    piece(group, '|', input_buffer, 0);
    if (first_time) {
      p = popen("statistics.e 0 0 '' 2", "w");
      strcpy(old_group, group);
      printf("%s: %s\n", argv[1], old_group);
      fflush(stdout);
      first_time = 0;
    } else {
      if (strcmp(old_group, group) != 0) {
        pclose(p);
        p = popen("statistics.e 0 0 '' 2", "w");
        strcpy(old_group, group);
        printf("%s: %s\n", argv[1], old_group);
        fflush(stdout);
      }
    }
    if (piece(value, '|', input_buffer, 1)) {
      fprintf(p, "%s\n", value);
      fflush(p);
    }
  }
  if (p)
    pclose(p);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1020,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x1014(%rbp)
movq   $0x0,-0x1020(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11ff <main+0x5f>
mov    0x2df9(%rip),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe10(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
jmp    1204 <main+0x64>
lea    -0x410(%rbp),%rdi
mov    0x2dd6(%rip),%rax
mov    (%rax),%esi
call   1040 <get_line@plt>
cmp    $0x0,%rax
je     1387 <main+0x1e7>
lea    -0x810(%rbp),%rdi
lea    -0x410(%rbp),%rdx
mov    $0x7c,%esi
xor    %ecx,%ecx
call   10c0 <piece@plt>
cmpl   $0x0,-0x1014(%rbp)
je     12b0 <main+0x110>
lea    0xdc9(%rip),%rdi
lea    0xdd8(%rip),%rsi
call   10a0 <popen@plt>
mov    %rax,-0x1020(%rbp)
lea    -0xc10(%rbp),%rdi
lea    -0x810(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    -0xc10(%rbp),%rdx
lea    0xda5(%rip),%rdi
call   1050 <printf@plt>
mov    0x2d37(%rip),%rax
mov    (%rax),%rdi
call   1090 <fflush@plt>
movl   $0x0,-0x1014(%rbp)
jmp    1335 <main+0x195>
lea    -0xc10(%rbp),%rdi
lea    -0x810(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     1330 <main+0x190>
mov    -0x1020(%rbp),%rdi
call   1060 <pclose@plt>
lea    0xd3a(%rip),%rdi
lea    0xd49(%rip),%rsi
call   10a0 <popen@plt>
mov    %rax,-0x1020(%rbp)
lea    -0xc10(%rbp),%rdi
lea    -0x810(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    -0xc10(%rbp),%rdx
lea    0xd16(%rip),%rdi
call   1050 <printf@plt>
mov    0x2ca8(%rip),%rax
mov    (%rax),%rdi
call   1090 <fflush@plt>
jmp    1335 <main+0x195>
lea    -0x1010(%rbp),%rdi
lea    -0x410(%rbp),%rdx
mov    $0x7c,%esi
mov    $0x1,%ecx
call   10c0 <piece@plt>
cmp    $0x0,%rax
je     1382 <main+0x1e2>
mov    -0x1020(%rbp),%rdi
lea    -0x1010(%rbp),%rdx
lea    0xcc5(%rip),%rsi
call   1080 <fprintf@plt>
mov    -0x1020(%rbp),%rdi
call   1090 <fflush@plt>
jmp    1204 <main+0x64>
cmpq   $0x0,-0x1020(%rbp)
je     13a1 <main+0x201>
mov    -0x1020(%rbp),%rdi
call   1060 <pclose@plt>
xor    %eax,%eax
add    $0x1020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1008,%rsp
mov    %rsi,%r14
cmp    $0x2,%edi
jne    13a5 <main+0x205>
mov    0x2e24(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdi
call   1040 <get_line@plt>
test   %rax,%rax
je     1391 <main+0x1f1>
lea    0xc00(%rsp),%r12
mov    %rsp,%r15
mov    %r12,%rdi
mov    $0x7c,%esi
mov    %r15,%rdx
xor    %ecx,%ecx
call   10c0 <piece@plt>
lea    0xe1f(%rip),%rdi
lea    0xe2e(%rip),%rsi
call   10a0 <popen@plt>
mov    %rax,%rbx
lea    0x800(%rsp),%rbp
mov    %rbp,%rdi
mov    %r12,%rsi
call   1030 <strcpy@plt>
mov    0x8(%r14),%rsi
lea    0xe0a(%rip),%rdi
mov    %rbp,%rdx
call   1050 <printf@plt>
mov    0x2d99(%rip),%rax
mov    (%rax),%rdi
call   1090 <fflush@plt>
lea    0x400(%rsp),%rdi
mov    $0x7c,%esi
mov    %r15,%rdx
mov    $0x1,%ecx
call   10c0 <piece@plt>
test   %rax,%rax
je     127d <main+0xdd>
lea    0xdd1(%rip),%rsi
lea    0x400(%rsp),%rdx
mov    %rbx,%rdi
call   1080 <fprintf@plt>
mov    %rbx,%rdi
call   1090 <fflush@plt>
mov    0x2d64(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdi
call   1040 <get_line@plt>
test   %rax,%rax
je     1384 <main+0x1e4>
lea    0xc00(%rsp),%r15
mov    %rsp,%r12
lea    0x800(%rsp),%r13
lea    0x400(%rsp),%rbp
jmp    12da <main+0x13a>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x2d21(%rip),%rax
mov    (%rax),%esi
mov    %r12,%rdi
call   1040 <get_line@plt>
test   %rax,%rax
je     1384 <main+0x1e4>
mov    %r15,%rdi
mov    $0x7c,%esi
mov    %r12,%rdx
xor    %ecx,%ecx
call   10c0 <piece@plt>
mov    %r13,%rdi
mov    %r15,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1347 <main+0x1a7>
mov    %rbx,%rdi
call   1060 <pclose@plt>
lea    0xd0f(%rip),%rdi
lea    0xd1e(%rip),%rsi
call   10a0 <popen@plt>
mov    %rax,%rbx
mov    %r13,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
mov    0x8(%r14),%rsi
lea    0xd02(%rip),%rdi
mov    %r13,%rdx
call   1050 <printf@plt>
mov    0x2c91(%rip),%rax
mov    (%rax),%rdi
call   1090 <fflush@plt>
mov    %rbp,%rdi
mov    $0x7c,%esi
mov    %r12,%rdx
mov    $0x1,%ecx
call   10c0 <piece@plt>
test   %rax,%rax
je     12c0 <main+0x120>
mov    %rbx,%rdi
lea    0xcc7(%rip),%rsi
mov    %rbp,%rdx
call   1080 <fprintf@plt>
mov    %rbx,%rdi
call   1090 <fflush@plt>
jmp    12c0 <main+0x120>
test   %rbx,%rbx
je     1391 <main+0x1f1>
mov    %rbx,%rdi
call   1060 <pclose@plt>
xor    %eax,%eax
add    $0x1008,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c2c(%rip),%rax
mov    (%rax),%rdi
mov    (%r14),%rdx
lea    0xc47(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32* null
@.str = [26 x i8] c"Usage: %s output_heading\0A\00"
@stdin = global i32 0
@.str.1 = [22 x i8] c"statistics.e 0 0 '' 2\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [8 x i8] c"%s: %s\0A\00"
@stdout = global i32* null
@.str.4 = [4 x i8] c"%s\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 [1024 x i8]
%8 = alloca [1024 x i8]
%9 = alloca [1024 x i8]
%10 = alloca i32
%11 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %10
store i32* null, i32** %11
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 2
br i1 %13, label %14, label %21
14: ; preds = %2
%15 = load i32*, i32** @stderr
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 @fprintf(i32* %15, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %2
br label %22
22: ; preds = %76, %21
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%24 = load i32, i32* @stdin
%25 = call i64 @get_line(i8* %23, i32 %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %77
27: ; preds = %22
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%30 = call i64 @piece(i8* %28, i8 signext 124, i8* %29, i32 0)
%31 = load i32, i32* %10
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %45
33: ; preds = %27
%34 = call i32* @popen(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %34, i32** %11
%35 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%36 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%37 = call i32 @strcpy(i8* %35, i8* %36)
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 1
%40 = load i8*, i8** %39
%41 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%42 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %40, i8* %41)
%43 = load i32*, i32** @stdout
%44 = call i32 @fflush(i32* %43)
store i32 0, i32* %10
br label %65
45: ; preds = %27
%46 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%47 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%48 = call i64 @strcmp(i8* %46, i8* %47)
%49 = icmp ne i64 %48, 0
br i1 %49, label %50, label %64
50: ; preds = %45
%51 = load i32*, i32** %11
%52 = call i32 @pclose(i32* %51)
%53 = call i32* @popen(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %53, i32** %11
%54 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%55 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%56 = call i32 @strcpy(i8* %54, i8* %55)
%57 = load i8**, i8*** %5
%58 = getelementptr inbounds i8*, i8** %57, i64 1
%59 = load i8*, i8** %58
%60 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%61 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %59, i8* %60)
%62 = load i32*, i32** @stdout
%63 = call i32 @fflush(i32* %62)
br label %64
64: ; preds = %50, %45
br label %65
65: ; preds = %64, %33
%66 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%67 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%68 = call i64 @piece(i8* %66, i8 signext 124, i8* %67, i32 1)
%69 = icmp ne i64 %68, 0
br i1 %69, label %70, label %76
70: ; preds = %65
%71 = load i32*, i32** %11
%72 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%73 = call i32 @fprintf(i32* %71, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %72)
%74 = load i32*, i32** %11
%75 = call i32 @fflush(i32* %74)
br label %76
76: ; preds = %70, %65
br label %22
77: ; preds = %22
%78 = load i32*, i32** %11
%79 = icmp ne i32* %78, null
br i1 %79, label %80, label %83
80: ; preds = %77
%81 = load i32*, i32** %11
%82 = call i32 @pclose(i32* %81)
br label %83
83: ; preds = %80, %77
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32* null
@.str = [26 x i8] c"Usage: %s output_heading\0A\00"
@stdin = global i32 0
@.str.1 = [22 x i8] c"statistics.e 0 0 '' 2\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [8 x i8] c"%s: %s\0A\00"
@stdout = global i32* null
@.str.4 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = alloca [1024 x i8]
%6 = alloca [1024 x i8]
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%11 = icmp eq i32 %0, 2
br i1 %11, label %12, label %34
12: ; preds = %2
%13 = load i32, i32* @stdin
%14 = call i64 @get_line(i8* %7, i32 %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %68, label %16
16: ; preds = %12
%17 = getelementptr inbounds i8*, i8** %1, i64 1
%18 = call i64 @piece(i8* %8, i8 signext 124, i8* %7, i32 0)
%19 = call i32* @popen(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%20 = call i32 @strcpy(i8* %9, i8* %8)
%21 = load i8*, i8** %17
%22 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %21, i8* %9)
%23 = load i32*, i32** @stdout
%24 = call i32 @fflush(i32* %23)
%25 = call i64 @piece(i8* %10, i8 signext 124, i8* %7, i32 1)
%26 = icmp eq i64 %25, 0
br i1 %26, label %30, label %27
27: ; preds = %16
%28 = call i32 @fprintf(i32* %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %10)
%29 = call i32 @fflush(i32* %19)
br label %30
30: ; preds = %27, %16
%31 = load i32, i32* @stdin
%32 = call i64 @get_line(i8* %7, i32 %31)
%33 = icmp eq i64 %32, 0
br i1 %33, label %63, label %39
34: ; preds = %2
%35 = load i32*, i32** @stderr
%36 = load i8*, i8** %1
%37 = tail call i32 @fprintf(i32* %35, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %36)
%38 = tail call i32 @exit(i32 1)
unreachable
39: ; preds = %30, %59
%40 = phi i32* [ %53, %59 ], [ %19, %30 ]
%41 = call i64 @piece(i8* %8, i8 signext 124, i8* %7, i32 0)
%42 = call i64 @strcmp(i8* %9, i8* %8)
%43 = icmp eq i64 %42, 0
br i1 %43, label %52, label %44
44: ; preds = %39
%45 = call i32 @pclose(i32* %40)
%46 = call i32* @popen(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%47 = call i32 @strcpy(i8* %9, i8* %8)
%48 = load i8*, i8** %17
%49 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %48, i8* %9)
%50 = load i32*, i32** @stdout
%51 = call i32 @fflush(i32* %50)
br label %52
52: ; preds = %39, %44
%53 = phi i32* [ %46, %44 ], [ %40, %39 ]
%54 = call i64 @piece(i8* %10, i8 signext 124, i8* %7, i32 1)
%55 = icmp eq i64 %54, 0
br i1 %55, label %59, label %56
56: ; preds = %52
%57 = call i32 @fprintf(i32* %53, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %10)
%58 = call i32 @fflush(i32* %53)
br label %59
59: ; preds = %56, %52
%60 = load i32, i32* @stdin
%61 = call i64 @get_line(i8* %7, i32 %60)
%62 = icmp eq i64 %61, 0
br i1 %62, label %63, label %39
63: ; preds = %59, %30
%64 = phi i32* [ %19, %30 ], [ %53, %59 ]
%65 = icmp eq i32* %64, null
br i1 %65, label %68, label %66
66: ; preds = %63
%67 = call i32 @pclose(i32* %64)
br label %68
68: ; preds = %12, %66, %63
ret i32 0
}