#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*/ STDOUT_FILENO;
int strlen(char const *);
int /*<<< orphan*/ usleep(int);
int /*<<< orphan*/ write(int /*<<< orphan*/, char const *, int);
void travail() {
  const char msg[] = "-\\|/";
  const int sz = strlen(msg);
  int i = 0;
  for (;;) {
    write(STDOUT_FILENO, "\r", 1);
    usleep(100000);
    write(STDOUT_FILENO, " => ", 4);
    write(STDOUT_FILENO, &msg[i++], 1);
    if (i == sz)
      i = 0;
  }
}


x86 assembly (clang, -O0):
<travail>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0xec2(%rip),%eax
mov    %eax,-0x5(%rbp)
mov    0xebd(%rip),%al
mov    %al,-0x1(%rbp)
lea    -0x5(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    0x2e8c(%rip),%rax
mov    (%rax),%edi
lea    0xe98(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x186a0,%edi
call   1050 <usleep@plt>
mov    0x2e68(%rip),%rax
mov    (%rax),%edi
lea    0xe76(%rip),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x10(%rbp)
cltq
lea    -0x5(%rbp),%rsi
add    %rax,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    11d5 <travail+0xa5>
movl   $0x0,-0x10(%rbp)
jmp    115d <travail+0x2d>

x86 assembly (clang, -O2):
<travail>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movb   $0x0,0x4(%rsp)
movl   $0x2f7c5c2d,(%rsp)
mov    %rsp,%rdi
call   1040 <strlen@plt>
mov    %eax,%r13d
xor    %r12d,%r12d
mov    0x2e94(%rip),%rbp
lea    0xea2(%rip),%r14
lea    0xe9d(%rip),%r15
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    0x0(%rbp),%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x186a0,%edi
call   1050 <usleep@plt>
mov    0x0(%rbp),%edi
mov    %r15,%rsi
mov    $0x4,%edx
call   1030 <write@plt>
mov    0x0(%rbp),%edi
movslq %ebx,%rax
add    $0x1,%ebx
lea    (%rsp,%rax,1),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
cmp    %r13d,%ebx
cmove  %r12d,%ebx
jmp    1170 <travail+0x40>

LLVM IR (-O0):
@__const.travail.msg = [5 x i8] c"-\\|/\00"
@STDOUT_FILENO = global i32 0
@.str = [2 x i8] c"\0D\00"
@.str.1 = [5 x i8] c" => \00"
define void @travail() {
%1 = alloca [5 x i8]
%2 = alloca i32
%3 = alloca i32
%4 = bitcast [5 x i8]* %1 to i8*
%5 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%6 = call i32 @strlen(i8* %5)
store i32 %6, i32* %2
store i32 0, i32* %3
br label %7
7: ; preds = %23, %0
%8 = load i32, i32* @STDOUT_FILENO
%9 = call i32 @write(i32 %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%10 = call i32 @usleep(i32 100000)
%11 = load i32, i32* @STDOUT_FILENO
%12 = call i32 @write(i32 %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%13 = load i32, i32* @STDOUT_FILENO
%14 = load i32, i32* %3
%15 = add nsw i32 %14, 1
store i32 %15, i32* %3
%16 = sext i32 %14 to i64
%17 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 %16
%18 = call i32 @write(i32 %13, i8* %17, i32 1)
%19 = load i32, i32* %3
%20 = load i32, i32* %2
%21 = icmp eq i32 %19, %20
br i1 %21, label %22, label %23
22: ; preds = %7
store i32 0, i32* %3
br label %23
23: ; preds = %22, %7
br label %7
}

LLVM IR (-O2):
@__const.travail.msg = [5 x i8] c"-\\|/\00"
@STDOUT_FILENO = global i32 0
@.str = [2 x i8] c"\0D\00"
@.str.1 = [5 x i8] c" => \00"
define void @travail() {
%1 = alloca [5 x i8]
%2 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%3 = call i32 @strlen(i8* %2)
br label %4
4: ; preds = %4, %0
%5 = phi i32 [ 0, %0 ], [ %17, %4 ]
%6 = load i32, i32* @STDOUT_FILENO
%7 = call i32 @write(i32 %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%8 = call i32 @usleep(i32 100000)
%9 = load i32, i32* @STDOUT_FILENO
%10 = call i32 @write(i32 %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%11 = load i32, i32* @STDOUT_FILENO
%12 = add nsw i32 %5, 1
%13 = sext i32 %5 to i64
%14 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 %13
%15 = call i32 @write(i32 %11, i8* %14, i32 1)
%16 = icmp eq i32 %12, %3
%17 = select i1 %16, i32 0, i32 %12
br label %4
}