#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 printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ usleep(int);
void spin_roulette(long spin) {
  int n;
  puts("");
  printf("Roulette  :  ");
  int i, j;
  int s = 12500;
  for (i = 0; i < 128; i++) {
    n = printf("%d", (i % 36) + 1);
    usleep(s);
    for (j = 0; j < n; j++) {
      printf("\b \b");
    }
  }
  for (i = 128; i < (128 + 36); i++) {
    n = printf("%d", (i % 36) + 1);
    if (((i % 36) + 1) == spin) {
      for (j = 0; j < n; j++) {
        printf("\b \b");
      }
      break;
    }
    usleep(s);
    for (j = 0; j < n; j++) {
      printf("\b \b");
    }
  }
  for (int k = 0; k < 36; k++) {
    n = printf("%d", ((i + k) % 36) + 1);
    s = 1.1 * s;
    usleep(s);
    for (j = 0; j < n; j++) {
      printf("\b \b");
    }
  }
  printf("%ld", spin);
  usleep(s);
  puts("");
  puts("");
}


x86 assembly (clang, -O0):
<spin_roulette>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xed9(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x30d4,-0x18(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x80,-0x10(%rbp)
jge    11dc <spin_roulette+0xac>
mov    -0x10(%rbp),%eax
mov    $0x24,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
add    $0x1,%esi
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%edi
call   1050 <usleep@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11c9 <spin_roulette+0x99>
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a1 <spin_roulette+0x71>
jmp    11ce <spin_roulette+0x9e>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1164 <spin_roulette+0x34>
movl   $0x80,-0x10(%rbp)
cmpl   $0xa4,-0x10(%rbp)
jge    12aa <spin_roulette+0x17a>
mov    -0x10(%rbp),%eax
mov    $0x24,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
add    $0x1,%esi
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x24,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
movslq %edx,%rax
cmp    -0x8(%rbp),%rax
jne    1260 <spin_roulette+0x130>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    125b <spin_roulette+0x12b>
lea    0xdd3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1233 <spin_roulette+0x103>
jmp    12aa <spin_roulette+0x17a>
mov    -0x18(%rbp),%edi
call   1050 <usleep@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1297 <spin_roulette+0x167>
lea    0xd97(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    126f <spin_roulette+0x13f>
jmp    129c <spin_roulette+0x16c>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11e3 <spin_roulette+0xb3>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x24,-0x1c(%rbp)
jge    1341 <spin_roulette+0x211>
mov    -0x10(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    $0x24,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
add    $0x1,%esi
lea    0xd41(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    %eax,-0xc(%rbp)
cvtsi2sdl -0x18(%rbp),%xmm1
movsd  0xd14(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
call   1050 <usleep@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    132e <spin_roulette+0x1fe>
lea    0xd00(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1306 <spin_roulette+0x1d6>
jmp    1333 <spin_roulette+0x203>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    12b1 <spin_roulette+0x181>
mov    -0x8(%rbp),%rsi
lea    0xcd1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%edi
call   1050 <usleep@plt>
lea    0xcba(%rip),%rdi
call   1030 <puts@plt>
lea    0xcae(%rip),%rdi
call   1030 <puts@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<spin_roulette>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,(%rsp)
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xeb8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb8(%rip),%r15
lea    0xeb4(%rip),%rbp
xor    %r14d,%r14d
jmp    117d <spin_roulette+0x4d>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r14d
cmp    $0x80,%r14d
je     11c1 <spin_roulette+0x91>
movzbl %r14b,%eax
imul   $0x39,%eax,%ecx
shr    $0x9,%ecx
and    $0xfffffffc,%ecx
lea    (%rcx,%rcx,8),%ecx
sub    %cl,%al
add    $0x1,%al
movzbl %al,%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %eax,%ebx
mov    $0x30d4,%edi
call   1050 <usleep@plt>
test   %ebx,%ebx
jle    1170 <spin_roulette+0x40>
xchg   %ax,%ax
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0xffffffff,%ebx
jne    11b0 <spin_roulette+0x80>
jmp    1170 <spin_roulette+0x40>
mov    $0x80,%r13d
lea    0xe48(%rip),%r15
lea    0xe44(%rip),%rbp
mov    (%rsp),%r14
jmp    11ed <spin_roulette+0xbd>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r13d
cmp    $0xa4,%r13d
je     1241 <spin_roulette+0x111>
movzbl %r13b,%eax
imul   $0x39,%eax,%ecx
shr    $0x9,%ecx
and    $0xfffffffc,%ecx
lea    (%rcx,%rcx,8),%ecx
sub    %cl,%al
add    $0x1,%al
movzbl %al,%r12d
mov    %r15,%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %eax,%ebx
cmp    %r14,%r12
je     1249 <spin_roulette+0x119>
mov    $0x30d4,%edi
call   1050 <usleep@plt>
test   %ebx,%ebx
jle    11e0 <spin_roulette+0xb0>
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0xffffffff,%ebx
jne    1230 <spin_roulette+0x100>
jmp    11e0 <spin_roulette+0xb0>
mov    $0xa4,%r13d
jmp    126f <spin_roulette+0x13f>
test   %ebx,%ebx
jle    126f <spin_roulette+0x13f>
lea    0xdc5(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0xffffffff,%ebx
jne    1260 <spin_roulette+0x130>
mov    $0x30d4,%r12d
lea    0xd9a(%rip),%r15
lea    0xd96(%rip),%rbx
xor    %r14d,%r14d
jmp    129a <spin_roulette+0x16a>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r14d
cmp    $0x24,%r14d
je     1301 <spin_roulette+0x1d1>
lea    (%r14,%r13,1),%esi
imul   $0x38e38e39,%rsi,%rax
shr    $0x23,%rax
shl    $0x2,%eax
lea    (%rax,%rax,8),%eax
sub    %eax,%esi
add    $0x1,%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %r12d,%xmm0
mov    %eax,%ebp
mulsd  0xd30(%rip),%xmm0
cvttsd2si %xmm0,%r12d
mov    %r12d,%edi
call   1050 <usleep@plt>
test   %ebp,%ebp
jle    1290 <spin_roulette+0x160>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0xffffffff,%ebp
jne    12f0 <spin_roulette+0x1c0>
jmp    1290 <spin_roulette+0x160>
lea    0xd15(%rip),%rdi
mov    (%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12d,%edi
call   1050 <usleep@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [14 x i8] c"Roulette : \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [4 x i8] c"\08 \08\00"
@.str.4 = [4 x i8] c"%ld\00"
define void @spin_roulette(i64 %0) {
%2 = alloca i64
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i64 %0, i64* %2
%8 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
store i32 12500, i32* %6
store i32 0, i32* %4
br label %10
10: ; preds = %30, %1
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 128
br i1 %12, label %13, label %33
13: ; preds = %10
%14 = load i32, i32* %4
%15 = srem i32 %14, 36
%16 = add nsw i32 %15, 1
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %16)
store i32 %17, i32* %3
%18 = load i32, i32* %6
%19 = call i32 @usleep(i32 %18)
store i32 0, i32* %5
br label %20
20: ; preds = %26, %13
%21 = load i32, i32* %5
%22 = load i32, i32* %3
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %29
24: ; preds = %20
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %26
26: ; preds = %24
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 1
store i32 %28, i32* %5
br label %20
29: ; preds = %20
br label %30
30: ; preds = %29
%31 = load i32, i32* %4
%32 = add nsw i32 %31, 1
store i32 %32, i32* %4
br label %10
33: ; preds = %10
store i32 128, i32* %4
br label %34
34: ; preds = %72, %33
%35 = load i32, i32* %4
%36 = icmp slt i32 %35, 164
br i1 %36, label %37, label %75
37: ; preds = %34
%38 = load i32, i32* %4
%39 = srem i32 %38, 36
%40 = add nsw i32 %39, 1
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %40)
store i32 %41, i32* %3
%42 = load i32, i32* %4
%43 = srem i32 %42, 36
%44 = add nsw i32 %43, 1
%45 = sext i32 %44 to i64
%46 = load i64, i64* %2
%47 = icmp eq i64 %45, %46
br i1 %47, label %48, label %59
48: ; preds = %37
store i32 0, i32* %5
br label %49
49: ; preds = %55, %48
%50 = load i32, i32* %5
%51 = load i32, i32* %3
%52 = icmp slt i32 %50, %51
br i1 %52, label %53, label %58
53: ; preds = %49
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %55
55: ; preds = %53
%56 = load i32, i32* %5
%57 = add nsw i32 %56, 1
store i32 %57, i32* %5
br label %49
58: ; preds = %49
br label %75
59: ; preds = %37
%60 = load i32, i32* %6
%61 = call i32 @usleep(i32 %60)
store i32 0, i32* %5
br label %62
62: ; preds = %68, %59
%63 = load i32, i32* %5
%64 = load i32, i32* %3
%65 = icmp slt i32 %63, %64
br i1 %65, label %66, label %71
66: ; preds = %62
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %68
68: ; preds = %66
%69 = load i32, i32* %5
%70 = add nsw i32 %69, 1
store i32 %70, i32* %5
br label %62
71: ; preds = %62
br label %72
72: ; preds = %71
%73 = load i32, i32* %4
%74 = add nsw i32 %73, 1
store i32 %74, i32* %4
br label %34
75: ; preds = %58, %34
store i32 0, i32* %7
br label %76
76: ; preds = %102, %75
%77 = load i32, i32* %7
%78 = icmp slt i32 %77, 36
br i1 %78, label %79, label %105
79: ; preds = %76
%80 = load i32, i32* %4
%81 = load i32, i32* %7
%82 = add nsw i32 %80, %81
%83 = srem i32 %82, 36
%84 = add nsw i32 %83, 1
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %84)
store i32 %85, i32* %3
%86 = load i32, i32* %6
%87 = sitofp i32 %86 to double
%88 = fmul double 1.100000e+00, %87
%89 = fptosi double %88 to i32
store i32 %89, i32* %6
%90 = load i32, i32* %6
%91 = call i32 @usleep(i32 %90)
store i32 0, i32* %5
br label %92
92: ; preds = %98, %79
%93 = load i32, i32* %5
%94 = load i32, i32* %3
%95 = icmp slt i32 %93, %94
br i1 %95, label %96, label %101
96: ; preds = %92
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %98
98: ; preds = %96
%99 = load i32, i32* %5
%100 = add nsw i32 %99, 1
store i32 %100, i32* %5
br label %92
101: ; preds = %92
br label %102
102: ; preds = %101
%103 = load i32, i32* %7
%104 = add nsw i32 %103, 1
store i32 %104, i32* %7
br label %76
105: ; preds = %76
%106 = load i64, i64* %2
%107 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i64 %106)
%108 = load i32, i32* %6
%109 = call i32 @usleep(i32 %108)
%110 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%111 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.1 = [14 x i8] c"Roulette : \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [4 x i8] c"\08 \08\00"
@.str.4 = [4 x i8] c"%ld\00"
define void @spin_roulette(i64 %0) {
%2 = tail call i32 @putchar(i32 10)
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %4
4: ; preds = %1, %18
%5 = phi i32 [ 0, %1 ], [ %19, %18 ]
%6 = trunc i32 %5 to i8
%7 = urem i8 %6, 36
%8 = add nuw nsw i8 %7, 1
%9 = zext i8 %8 to i32
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%11 = tail call i32 @usleep(i32 12500)
%12 = icmp sgt i32 %10, 0
br i1 %12, label %13, label %18
13: ; preds = %4, %13
%14 = phi i32 [ %16, %13 ], [ 0, %4 ]
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%16 = add nuw nsw i32 %14, 1
%17 = icmp eq i32 %16, %10
br i1 %17, label %18, label %13
18: ; preds = %13, %4
%19 = add nuw nsw i32 %5, 1
%20 = icmp eq i32 %19, 128
br i1 %20, label %21, label %4
21: ; preds = %18, %45
%22 = phi i32 [ %46, %45 ], [ 128, %18 ]
%23 = trunc i32 %22 to i8
%24 = urem i8 %23, 36
%25 = add nuw nsw i8 %24, 1
%26 = zext i8 %25 to i32
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %26)
%28 = zext i8 %25 to i64
%29 = icmp eq i64 %28, %0
br i1 %29, label %30, label %37
30: ; preds = %21
%31 = icmp sgt i32 %27, 0
br i1 %31, label %32, label %48
32: ; preds = %30, %32
%33 = phi i32 [ %35, %32 ], [ 0, %30 ]
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%35 = add nuw nsw i32 %33, 1
%36 = icmp eq i32 %35, %27
br i1 %36, label %48, label %32
37: ; preds = %21
%38 = tail call i32 @usleep(i32 12500)
%39 = icmp sgt i32 %27, 0
br i1 %39, label %40, label %45
40: ; preds = %37, %40
%41 = phi i32 [ %43, %40 ], [ 0, %37 ]
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%43 = add nuw nsw i32 %41, 1
%44 = icmp eq i32 %43, %27
br i1 %44, label %45, label %40
45: ; preds = %40, %37
%46 = add nuw nsw i32 %22, 1
%47 = icmp eq i32 %46, 164
br i1 %47, label %48, label %21
48: ; preds = %45, %32, %30
%49 = phi i32 [ %22, %30 ], [ %22, %32 ], [ 164, %45 ]
br label %55
50: ; preds = %72
%51 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i64 %0)
%52 = tail call i32 @usleep(i32 %64)
%53 = tail call i32 @putchar(i32 10)
%54 = tail call i32 @putchar(i32 10)
ret void
55: ; preds = %48, %72
%56 = phi i32 [ 0, %48 ], [ %73, %72 ]
%57 = phi i32 [ 12500, %48 ], [ %64, %72 ]
%58 = add nuw nsw i32 %56, %49
%59 = urem i32 %58, 36
%60 = add nuw nsw i32 %59, 1
%61 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %60)
%62 = sitofp i32 %57 to double
%63 = fmul double %62, 1.100000e+00
%64 = fptosi double %63 to i32
%65 = tail call i32 @usleep(i32 %64)
%66 = icmp sgt i32 %61, 0
br i1 %66, label %67, label %72
67: ; preds = %55, %67
%68 = phi i32 [ %70, %67 ], [ 0, %55 ]
%69 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%70 = add nuw nsw i32 %68, 1
%71 = icmp eq i32 %70, %61
br i1 %71, label %72, label %67
72: ; preds = %67, %55
%73 = add nuw nsw i32 %56, 1
%74 = icmp eq i32 %73, 36
br i1 %74, label %50, label %55
}