#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 */
scalar_t__ RAND_MAX;
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ random();
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ usleep(int);
void travail() {
  for (;;) {
    printf("%s", random() > RAND_MAX >> 1 ? "." : "\b \b");
    fflush(stdout);
    usleep(100000);
  }
}


x86 assembly (clang, -O0):
<travail>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
jmp    114d <travail+0xd>
mov    $0x0,%al
call   1040 <random@plt>
mov    %rax,%rcx
mov    0x2e8a(%rip),%rax
mov    (%rax),%rdx
sar    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
lea    0xe95(%rip),%rsi
lea    0xe8c(%rip),%rax
cmp    %rdx,%rcx
cmovg  %rax,%rsi
mov    %rsi,-0x8(%rbp)
lea    0xe77(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e43(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    $0x186a0,%edi
call   1060 <usleep@plt>
jmp    114d <travail+0xd>

x86 assembly (clang, -O2):
<travail>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    0x2e98(%rip),%r14
lea    0xeac(%rip),%r15
lea    0xea7(%rip),%r12
lea    0xe9b(%rip),%r13
mov    0x2e6c(%rip),%rbx
jmp    1189 <travail+0x49>
xchg   %ax,%ax
mov    %r13,%rdi
call   1030 <printf@plt>
mov    (%rbx),%edi
call   1050 <fflush@plt>
mov    $0x186a0,%edi
call   1060 <usleep@plt>
xor    %eax,%eax
call   1040 <random@plt>
mov    (%r14),%rcx
sar    %rcx
mov    %r15,%rsi
cmp    %rcx,%rax
jg     1170 <travail+0x30>
mov    %r12,%rsi
jmp    1170 <travail+0x30>

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@RAND_MAX = global i64 0
@.str.1 = [2 x i8] c".\00"
@.str.2 = [4 x i8] c"\08 \08\00"
@stdout = global i32 0
define void @travail() {
br label %1
1: ; preds = %1, %0
%2 = call i64 (...) @random()
%3 = load i64, i64* @RAND_MAX
%4 = ashr i64 %3, 1
%5 = icmp sgt i64 %2, %4
%6 = zext i1 %5 to i64
%7 = select i1 %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0)
%8 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = load i32, i32* @stdout
%10 = call i32 @fflush(i32 %9)
%11 = call i32 @usleep(i32 100000)
br label %1
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@RAND_MAX = global i64 0
@.str.1 = [2 x i8] c".\00"
@.str.2 = [4 x i8] c"\08 \08\00"
@stdout = global i32 0
define void @travail() {
br label %1
1: ; preds = %1, %0
%2 = tail call i64 (...) @random()
%3 = load i64, i64* @RAND_MAX
%4 = ashr i64 %3, 1
%5 = icmp sgt i64 %2, %4
%6 = select i1 %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0)
%7 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = load i32, i32* @stdout
%9 = tail call i32 @fflush(i32 %8)
%10 = tail call i32 @usleep(i32 100000)
br label %1
}