#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 getline(char **, size_t *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strncmp(char *, char *, int);
int main(int argc, char **argv) {
  char *line = NULL;
  size_t size;
  size_t num_svs = 0;
  size_t num_stems = 0;
  printf("\n");
  while (getline(&line, &size, stdin) != -1) {
    if (!strncmp("Making shadow value", line, 19)) {
      num_svs += 1;
    } else if (!strncmp("Cleaning up shadow value", line, 24)) {
      num_svs -= 1;
    } else if (!strncmp("Making stem node", line, 16)) {
      num_stems += 1;
    } else if (!strncmp("Cleaning up stem node", line, 20)) {
      num_stems -= 1;
    } else {
      continue;
    }
    printf("\e[0K\r# shadow values: %u      \t; # stems: %u      ", num_svs,
           num_stems);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2e75(%rip),%rax
mov    (%rax),%edx
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <getline@plt>
cmp    $0xffffffff,%eax
je     1276 <main+0x146>
mov    -0x18(%rbp),%rsi
lea    0xe6c(%rip),%rdi
mov    $0x13,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    11ba <main+0x8a>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    125b <main+0x12b>
mov    -0x18(%rbp),%rsi
lea    0xe51(%rip),%rdi
mov    $0x18,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    11e9 <main+0xb9>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1256 <main+0x126>
mov    -0x18(%rbp),%rsi
lea    0xe3b(%rip),%rdi
mov    $0x10,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1218 <main+0xe8>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1251 <main+0x121>
mov    -0x18(%rbp),%rsi
lea    0xe1d(%rip),%rdi
mov    $0x14,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1247 <main+0x117>
mov    -0x30(%rbp),%rax
sub    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    124c <main+0x11c>
jmp    116c <main+0x3c>
jmp    1251 <main+0x121>
jmp    1256 <main+0x126>
jmp    125b <main+0x12b>
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
lea    0xdec(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    116c <main+0x3c>
lea    0xd83(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
movq   $0x0,0x18(%rsp)
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x2e80(%rip),%r12
lea    0x18(%rsp),%r14
lea    0x20(%rsp),%rbx
lea    0xe87(%rip),%r15
lea    0xe94(%rip),%r13
lea    0xea6(%rip),%rbp
xor    %eax,%eax
mov    %rax,0x10(%rsp)
xor    %eax,%eax
mov    %rax,0x8(%rsp)
jmp    11c0 <main+0x80>
mov    0x8(%rsp),%rdx
add    $0xffffffffffffffff,%rdx
mov    0x10(%rsp),%rsi
lea    0xea8(%rip),%rdi
mov    %rsi,0x10(%rsp)
mov    %rdx,0x8(%rsp)
xor    %eax,%eax
call   1050 <printf@plt>
nopl   (%rax)
mov    (%r12),%edx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <getline@plt>
cmp    $0xffffffff,%eax
je     126d <main+0x12d>
mov    0x18(%rsp),%rsi
mov    %r15,%rdi
mov    $0x13,%edx
call   1040 <strncmp@plt>
test   %eax,%eax
je     1239 <main+0xf9>
mov    0x18(%rsp),%rsi
mov    %r13,%rdi
mov    $0x18,%edx
call   1040 <strncmp@plt>
test   %eax,%eax
je     124c <main+0x10c>
mov    0x18(%rsp),%rsi
mov    %rbp,%rdi
mov    $0x10,%edx
call   1040 <strncmp@plt>
test   %eax,%eax
je     125f <main+0x11f>
mov    0x18(%rsp),%rsi
lea    0xe18(%rip),%rdi
mov    $0x14,%edx
call   1040 <strncmp@plt>
test   %eax,%eax
jne    11c0 <main+0x80>
jmp    1197 <main+0x57>
mov    0x10(%rsp),%rsi
add    $0x1,%rsi
mov    0x8(%rsp),%rdx
jmp    11a5 <main+0x65>
mov    0x10(%rsp),%rsi
add    $0xffffffffffffffff,%rsi
mov    0x8(%rsp),%rdx
jmp    11a5 <main+0x65>
mov    0x8(%rsp),%rdx
add    $0x1,%rdx
jmp    11a0 <main+0x60>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@stdin = global i32 0
@.str.1 = [20 x i8] c"Making shadow value\00"
@.str.2 = [25 x i8] c"Cleaning up shadow value\00"
@.str.3 = [17 x i8] c"Making stem node\00"
@.str.4 = [22 x i8] c"Cleaning up stem node\00"
@.str.5 = [51 x i8] c"\1B[0K\0D# shadow values: %u \09; # stems: %u \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %6
store i64 0, i64* %8
store i64 0, i64* %9
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %47, %43, %2
%12 = load i32, i32* @stdin
%13 = call i32 @getline(i8** %6, i64* %7, i32 %12)
%14 = icmp ne i32 %13, -1
br i1 %14, label %15, label %51
15: ; preds = %11
%16 = load i8*, i8** %6
%17 = call i32 @strncmp(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %16, i32 19)
%18 = icmp ne i32 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %15
%20 = load i64, i64* %8
%21 = add i64 %20, 1
store i64 %21, i64* %8
br label %47
22: ; preds = %15
%23 = load i8*, i8** %6
%24 = call i32 @strncmp(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %23, i32 24)
%25 = icmp ne i32 %24, 0
br i1 %25, label %29, label %26
26: ; preds = %22
%27 = load i64, i64* %8
%28 = sub i64 %27, 1
store i64 %28, i64* %8
br label %46
29: ; preds = %22
%30 = load i8*, i8** %6
%31 = call i32 @strncmp(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* %30, i32 16)
%32 = icmp ne i32 %31, 0
br i1 %32, label %36, label %33
33: ; preds = %29
%34 = load i64, i64* %9
%35 = add i64 %34, 1
store i64 %35, i64* %9
br label %45
36: ; preds = %29
%37 = load i8*, i8** %6
%38 = call i32 @strncmp(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %37, i32 20)
%39 = icmp ne i32 %38, 0
br i1 %39, label %43, label %40
40: ; preds = %36
%41 = load i64, i64* %9
%42 = sub i64 %41, 1
store i64 %42, i64* %9
br label %44
43: ; preds = %36
br label %11
44: ; preds = %40
br label %45
45: ; preds = %44, %33
br label %46
46: ; preds = %45, %26
br label %47
47: ; preds = %46, %19
%48 = load i64, i64* %8
%49 = load i64, i64* %9
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.5, i64 0, i64 0), i64 %48, i64 %49)
br label %11
51: ; preds = %11
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%53 = load i32, i32* %3
ret i32 %53
}

LLVM IR (-O2):
@stdin = global i32 0
@.str.1 = [20 x i8] c"Making shadow value\00"
@.str.2 = [25 x i8] c"Cleaning up shadow value\00"
@.str.3 = [17 x i8] c"Making stem node\00"
@.str.4 = [22 x i8] c"Cleaning up stem node\00"
@.str.5 = [51 x i8] c"\1B[0K\0D# shadow values: %u \09; # stems: %u \00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%6 = bitcast i64* %4 to i8*
%7 = tail call i32 @putchar(i32 10)
br label %8
8: ; preds = %39, %2
%9 = phi i64 [ %40, %39 ], [ 0, %2 ]
%10 = phi i64 [ %41, %39 ], [ 0, %2 ]
br label %11
11: ; preds = %8, %33
%12 = load i32, i32* @stdin
%13 = call i32 @getline(i8** %3, i64* %4, i32 %12)
%14 = icmp eq i32 %13, -1
br i1 %14, label %43, label %15
15: ; preds = %11
%16 = load i8*, i8** %3
%17 = call i32 @strncmp(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %16, i32 19)
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = add i64 %9, 1
br label %39
21: ; preds = %15
%22 = load i8*, i8** %3
%23 = call i32 @strncmp(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %22, i32 24)
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = add i64 %9, -1
br label %39
27: ; preds = %21
%28 = load i8*, i8** %3
%29 = call i32 @strncmp(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* %28, i32 16)
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %27
%32 = add i64 %10, 1
br label %39
33: ; preds = %27
%34 = load i8*, i8** %3
%35 = call i32 @strncmp(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %34, i32 20)
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %11
37: ; preds = %33
%38 = add i64 %10, -1
br label %39
39: ; preds = %25, %37, %31, %19
%40 = phi i64 [ %9, %37 ], [ %9, %31 ], [ %26, %25 ], [ %20, %19 ]
%41 = phi i64 [ %38, %37 ], [ %32, %31 ], [ %10, %25 ], [ %10, %19 ]
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.5, i64 0, i64 0), i64 %40, i64 %41)
br label %8
43: ; preds = %11
%44 = call i32 @putchar(i32 10)
ret i32 0
}