#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 /*<<< orphan*/ stderr;
void spinner(int n) {
  char *s = "|/-\\";
  if (n % 4)
    return;
  n /= 4;
  fprintf(stderr, "\010\010\010\010\010\010\010\010\010\010\010\010\010");
  fprintf(stderr, "%c %d", s[n % 4], n);
  fflush(stderr);
}


x86 assembly (clang, -O0):
<spinner>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
lea    0xece(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     114f <spinner+0x2f>
jmp    11ba <spinner+0x9a>
mov    -0x4(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
mov    0x2e7c(%rip),%rax
mov    (%rax),%edi
lea    0xe98(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    -0x18(%rbp),%rax
movslq %edx,%rcx
movsbl (%rax,%rcx,1),%edx
mov    -0x4(%rbp),%ecx
lea    0xe6e(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e2d(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<spinner>:
test   $0x3,%dil
je     1127 <spinner+0x7>
ret
push   %r14
push   %rbx
push   %rax
lea    0x3(%rdi),%ebx
test   %edi,%edi
cmovns %edi,%ebx
sar    $0x2,%ebx
mov    0x2ea3(%rip),%r14
mov    (%r14),%edi
lea    0xebe(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%r14),%edi
lea    0x3(%rbx),%eax
test   %ebx,%ebx
cmovns %ebx,%eax
and    $0xfffffffc,%eax
mov    %ebx,%ecx
sub    %eax,%ecx
movslq %ecx,%rax
lea    0xe96(%rip),%rcx
movsbl (%rax,%rcx,1),%edx
lea    0xe9e(%rip),%rsi
mov    %ebx,%ecx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%r14),%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <fflush@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"|/-\\\00"
@stderr = global i32 0
@.str.1 = [14 x i8] c"\08\08\08\08\08\08\08\08\08\08\08\08\08\00"
@.str.2 = [6 x i8] c"%c %d\00"
define void @spinner(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
store i32 %0, i32* %2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %3
%4 = load i32, i32* %2
%5 = srem i32 %4, 4
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %1
br label %25
8: ; preds = %1
%9 = load i32, i32* %2
%10 = sdiv i32 %9, 4
store i32 %10, i32* %2
%11 = load i32, i32* @stderr
%12 = call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%13 = load i32, i32* @stderr
%14 = load i8*, i8** %3
%15 = load i32, i32* %2
%16 = srem i32 %15, 4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %14, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = load i32, i32* %2
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %20, i32 %21)
%23 = load i32, i32* @stderr
%24 = call i32 @fflush(i32 %23)
br label %25
25: ; preds = %8, %7
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"|/-\\\00"
@stderr = global i32 0
@.str.1 = [14 x i8] c"\08\08\08\08\08\08\08\08\08\08\08\08\08\00"
@.str.2 = [6 x i8] c"%c %d\00"
define void @spinner(i32 %0) {
%2 = and i32 %0, 3
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %17
4: ; preds = %1
%5 = sdiv i32 %0, 4
%6 = load i32, i32* @stderr
%7 = tail call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%8 = load i32, i32* @stderr
%9 = srem i32 %5, 4
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [5 x i8], [5 x i8]* @.str, i64 0, i64 %10
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = tail call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %13, i32 %5)
%15 = load i32, i32* @stderr
%16 = tail call i32 @fflush(i32 %15)
br label %17
17: ; preds = %1, %4
ret void
}