#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*/ printf(char *, ...);
void print_progress(double max, double value, char *title, char *action) {
  const double d = 30 / max;
  printf("\r%s: [", title);
  for (int i = 0; i < 30; i++) {
    if (i < (value * d))
      printf("=");
    else
      printf(" ");
  }
  printf("]: %s                ", action);
}


x86 assembly (clang, -O0):
<print_progress>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
movsd  0xece(%rip),%xmm0
divsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x1e,-0x2c(%rbp)
jge    11ac <print_progress+0x9c>
cvtsi2sdl -0x2c(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    118b <print_progress+0x7b>
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1199 <print_progress+0x89>
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    119e <print_progress+0x8e>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1155 <print_progress+0x45>
mov    -0x20(%rbp),%rsi
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_progress>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%rsi
movsd  %xmm1,0x8(%rsp)
movsd  0xec4(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
lea    0xec4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsd  (%rsp),%xmm0
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%rsp)
xorpd  %xmm1,%xmm1
mov    $0x1e,%ebp
mov    $0x3d,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  %xmm1,0x8(%rsp)
movsd  (%rsp),%xmm0
ucomisd %xmm1,%xmm0
mov    $0x20,%edi
cmova  %ebx,%edi
call   1030 <putchar@plt>
movsd  0x8(%rsp),%xmm1
addsd  0xe5e(%rip),%xmm1
add    $0xffffffff,%ebp
jne    1180 <print_progress+0x60>
lea    0xe61(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"\0D%s: [\00"
@.str.1 = [2 x i8] c"=\00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [22 x i8] c"]: %s \00"
define void @print_progress(double %0, double %1, i8* %2, i8* %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca double
%10 = alloca i32
store double %0, double* %5
store double %1, double* %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%11 = load double, double* %5
%12 = fdiv double 3.000000e+01, %11
store double %12, double* %9
%13 = load i8*, i8** %7
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %13)
store i32 0, i32* %10
br label %15
15: ; preds = %30, %4
%16 = load i32, i32* %10
%17 = icmp slt i32 %16, 30
br i1 %17, label %18, label %33
18: ; preds = %15
%19 = load i32, i32* %10
%20 = sitofp i32 %19 to double
%21 = load double, double* %6
%22 = load double, double* %9
%23 = fmul double %21, %22
%24 = fcmp olt double %20, %23
br i1 %24, label %25, label %27
25: ; preds = %18
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %29
27: ; preds = %18
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %29
29: ; preds = %27, %25
br label %30
30: ; preds = %29
%31 = load i32, i32* %10
%32 = add nsw i32 %31, 1
store i32 %32, i32* %10
br label %15
33: ; preds = %15
%34 = load i8*, i8** %8
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %34)
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"\0D%s: [\00"
@.str.3 = [22 x i8] c"]: %s \00"
define void @print_progress(double %0, double %1, i8* %2, i8* %3) {
%5 = fdiv double 3.000000e+01, %0
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %2)
%7 = fmul double %5, %1
br label %10
8: ; preds = %10
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %3)
ret void
10: ; preds = %4, %10
%11 = phi i32 [ 0, %4 ], [ %16, %10 ]
%12 = sitofp i32 %11 to double
%13 = fcmp ogt double %7, %12
%14 = select i1 %13, i32 61, i32 32
%15 = tail call i32 @putchar(i32 %14)
%16 = add nuw nsw i32 %11, 1
%17 = icmp eq i32 %16, 30
br i1 %17, label %8, label %10
}