#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*/ fprintf(int /*<<< orphan*/, char *, int, char const);
int /*<<< orphan*/ stdout;
int strlen(char const *);
void SpinSpinner(void) {
  static const char *spinner = "\\|/-";
  static int index;
  if (index > strlen(spinner))
    index = 0;
  fprintf(stdout, "%c[1D%c", 0x1b, spinner[index++]);
  fflush(stdout);
}


x86 assembly (clang, -O0):
<SpinSpinner>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2f06(%rip),%eax
mov    %eax,-0x4(%rbp)
mov    0x2ef0(%rip),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x4(%rbp),%eax
cmp    %ecx,%eax
jle    1164 <SpinSpinner+0x34>
movl   $0x0,0x2ee0(%rip)
mov    0x2e75(%rip),%rax
mov    (%rax),%edi
mov    0x2ec4(%rip),%rax
mov    0x2eca(%rip),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,0x2ebf(%rip)
movslq %ecx,%rcx
lea    0xe76(%rip),%rsi
mov    $0x1b,%edx
movsbl (%rax,%rcx,1),%ecx
call   1040 <fprintf@plt>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SpinSpinner>:
push   %rbp
push   %rbx
push   %rax
mov    0x2f03(%rip),%ebp
lea    0xec0(%rip),%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
xor    %ecx,%ecx
cmp    %eax,%ebp
jg     1154 <SpinSpinner+0x24>
mov    0x2ee8(%rip),%ecx
mov    0x2e85(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0x1(%rcx),%eax
mov    %eax,0x2ed5(%rip)
movslq %ecx,%rax
movsbl (%rax,%rbx,1),%ecx
lea    0xe90(%rip),%rsi
mov    $0x1b,%edx
call   1040 <fprintf@plt>
mov    0x0(%rbp),%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <fflush@plt>

LLVM IR (-O0):
@SpinSpinner.spinner = internal global i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0)
@.str = [5 x i8] c"\\|/-\00"
@SpinSpinner.index = internal global i32 0
@stdout = global i32 0
@.str.1 = [8 x i8] c"%c[1D%c\00"
define void @SpinSpinner() {
%1 = load i32, i32* @SpinSpinner.index
%2 = load i8*, i8** @SpinSpinner.spinner
%3 = call i32 @strlen(i8* %2)
%4 = icmp sgt i32 %1, %3
br i1 %4, label %5, label %6
5: ; preds = %0
store i32 0, i32* @SpinSpinner.index
br label %6
6: ; preds = %5, %0
%7 = load i32, i32* @stdout
%8 = load i8*, i8** @SpinSpinner.spinner
%9 = load i32, i32* @SpinSpinner.index
%10 = add nsw i32 %9, 1
store i32 %10, i32* @SpinSpinner.index
%11 = sext i32 %9 to i64
%12 = getelementptr inbounds i8, i8* %8, i64 %11
%13 = load i8, i8* %12
%14 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 27, i8 signext %13)
%15 = load i32, i32* @stdout
%16 = call i32 @fflush(i32 %15)
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"\\|/-\00"
@SpinSpinner.index = internal unnamed_addr global i32 0
@stdout = global i32 0
@.str.1 = [8 x i8] c"%c[1D%c\00"
define void @SpinSpinner() {
%1 = load i32, i32* @SpinSpinner.index
%2 = tail call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%3 = icmp sgt i32 %1, %2
%4 = load i32, i32* @SpinSpinner.index
%5 = select i1 %3, i32 0, i32 %4
%6 = load i32, i32* @stdout
%7 = add nsw i32 %5, 1
store i32 %7, i32* @SpinSpinner.index
%8 = sext i32 %5 to i64
%9 = getelementptr inbounds [5 x i8], [5 x i8]* @.str, i64 0, i64 %8
%10 = load i8, i8* %9
%11 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 27, i8 signext %10)
%12 = load i32, i32* @stdout
%13 = tail call i32 @fflush(i32 %12)
ret void
}