#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_tables = 0;
  printf("\n");
  while (getline(&line, &size, stdin) != -1) {
    if (!strncmp("Making a persistent hash table.", line, 31)) {
      num_tables += 1;
    } else {
      continue;
    }
    printf("\e[0K\r# num tables: %u          ", num_tables);
  }
  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)
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2e7d(%rip),%rax
mov    (%rax),%edx
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <getline@plt>
cmp    $0xffffffff,%eax
je     11ce <main+0x9e>
mov    -0x18(%rbp),%rsi
lea    0xe74(%rip),%rdi
mov    $0x1f,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    11b2 <main+0x82>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    11b7 <main+0x87>
jmp    1164 <main+0x34>
mov    -0x28(%rbp),%rsi
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1164 <main+0x34>
lea    0xe2b(%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    $0x18,%rsp
movq   $0x0,0x8(%rsp)
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x2e80(%rip),%rbp
lea    0x8(%rsp),%r14
lea    0x10(%rsp),%rbx
lea    0xe87(%rip),%r15
lea    0xea0(%rip),%r12
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x0(%rbp),%edx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <getline@plt>
cmp    $0xffffffff,%eax
je     11cc <main+0x8c>
mov    0x8(%rsp),%rsi
mov    %r15,%rdi
mov    $0x1f,%edx
call   1040 <strncmp@plt>
test   %eax,%eax
jne    1190 <main+0x50>
add    $0x1,%r13
mov    %r12,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1190 <main+0x50>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x18,%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 = [32 x i8] c"Making a persistent hash table.\00"
@.str.2 = [32 x i8] c"\1B[0K\0D# num tables: %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
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
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %22, %21, %2
%11 = load i32, i32* @stdin
%12 = call i32 @getline(i8** %6, i64* %7, i32 %11)
%13 = icmp ne i32 %12, -1
br i1 %13, label %14, label %25
14: ; preds = %10
%15 = load i8*, i8** %6
%16 = call i32 @strncmp(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %15, i32 31)
%17 = icmp ne i32 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %14
%19 = load i64, i64* %8
%20 = add i64 %19, 1
store i64 %20, i64* %8
br label %22
21: ; preds = %14
br label %10
22: ; preds = %18
%23 = load i64, i64* %8
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i64 %23)
br label %10
25: ; preds = %10
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
@stdin = global i32 0
@.str.1 = [32 x i8] c"Making a persistent hash table.\00"
@.str.2 = [32 x i8] c"\1B[0K\0D# num tables: %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 = %18, %2
%9 = phi i64 [ %19, %18 ], [ 0, %2 ]
br label %10
10: ; preds = %8, %14
%11 = load i32, i32* @stdin
%12 = call i32 @getline(i8** %3, i64* %4, i32 %11)
%13 = icmp eq i32 %12, -1
br i1 %13, label %21, label %14
14: ; preds = %10
%15 = load i8*, i8** %3
%16 = call i32 @strncmp(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %15, i32 31)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %10
18: ; preds = %14
%19 = add i64 %9, 1
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i64 %19)
br label %8
21: ; preds = %10
%22 = call i32 @putchar(i32 10)
ret i32 0
}