#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);
int /*<<< orphan*/ stdout;
void Spinner(int i) {
  switch (i % 4) {
  case 1:
    printf("%c", '-');
    break;
  case 2:
    printf("%c", '/');
    break;
  case 3:
    printf("%c", '|');
    break;
  case 0:
    printf("%c", '\\');
    break;
  }
  printf("%c", 0x08);
  fflush(stdout);
}


x86 assembly (clang, -O0):
<Spinner>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,%edx
add    $0x3,%edx
test   %eax,%eax
mov    %eax,%ecx
cmovs  %edx,%ecx
and    $0xfffffffc,%ecx
sub    %ecx,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x3,%eax
ja     11b5 <Spinner+0x95>
mov    -0x10(%rbp),%rax
lea    0xea7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xea7(%rip),%rdi
mov    $0x2d,%esi
call   1030 <printf@plt>
jmp    11b5 <Spinner+0x95>
lea    0xe91(%rip),%rdi
mov    $0x2f,%esi
call   1030 <printf@plt>
jmp    11b5 <Spinner+0x95>
lea    0xe7b(%rip),%rdi
mov    $0x7c,%esi
call   1030 <printf@plt>
jmp    11b5 <Spinner+0x95>
lea    0xe65(%rip),%rdi
mov    $0x5c,%esi
call   1030 <printf@plt>
lea    0xe54(%rip),%rdi
mov    $0x8,%esi
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
lea    0x3(%rdi),%eax
test   %edi,%edi
cmovns %edi,%eax
and    $0xfffffffc,%eax
sub    %eax,%edi
cmp    $0x3,%edi
ja     114c <Spinner+0x2c>
movslq %edi,%rax
lea    0xec7(%rip),%rcx
mov    (%rcx,%rax,4),%esi
lea    0xeb9(%rip),%rdi
call   1030 <printf@plt>
lea    0xead(%rip),%rdi
mov    $0x8,%esi
call   1030 <printf@plt>
mov    0x2e7c(%rip),%rax
mov    (%rax),%edi
pop    %rax
jmp    1040 <fflush@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
@stdout = global i32 0
define void @Spinner(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = srem i32 %3, 4
switch i32 %4, label %13 [
i32 1, label %5
i32 2, label %7
i32 3, label %9
i32 0, label %11
]
5: ; preds = %1
%6 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 45)
br label %13
7: ; preds = %1
%8 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 47)
br label %13
9: ; preds = %1
%10 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 124)
br label %13
11: ; preds = %1
%12 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 92)
br label %13
13: ; preds = %1, %11, %9, %7, %5
%14 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 8)
%15 = load i32, i32* @stdout
%16 = call i32 @fflush(i32 %15)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
@stdout = global i32 0
@switch.table.Spinner = [4 x i32] [i32 92, i32 45, i32 47, i32 124]
define void @Spinner(i32 %0) {
%2 = srem i32 %0, 4
%3 = icmp ult i32 %2, 4
br i1 %3, label %4, label %9
4: ; preds = %1
%5 = sext i32 %2 to i64
%6 = getelementptr inbounds [4 x i32], [4 x i32]* @switch.table.Spinner, i64 0, i64 %5
%7 = load i32, i32* %6
%8 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %7)
br label %9
9: ; preds = %1, %4
%10 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 8)
%11 = load i32, i32* @stdout
%12 = tail call i32 @fflush(i32 %11)
ret void
}