#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 *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stdout;
int main(void) {
  int i;
  printf("ABCDEFG");
  for (i = 0; i < 7; i++) {
    sleep(1000);
    printf("\b \b");
    fflush(stdout);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x7,-0x8(%rbp)
jge    118e <main+0x5e>
mov    $0x3e8,%edi
call   1050 <sleep@plt>
lea    0xe9b(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e67(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1152 <main+0x22>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xec5(%rip),%rdi
call   1030 <printf@plt>
mov    $0x3e8,%edi
call   1050 <sleep@plt>
lea    0xeb7(%rip),%rbx
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    0x2e80(%rip),%r14
mov    (%r14),%edi
call   1040 <fflush@plt>
mov    $0x3e8,%edi
call   1050 <sleep@plt>
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    (%r14),%edi
call   1040 <fflush@plt>
mov    $0x3e8,%edi
call   1050 <sleep@plt>
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    (%r14),%edi
call   1040 <fflush@plt>
mov    $0x3e8,%edi
call   1050 <sleep@plt>
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    (%r14),%edi
call   1040 <fflush@plt>
mov    $0x3e8,%edi
call   1050 <sleep@plt>
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    (%r14),%edi
call   1040 <fflush@plt>
mov    $0x3e8,%edi
call   1050 <sleep@plt>
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    (%r14),%edi
call   1040 <fflush@plt>
mov    $0x3e8,%edi
call   1050 <sleep@plt>
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    (%r14),%edi
call   1040 <fflush@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [8 x i8] c"ABCDEFG\00"
@.str.1 = [4 x i8] c"\08 \08\00"
@stdout = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
br label %4
4: ; preds = %12, %0
%5 = load i32, i32* %2
%6 = icmp slt i32 %5, 7
br i1 %6, label %7, label %15
7: ; preds = %4
%8 = call i32 @sleep(i32 1000)
%9 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%10 = load i32, i32* @stdout
%11 = call i32 @fflush(i32 %10)
br label %12
12: ; preds = %7
%13 = load i32, i32* %2
%14 = add nsw i32 %13, 1
store i32 %14, i32* %2
br label %4
15: ; preds = %4
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"ABCDEFG\00"
@.str.1 = [4 x i8] c"\08 \08\00"
@stdout = global i32 0
define i32 @main() {
%1 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @sleep(i32 1000)
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%4 = load i32, i32* @stdout
%5 = tail call i32 @fflush(i32 %4)
%6 = tail call i32 @sleep(i32 1000)
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%8 = load i32, i32* @stdout
%9 = tail call i32 @fflush(i32 %8)
%10 = tail call i32 @sleep(i32 1000)
%11 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%12 = load i32, i32* @stdout
%13 = tail call i32 @fflush(i32 %12)
%14 = tail call i32 @sleep(i32 1000)
%15 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%16 = load i32, i32* @stdout
%17 = tail call i32 @fflush(i32 %16)
%18 = tail call i32 @sleep(i32 1000)
%19 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%20 = load i32, i32* @stdout
%21 = tail call i32 @fflush(i32 %20)
%22 = tail call i32 @sleep(i32 1000)
%23 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%24 = load i32, i32* @stdout
%25 = tail call i32 @fflush(i32 %24)
%26 = tail call i32 @sleep(i32 1000)
%27 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%28 = load i32, i32* @stdout
%29 = tail call i32 @fflush(i32 %28)
ret i32 0
}