#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*/ stdout;
void Spinner(void) {
  static int step;
  if (step < 3) {
    step++;
  } else {
    step = 0;
  }
  printf("\b");
  switch (step) {
  case 0:
    printf("-");
    break;
  case 1:
    printf("/");
    break;
  case 2:
    printf("|");
    break;
  case 3:
    printf("\\");
    break;
  }
  fflush(stdout);
}


x86 assembly (clang, -O0):
<Spinner>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
cmpl   $0x3,0x2f05(%rip)
jge    1149 <Spinner+0x29>
mov    0x2ef9(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2ef0(%rip)
jmp    1153 <Spinner+0x33>
movl   $0x0,0x2ee1(%rip)
lea    0xeb6(%rip),%rdi
call   1030 <printf@plt>
mov    0x2ecf(%rip),%eax
mov    %rax,-0x8(%rbp)
sub    $0x3,%rax
ja     11c6 <Spinner+0xa6>
mov    -0x8(%rbp),%rax
lea    0xe82(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe84(%rip),%rdi
call   1030 <printf@plt>
jmp    11c6 <Spinner+0xa6>
lea    0xe75(%rip),%rdi
call   1030 <printf@plt>
jmp    11c6 <Spinner+0xa6>
lea    0xe66(%rip),%rdi
call   1030 <printf@plt>
jmp    11c6 <Spinner+0xa6>
lea    0xe57(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e13(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Spinner>:
push   %rax
mov    0x2f0d(%rip),%eax
lea    0x1(%rax),%ecx
xor    %edx,%edx
cmp    $0x3,%eax
cmovl  %ecx,%edx
mov    %edx,0x2efc(%rip)
mov    $0x8,%edi
call   1030 <putchar@plt>
movslq 0x2eeb(%rip),%rax
cmp    $0x3,%rax
ja     115e <Spinner+0x3e>
lea    0xeaa(%rip),%rcx
mov    (%rcx,%rax,4),%edi
call   1030 <putchar@plt>
mov    0x2e7b(%rip),%rax
mov    (%rax),%edi
pop    %rax
jmp    1040 <fflush@plt>

LLVM IR (-O0):
@Spinner.step = internal global i32 0
@.str = [2 x i8] c"\08\00"
@.str.1 = [2 x i8] c"-\00"
@.str.2 = [2 x i8] c"/\00"
@.str.3 = [2 x i8] c"|\00"
@.str.4 = [2 x i8] c"\\\00"
@stdout = global i32 0
define void @Spinner() {
%1 = load i32, i32* @Spinner.step
%2 = icmp slt i32 %1, 3
br i1 %2, label %3, label %6
3: ; preds = %0
%4 = load i32, i32* @Spinner.step
%5 = add nsw i32 %4, 1
store i32 %5, i32* @Spinner.step
br label %7
6: ; preds = %0
store i32 0, i32* @Spinner.step
br label %7
7: ; preds = %6, %3
%8 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* @Spinner.step
switch i32 %9, label %18 [
i32 0, label %10
i32 1, label %12
i32 2, label %14
i32 3, label %16
]
10: ; preds = %7
%11 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %18
12: ; preds = %7
%13 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %18
14: ; preds = %7
%15 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %18
16: ; preds = %7
%17 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %18
18: ; preds = %7, %16, %14, %12, %10
%19 = load i32, i32* @stdout
%20 = call i32 @fflush(i32 %19)
ret void
}

LLVM IR (-O2):
@Spinner.step = internal unnamed_addr global i32 0
@stdout = global i32 0
@switch.table.Spinner = [4 x i32] [i32 45, i32 47, i32 124, i32 92]
define void @Spinner() {
%1 = load i32, i32* @Spinner.step
%2 = icmp slt i32 %1, 3
%3 = add nsw i32 %1, 1
%4 = select i1 %2, i32 %3, i32 0
store i32 %4, i32* @Spinner.step
%5 = tail call i32 @putchar(i32 8)
%6 = load i32, i32* @Spinner.step
%7 = icmp ult i32 %6, 4
br i1 %7, label %8, label %13
8: ; preds = %0
%9 = sext i32 %6 to i64
%10 = getelementptr inbounds [4 x i32], [4 x i32]* @switch.table.Spinner, i64 0, i64 %9
%11 = load i32, i32* %10
%12 = tail call i32 @putchar(i32 %11)
br label %13
13: ; preds = %0, %8
%14 = load i32, i32* @stdout
%15 = tail call i32 @fflush(i32 %14)
ret void
}