#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 /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *, int, int);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stdout;
int main() {
  char *esc = "\x1b[A\r\x1b[K";
  int i, j;
  putchar('\n');
  for (i = 0; i < 10; i++) {
    for (j = 0; j < 10; j++) {
      printf("%smain: %d/9\nsub:  %d/9\r", esc, i, j);
      fflush(stdout);
      sleep(1);
    }
  }
  putchar('\n');
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    $0xa,%edi
call   1030 <putchar@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    11d5 <main+0x95>
movl   $0x0,-0x18(%rbp)
cmpl   $0xa,-0x18(%rbp)
jge    11c2 <main+0x82>
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xe71(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e3d(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    117c <main+0x3c>
jmp    11c7 <main+0x87>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116b <main+0x2b>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %ebx,%ebx
lea    0xead(%rip),%r14
lea    0xe9e(%rip),%r15
mov    0x2e77(%rip),%r12
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
xor    %ecx,%ecx
call   1040 <printf@plt>
mov    (%r12),%edi
call   1050 <fflush@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
mov    $0x1,%ecx
call   1040 <printf@plt>
mov    (%r12),%edi
call   1050 <fflush@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
mov    $0x2,%ecx
call   1040 <printf@plt>
mov    (%r12),%edi
call   1050 <fflush@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
mov    $0x3,%ecx
call   1040 <printf@plt>
mov    (%r12),%edi
call   1050 <fflush@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
mov    $0x4,%ecx
call   1040 <printf@plt>
mov    (%r12),%edi
call   1050 <fflush@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
mov    $0x5,%ecx
call   1040 <printf@plt>
mov    (%r12),%edi
call   1050 <fflush@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
mov    $0x6,%ecx
call   1040 <printf@plt>
mov    (%r12),%edi
call   1050 <fflush@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
mov    $0x7,%ecx
call   1040 <printf@plt>
mov    (%r12),%edi
call   1050 <fflush@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
mov    $0x8,%ecx
call   1040 <printf@plt>
mov    (%r12),%edi
call   1050 <fflush@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
mov    $0x9,%ecx
call   1040 <printf@plt>
mov    (%r12),%edi
call   1050 <fflush@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
add    $0x1,%ebx
cmp    $0xa,%ebx
jne    1170 <main+0x30>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [8 x i8] c"\1B[A\0D\1B[K\00"
@.str.1 = [25 x i8] c"%smain: %d/9\0Asub: %d/9\0D\00"
@stdout = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %2
%5 = call i32 @putchar(i8 signext 10)
store i32 0, i32* %3
br label %6
6: ; preds = %25, %0
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 10
br i1 %8, label %9, label %28
9: ; preds = %6
store i32 0, i32* %4
br label %10
10: ; preds = %21, %9
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 10
br i1 %12, label %13, label %24
13: ; preds = %10
%14 = load i8*, i8** %2
%15 = load i32, i32* %3
%16 = load i32, i32* %4
%17 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %14, i32 %15, i32 %16)
%18 = load i32, i32* @stdout
%19 = call i32 @fflush(i32 %18)
%20 = call i32 @sleep(i32 1)
br label %21
21: ; preds = %13
%22 = load i32, i32* %4
%23 = add nsw i32 %22, 1
store i32 %23, i32* %4
br label %10
24: ; preds = %10
br label %25
25: ; preds = %24
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 1
store i32 %27, i32* %3
br label %6
28: ; preds = %6
%29 = call i32 @putchar(i8 signext 10)
%30 = load i32, i32* %1
ret i32 %30
}

LLVM IR (-O2):
@.str = [8 x i8] c"\1B[A\0D\1B[K\00"
@.str.1 = [25 x i8] c"%smain: %d/9\0Asub: %d/9\0D\00"
@stdout = global i32 0
define i32 @main() {
%1 = tail call i32 @putchar(i8 signext 10)
br label %2
2: ; preds = %0, %2
%3 = phi i32 [ 0, %0 ], [ %44, %2 ]
%4 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %3, i32 0)
%5 = load i32, i32* @stdout
%6 = tail call i32 @fflush(i32 %5)
%7 = tail call i32 @sleep(i32 1)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %3, i32 1)
%9 = load i32, i32* @stdout
%10 = tail call i32 @fflush(i32 %9)
%11 = tail call i32 @sleep(i32 1)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %3, i32 2)
%13 = load i32, i32* @stdout
%14 = tail call i32 @fflush(i32 %13)
%15 = tail call i32 @sleep(i32 1)
%16 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %3, i32 3)
%17 = load i32, i32* @stdout
%18 = tail call i32 @fflush(i32 %17)
%19 = tail call i32 @sleep(i32 1)
%20 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %3, i32 4)
%21 = load i32, i32* @stdout
%22 = tail call i32 @fflush(i32 %21)
%23 = tail call i32 @sleep(i32 1)
%24 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %3, i32 5)
%25 = load i32, i32* @stdout
%26 = tail call i32 @fflush(i32 %25)
%27 = tail call i32 @sleep(i32 1)
%28 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %3, i32 6)
%29 = load i32, i32* @stdout
%30 = tail call i32 @fflush(i32 %29)
%31 = tail call i32 @sleep(i32 1)
%32 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %3, i32 7)
%33 = load i32, i32* @stdout
%34 = tail call i32 @fflush(i32 %33)
%35 = tail call i32 @sleep(i32 1)
%36 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %3, i32 8)
%37 = load i32, i32* @stdout
%38 = tail call i32 @fflush(i32 %37)
%39 = tail call i32 @sleep(i32 1)
%40 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %3, i32 9)
%41 = load i32, i32* @stdout
%42 = tail call i32 @fflush(i32 %41)
%43 = tail call i32 @sleep(i32 1)
%44 = add nuw nsw i32 %3, 1
%45 = icmp eq i32 %44, 10
br i1 %45, label %46, label %2
46: ; preds = %2
%47 = tail call i32 @putchar(i8 signext 10)
ret i32 0
}