#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 *, unsigned long);
int /*<<< orphan*/ stdout;
void showbar(unsigned long received) {
  static int bar = 0;
  bar = received % 8;
  if (bar == 0 || bar == 4)
    printf(" %lu |\r", received);
  else if (bar == 1 || bar == 5)
    printf(" %lu /\r", received);
  else if (bar == 2 || bar == 6)
    printf(" %lu -\r", received);
  else
    printf(" %lu \\\r", received);
  fflush(stdout);
}


x86 assembly (clang, -O0):
<showbar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
and    $0x7,%rax
mov    %eax,0x2efa(%rip)
cmpl   $0x0,0x2ef3(%rip)
je     1154 <showbar+0x34>
cmpl   $0x4,0x2ee6(%rip)
jne    1169 <showbar+0x49>
mov    -0x8(%rbp),%rsi
lea    0xea1(%rip),%rdi
call   1030 <printf@plt>
jmp    11e1 <showbar+0xc1>
cmpl   $0x1,0x2ec4(%rip)
je     1183 <showbar+0x63>
cmpl   $0x5,0x2eb7(%rip)
jne    1198 <showbar+0x78>
mov    -0x8(%rbp),%rsi
lea    0xe7a(%rip),%rdi
call   1030 <printf@plt>
jmp    11dc <showbar+0xbc>
cmpl   $0x2,0x2e95(%rip)
je     11b2 <showbar+0x92>
cmpl   $0x6,0x2e88(%rip)
jne    11c7 <showbar+0xa7>
mov    -0x8(%rbp),%rsi
lea    0xe53(%rip),%rdi
call   1030 <printf@plt>
jmp    11d7 <showbar+0xb7>
mov    -0x8(%rbp),%rsi
lea    0xe46(%rip),%rdi
call   1030 <printf@plt>
jmp    11dc <showbar+0xbc>
jmp    11e1 <showbar+0xc1>
mov    0x2df8(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<showbar>:
push   %rax
mov    %rdi,%rsi
mov    %esi,%eax
and    $0x3,%eax
cmp    $0x3,%eax
jne    1137 <showbar+0x17>
lea    0xee3(%rip),%rdi
jmp    1147 <showbar+0x27>
mov    %eax,%eax
lea    0xee0(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
call   1030 <printf@plt>
mov    0x2e8d(%rip),%rax
mov    (%rax),%edi
pop    %rax
jmp    1040 <fflush@plt>

LLVM IR (-O0):
@showbar.bar = internal global i32 0
@.str = [8 x i8] c" %lu |\0D\00"
@.str.1 = [8 x i8] c" %lu /\0D\00"
@.str.2 = [8 x i8] c" %lu -\0D\00"
@.str.3 = [8 x i8] c" %lu \\\0D\00"
@stdout = global i32 0
define void @showbar(i64 %0) {
%2 = alloca i64
store i64 %0, i64* %2
%3 = load i64, i64* %2
%4 = urem i64 %3, 8
%5 = trunc i64 %4 to i32
store i32 %5, i32* @showbar.bar
%6 = load i32, i32* @showbar.bar
%7 = icmp eq i32 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %1
%9 = load i32, i32* @showbar.bar
%10 = icmp eq i32 %9, 4
br i1 %10, label %11, label %14
11: ; preds = %8, %1
%12 = load i64, i64* %2
%13 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64 %12)
br label %37
14: ; preds = %8
%15 = load i32, i32* @showbar.bar
%16 = icmp eq i32 %15, 1
br i1 %16, label %20, label %17
17: ; preds = %14
%18 = load i32, i32* @showbar.bar
%19 = icmp eq i32 %18, 5
br i1 %19, label %20, label %23
20: ; preds = %17, %14
%21 = load i64, i64* %2
%22 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i64 %21)
br label %36
23: ; preds = %17
%24 = load i32, i32* @showbar.bar
%25 = icmp eq i32 %24, 2
br i1 %25, label %29, label %26
26: ; preds = %23
%27 = load i32, i32* @showbar.bar
%28 = icmp eq i32 %27, 6
br i1 %28, label %29, label %32
29: ; preds = %26, %23
%30 = load i64, i64* %2
%31 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i64 %30)
br label %35
32: ; preds = %26
%33 = load i64, i64* %2
%34 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i64 %33)
br label %35
35: ; preds = %32, %29
br label %36
36: ; preds = %35, %20
br label %37
37: ; preds = %36, %11
%38 = load i32, i32* @stdout
%39 = call i32 @fflush(i32 %38)
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c" %lu |\0D\00"
@.str.1 = [8 x i8] c" %lu /\0D\00"
@.str.2 = [8 x i8] c" %lu -\0D\00"
@.str.3 = [8 x i8] c" %lu \\\0D\00"
@stdout = global i32 0
@reltable.showbar = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str to i64), i64 ptrtoint ([3 x i32]* @reltable.showbar to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.1 to i64), i64 ptrtoint ([3 x i32]* @reltable.showbar to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.2 to i64), i64 ptrtoint ([3 x i32]* @reltable.showbar to i64)) to i32)]
define void @showbar(i64 %0) {
%2 = trunc i64 %0 to i32
%3 = and i32 %2, 3
%4 = icmp eq i32 %3, 3
br i1 %4, label %9, label %5
5: ; preds = %1
%6 = zext i32 %3 to i64
%7 = shl i64 %6, 2
%8 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.showbar to i8*), i64 %7)
br label %9
9: ; preds = %1, %5
%10 = phi i8* [ %8, %5 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), %1 ]
%11 = tail call i32 @printf(i8* %10, i64 %0)
%12 = load i32, i32* @stdout
%13 = tail call i32 @fflush(i32 %12)
ret void
}