#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*/ printf(char *, ...);
int /*<<< orphan*/ stdout;
void printProgressBar(int percent) {
  int num = percent * 70 / 100;
  printf("\r%3d%%[", percent);
  for (int i = 0; i < 70; ++i) {
    printf(i < num ? "=" : " ");
  }
  printf("]");
  fflush(stdout);
}


x86 assembly (clang, -O0):
<printProgressBar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
imul   $0x46,-0x4(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%esi
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x46,-0xc(%rbp)
jge    118b <printProgressBar+0x6b>
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%edx
lea    0xea1(%rip),%rdi
lea    0xe98(%rip),%rax
cmp    %edx,%ecx
cmovl  %rax,%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1152 <printProgressBar+0x32>
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e40(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printProgressBar>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%esi
imul   $0x46,%edi,%eax
cltq
imul   $0x51eb851f,%rax,%rbx
mov    %rbx,%rax
shr    $0x3f,%rax
sar    $0x25,%rbx
add    %eax,%ebx
lea    0xea7(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea1(%rip),%r14
lea    0xe9c(%rip),%r15
xor    %ebp,%ebp
cmp    %ebx,%ebp
mov    %r15,%rdi
cmovl  %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    $0x46,%ebp
jne    1170 <printProgressBar+0x40>
mov    $0x5d,%edi
call   1030 <putchar@plt>
mov    0x2e47(%rip),%rax
mov    (%rax),%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <fflush@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"\0D%3d%%[\00"
@.str.1 = [2 x i8] c"=\00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [2 x i8] c"]\00"
@stdout = global i32 0
define void @printProgressBar(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = mul nsw i32 %5, 70
%7 = sdiv i32 %6, 100
store i32 %7, i32* %3
%8 = load i32, i32* %2
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %8)
store i32 0, i32* %4
br label %10
10: ; preds = %20, %1
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 70
br i1 %12, label %13, label %23
13: ; preds = %10
%14 = load i32, i32* %4
%15 = load i32, i32* %3
%16 = icmp slt i32 %14, %15
%17 = zext i1 %16 to i64
%18 = select i1 %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0)
%19 = call i32 (i8*, ...) @printf(i8* %18)
br label %20
20: ; preds = %13
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %10
23: ; preds = %10
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%25 = load i32, i32* @stdout
%26 = call i32 @fflush(i32 %25)
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"\0D%3d%%[\00"
@.str.1 = [2 x i8] c"=\00"
@.str.2 = [2 x i8] c" \00"
@stdout = global i32 0
define void @printProgressBar(i32 %0) {
%2 = mul nsw i32 %0, 70
%3 = sdiv i32 %2, 100
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %9
5: ; preds = %9
%6 = tail call i32 @putchar(i32 93)
%7 = load i32, i32* @stdout
%8 = tail call i32 @fflush(i32 %7)
ret void
9: ; preds = %1, %9
%10 = phi i32 [ 0, %1 ], [ %14, %9 ]
%11 = icmp slt i32 %10, %3
%12 = select i1 %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %12)
%14 = add nuw nsw i32 %10, 1
%15 = icmp eq i32 %14, 70
br i1 %15, label %5, label %9
}