#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 const);
int /*<<< orphan*/ usleep(int);
void advance_progress_indicator(void) {
  static const char heartbeat[4] = {'-', '\\', '|', '/'};
  static const int total_heartbeat_chars = 4;
  static int cur_idx = 0;
  printf("%c\b", heartbeat[cur_idx++]);
  fflush(NULL);
  usleep(200000);
  if (cur_idx == total_heartbeat_chars)
    cur_idx = 0;
}


x86 assembly (clang, -O0):
<advance_progress_indicator>:
push   %rbp
mov    %rsp,%rbp
mov    0x2f02(%rip),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,0x2ef7(%rip)
movslq %eax,%rcx
lea    0xeb9(%rip),%rdi
lea    0xeaa(%rip),%rax
movsbl (%rax,%rcx,1),%esi
call   1030 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1040 <fflush@plt>
mov    $0x30d40,%edi
call   1050 <usleep@plt>
cmpl   $0x4,0x2ec3(%rip)
jne    1189 <advance_progress_indicator+0x59>
movl   $0x0,0x2eb3(%rip)
pop    %rbp
ret

x86 assembly (clang, -O2):
<advance_progress_indicator>:
push   %rax
movslq 0x2f04(%rip),%rax
lea    0x1(%rax),%ecx
mov    %ecx,0x2efb(%rip)
lea    0xeb8(%rip),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xeb1(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1040 <fflush@plt>
mov    $0x30d40,%edi
call   1050 <usleep@plt>
cmpl   $0x4,0x2ecc(%rip)
jne    117c <advance_progress_indicator+0x4c>
movl   $0x0,0x2ec0(%rip)
pop    %rax
ret

LLVM IR (-O0):
@advance_progress_indicator.heartbeat = internal constant [4 x i8] c"-\\|/"
@advance_progress_indicator.total_heartbeat_chars = internal constant i32 4
@advance_progress_indicator.cur_idx = internal global i32 0
@.str = [4 x i8] c"%c\08\00"
define void @advance_progress_indicator() {
%1 = load i32, i32* @advance_progress_indicator.cur_idx
%2 = add nsw i32 %1, 1
store i32 %2, i32* @advance_progress_indicator.cur_idx
%3 = sext i32 %1 to i64
%4 = getelementptr inbounds [4 x i8], [4 x i8]* @advance_progress_indicator.heartbeat, i64 0, i64 %3
%5 = load i8, i8* %4
%6 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %5)
%7 = call i32 @fflush(i32* null)
%8 = call i32 @usleep(i32 200000)
%9 = load i32, i32* @advance_progress_indicator.cur_idx
%10 = icmp eq i32 %9, 4
br i1 %10, label %11, label %12
11: ; preds = %0
store i32 0, i32* @advance_progress_indicator.cur_idx
br label %12
12: ; preds = %11, %0
ret void
}

LLVM IR (-O2):
@advance_progress_indicator.heartbeat = internal unnamed_addr constant [4 x i8] c"-\\|/"
@advance_progress_indicator.cur_idx = internal unnamed_addr global i32 0
@.str = [4 x i8] c"%c\08\00"
define void @advance_progress_indicator() {
%1 = load i32, i32* @advance_progress_indicator.cur_idx
%2 = add nsw i32 %1, 1
store i32 %2, i32* @advance_progress_indicator.cur_idx
%3 = sext i32 %1 to i64
%4 = getelementptr inbounds [4 x i8], [4 x i8]* @advance_progress_indicator.heartbeat, i64 0, i64 %3
%5 = load i8, i8* %4
%6 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %5)
%7 = tail call i32 @fflush(i32* null)
%8 = tail call i32 @usleep(i32 200000)
%9 = load i32, i32* @advance_progress_indicator.cur_idx
%10 = icmp eq i32 %9, 4
br i1 %10, label %11, label %12
11: ; preds = %0
store i32 0, i32* @advance_progress_indicator.cur_idx
br label %12
12: ; preds = %11, %0
ret void
}