#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 < name_len - 1)
      cnt++;
    else
      cnt = 0;
  }
  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>
mov    -0xc(%rbp),%eax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    120f <main+0xcf>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1216 <main+0xd6>
movl   $0x0,-0xc(%rbp)
jmp    116d <main+0x2d>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movabs $0x20686f59686f42,%rax
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rdi
call   1040 <strlen@plt>
mov    %eax,%r14d
lea    -0x1(%r14),%ebp
movslq %eax,%rbx
mov    %ebx,%eax
mov    %rax,0x10(%rsp)
xor    %r12d,%r12d
jmp    11ab <main+0x6b>
nopl   (%rax)
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    $0x1f4,%edi
call   1060 <sleep@plt>
cmp    %ebp,%r12d
lea    0x1(%r12),%eax
mov    $0x0,%ecx
cmovge %ecx,%eax
mov    %eax,%r12d
mov    $0xd,%edi
call   1030 <putchar@plt>
test   %r14d,%r14d
jle    1180 <main+0x40>
movslq %r12d,%r13
mov    0x10(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    %rbx,%r13
mov    $0x0,%eax
cmovge %rbx,%rax
neg    %rax
add    %rsp,%rax
add    $0x8,%rax
movsbl 0x0(%r13,%rax,1),%edi
call   1030 <putchar@plt>
add    $0x1,%r13
add    $0xffffffffffffffff,%r15
jne    11d0 <main+0x90>
jmp    1180 <main+0x40>

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 = load i32, i32* %5
%49 = sub nsw i32 %48, 1
%50 = icmp slt i32 %47, %49
br i1 %50, label %51, label %54
51: ; preds = %43
%52 = load i32, i32* %3
%53 = add nsw i32 %52, 1
store i32 %53, i32* %3
br label %55
54: ; preds = %43
store i32 0, i32* %3
br label %55
55: ; preds = %54, %51
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 = add nsw i32 %4, -1
%7 = sext i32 %4 to i64
%8 = zext i32 %4 to i64
br label %9
9: ; preds = %25, %0
%10 = phi i32 [ 0, %0 ], [ %31, %25 ]
%11 = call i32 @putchar(i8 signext 13)
br i1 %5, label %12, label %25
12: ; preds = %9
%13 = sext i32 %10 to i64
br label %14
14: ; preds = %12, %14
%15 = phi i64 [ 0, %12 ], [ %23, %14 ]
%16 = add nsw i64 %15, %13
%17 = icmp slt i64 %16, %7
%18 = select i1 %17, i64 0, i64 %7
%19 = sub nsw i64 %16, %18
%20 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = call i32 @putchar(i8 signext %21)
%23 = add nuw nsw i64 %15, 1
%24 = icmp eq i64 %23, %8
br i1 %24, label %25, label %14
25: ; preds = %14, %9
%26 = load i32, i32* @stdout
%27 = call i32 @fflush(i32 %26)
%28 = call i32 @sleep(i32 500)
%29 = icmp slt i32 %10, %6
%30 = add nsw i32 %10, 1
%31 = select i1 %29, i32 %30, i32 0
br label %9
}