#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*/ putchar(char);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stdout;
int strlen(char *);
int main(void) {
  int i;
  int cnt = 0;
  char name[] = "BohYoh ";
  int name_len = strlen(name);
  while (1) {
    putchar('\r');
    for (i = 0; i < name_len; i++) {
      if (cnt + i < name_len)
        putchar(name[cnt + i]);
      else
        putchar(name[cnt + i - name_len]);
    }
    fflush(stdout);
    sleep(500);
    if (cnt > 0)
      cnt--;
    else
      cnt = name_len - 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
mov    0xea3(%rip),%rax
mov    %rax,-0x14(%rbp)
lea    -0x14(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x18(%rbp)
mov    $0xd,%edi
call   1030 <putchar@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11d8 <main+0x98>
mov    -0xc(%rbp),%eax
add    -0x8(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11b0 <main+0x70>
mov    -0xc(%rbp),%eax
add    -0x8(%rbp),%eax
cltq
movsbl -0x14(%rbp,%rax,1),%edi
call   1030 <putchar@plt>
jmp    11c5 <main+0x85>
mov    -0xc(%rbp),%eax
add    -0x8(%rbp),%eax
sub    -0x18(%rbp),%eax
cltq
movsbl -0x14(%rbp,%rax,1),%edi
call   1030 <putchar@plt>
jmp    11ca <main+0x8a>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    117e <main+0x3e>
mov    0x2e01(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    $0x1f4,%edi
call   1060 <sleep@plt>
cmpl   $0x0,-0xc(%rbp)
jle    1208 <main+0xc8>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1211 <main+0xd1>
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    116d <main+0x2d>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movabs $0x20686f59686f42,%rax
mov    %rax,(%rsp)
mov    %rsp,%rdi
call   1040 <strlen@plt>
mov    %eax,%r14d
movslq %eax,%rbx
mov    %ebx,%r12d
xor    %r13d,%r13d
jmp    1193 <main+0x53>
nop
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    $0x1f4,%edi
call   1060 <sleep@plt>
test   %r13d,%r13d
cmovle %r12d,%r13d
add    $0xffffffff,%r13d
mov    $0xd,%edi
call   1030 <putchar@plt>
test   %r14d,%r14d
jle    1170 <main+0x30>
movslq %r13d,%rbp
mov    %r12,%r15
nopl   0x0(%rax,%rax,1)
cmp    %rbx,%rbp
mov    $0x0,%eax
cmovge %rbx,%rax
neg    %rax
add    %rsp,%rax
movsbl 0x0(%rbp,%rax,1),%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
add    $0xffffffffffffffff,%r15
jne    11b0 <main+0x70>
jmp    1170 <main+0x30>

LLVM IR (-O0):
@__const.main.name = [8 x i8] c"BohYoh \00"
@stdout = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [8 x i8]
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
%6 = bitcast [8 x i8]* %4 to i8*
%7 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 0
%8 = call i32 @strlen(i8* %7)
store i32 %8, i32* %5
br label %9
9: ; preds = %0, %55
%10 = call i32 @putchar(i8 signext 13)
store i32 0, i32* %2
br label %11
11: ; preds = %40, %9
%12 = load i32, i32* %2
%13 = load i32, i32* %5
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %43
15: ; preds = %11
%16 = load i32, i32* %3
%17 = load i32, i32* %2
%18 = add nsw i32 %16, %17
%19 = load i32, i32* %5
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %29
21: ; preds = %15
%22 = load i32, i32* %3
%23 = load i32, i32* %2
%24 = add nsw i32 %22, %23
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 %25
%27 = load i8, i8* %26
%28 = call i32 @putchar(i8 signext %27)
br label %39
29: ; preds = %15
%30 = load i32, i32* %3
%31 = load i32, i32* %2
%32 = add nsw i32 %30, %31
%33 = load i32, i32* %5
%34 = sub nsw i32 %32, %33
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 %35
%37 = load i8, i8* %36
%38 = call i32 @putchar(i8 signext %37)
br label %39
39: ; preds = %29, %21
br label %40
40: ; preds = %39
%41 = load i32, i32* %2
%42 = add nsw i32 %41, 1
store i32 %42, i32* %2
br label %11
43: ; preds = %11
%44 = load i32, i32* @stdout
%45 = call i32 @fflush(i32 %44)
%46 = call i32 @sleep(i32 500)
%47 = load i32, i32* %3
%48 = icmp sgt i32 %47, 0
br i1 %48, label %49, label %52
49: ; preds = %43
%50 = load i32, i32* %3
%51 = add nsw i32 %50, -1
store i32 %51, i32* %3
br label %55
52: ; preds = %43
%53 = load i32, i32* %5
%54 = sub nsw i32 %53, 1
store i32 %54, i32* %3
br label %55
55: ; preds = %52, %49
br label %9
}

LLVM IR (-O2):
@stdout = global i32 0
define i32 @main() {
%1 = alloca i64
%2 = bitcast i64* %1 to [8 x i8]*
%3 = bitcast i64* %1 to i8*
store i64 9122026705416002, i64* %1
%4 = call i32 @strlen(i8* %3)
%5 = icmp sgt i32 %4, 0
%6 = sext i32 %4 to i64
%7 = zext i32 %4 to i64
br label %8
8: ; preds = %24, %0
%9 = phi i32 [ 0, %0 ], [ %30, %24 ]
%10 = call i32 @putchar(i8 signext 13)
br i1 %5, label %11, label %24
11: ; preds = %8
%12 = sext i32 %9 to i64
br label %13
13: ; preds = %11, %13
%14 = phi i64 [ 0, %11 ], [ %22, %13 ]
%15 = add nsw i64 %14, %12
%16 = icmp slt i64 %15, %6
%17 = select i1 %16, i64 0, i64 %6
%18 = sub nsw i64 %15, %17
%19 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = call i32 @putchar(i8 signext %20)
%22 = add nuw nsw i64 %14, 1
%23 = icmp eq i64 %22, %7
br i1 %23, label %24, label %13
24: ; preds = %13, %8
%25 = load i32, i32* @stdout
%26 = call i32 @fflush(i32 %25)
%27 = call i32 @sleep(i32 500)
%28 = icmp sgt i32 %9, 0
%29 = select i1 %28, i32 %9, i32 %4
%30 = add nsw i32 %29, -1
br label %8
}