#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 */
typedef int uint8_t;
typedef int uint16_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
void progress_bar_print(char *prefix, char *suffix, uint8_t value) {
  if (value > 100) {
    value = 100;
  }
  printf("\033[?25l");
  putchar('\n');
  printf("\033[1A");
  putchar('\r');
  if (prefix) {
    printf("%s", prefix);
  }
  printf("|");
  for (unsigned i = 0; i < (25U); ++i) {
    if (100 * i < (uint16_t)(value * (25U))) {
      printf("█");
    } else {
      printf(" ");
    }
  }
  printf("|");
  if (suffix) {
    printf("%s", suffix);
  }
  printf("\033[s");
  putchar('\n');
  printf("\033[u");
  printf("\033[?25h");
}


x86 assembly (clang, -O0):
<progress_bar_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0x64,-0x14(%rbp)
jle    1144 <progress_bar_print+0x24>
movl   $0x64,-0x14(%rbp)
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xd,%edi
call   1030 <putchar@plt>
cmpq   $0x0,-0x8(%rbp)
je     1191 <progress_bar_print+0x71>
mov    -0x8(%rbp),%rsi
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0x19,-0x18(%rbp)
jae    11f4 <progress_bar_print+0xd4>
imul   $0x64,-0x18(%rbp),%eax
imul   $0x19,-0x14(%rbp),%ecx
cmp    %ecx,%eax
jae    11d3 <progress_bar_print+0xb3>
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11e1 <progress_bar_print+0xc1>
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11e6 <progress_bar_print+0xc6>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11a6 <progress_bar_print+0x86>
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpq   $0x0,-0x10(%rbp)
je     121f <progress_bar_print+0xff>
mov    -0x10(%rbp),%rsi
lea    0xdf4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdf1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xddd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdd3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<progress_bar_print>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
cmp    $0x64,%edx
mov    $0x64,%ebx
cmovl  %edx,%ebx
lea    0xec1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xeb0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xd,%edi
call   1030 <putchar@plt>
test   %r15,%r15
je     117e <progress_bar_print+0x5e>
lea    0xe98(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x7c,%edi
call   1030 <putchar@plt>
lea    (%rbx,%rbx,4),%eax
lea    (%rax,%rax,4),%ebp
lea    0xe7a(%rip),%r15
xor    %ebx,%ebx
jmp    11b5 <progress_bar_print+0x95>
nopl   0x0(%rax)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0x64,%ebx
cmp    $0x9c4,%ebx
je     11c5 <progress_bar_print+0xa5>
cmp    %ebp,%ebx
jae    11a0 <progress_bar_print+0x80>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11aa <progress_bar_print+0x8a>
mov    $0x7c,%edi
call   1030 <putchar@plt>
test   %r14,%r14
je     11e5 <progress_bar_print+0xc5>
lea    0xe31(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe27(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe13(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe09(%rip),%rdi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"\1B[?25l\00"
@.str.1 = [5 x i8] c"\1B[1A\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [2 x i8] c"|\00"
@.str.4 = [4 x i8] c"\E2\96\88\00"
@.str.5 = [2 x i8] c" \00"
@.str.6 = [4 x i8] c"\1B[s\00"
@.str.7 = [4 x i8] c"\1B[u\00"
@.str.8 = [7 x i8] c"\1B[?25h\00"
define void @progress_bar_print(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%8 = load i32, i32* %6
%9 = icmp sgt i32 %8, 100
br i1 %9, label %10, label %11
10: ; preds = %3
store i32 100, i32* %6
br label %11
11: ; preds = %10, %3
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @putchar(i8 signext 10)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 @putchar(i8 signext 13)
%16 = load i8*, i8** %4
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %21
18: ; preds = %11
%19 = load i8*, i8** %4
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %19)
br label %21
21: ; preds = %18, %11
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %7
br label %23
23: ; preds = %37, %21
%24 = load i32, i32* %7
%25 = icmp ult i32 %24, 25
br i1 %25, label %26, label %40
26: ; preds = %23
%27 = load i32, i32* %7
%28 = mul i32 100, %27
%29 = load i32, i32* %6
%30 = mul i32 %29, 25
%31 = icmp ult i32 %28, %30
br i1 %31, label %32, label %34
32: ; preds = %26
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %36
34: ; preds = %26
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %36
36: ; preds = %34, %32
br label %37
37: ; preds = %36
%38 = load i32, i32* %7
%39 = add i32 %38, 1
store i32 %39, i32* %7
br label %23
40: ; preds = %23
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%42 = load i8*, i8** %5
%43 = icmp ne i8* %42, null
br i1 %43, label %44, label %47
44: ; preds = %40
%45 = load i8*, i8** %5
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %45)
br label %47
47: ; preds = %44, %40
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%49 = call i32 @putchar(i8 signext 10)
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"\1B[?25l\00"
@.str.1 = [5 x i8] c"\1B[1A\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.4 = [4 x i8] c"\E2\96\88\00"
@.str.6 = [4 x i8] c"\1B[s\00"
@.str.7 = [4 x i8] c"\1B[u\00"
@.str.8 = [7 x i8] c"\1B[?25h\00"
define void @progress_bar_print(i8* %0, i8* %1, i32 %2) {
%4 = icmp slt i32 %2, 100
%5 = select i1 %4, i32 %2, i32 100
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @putchar(i8 signext 10)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%9 = tail call i32 @putchar(i8 signext 13)
%10 = icmp eq i8* %0, null
br i1 %10, label %13, label %11
11: ; preds = %3
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %13
13: ; preds = %11, %3
%14 = tail call i32 bitcast (i32 (i8)* @putchar to i32 (i32)*)(i32 124)
%15 = mul i32 %5, 25
br label %19
16: ; preds = %27
%17 = tail call i32 bitcast (i32 (i8)* @putchar to i32 (i32)*)(i32 124)
%18 = icmp eq i8* %1, null
br i1 %18, label %32, label %30
19: ; preds = %13, %27
%20 = phi i32 [ 0, %13 ], [ %28, %27 ]
%21 = mul nuw nsw i32 %20, 100
%22 = icmp ult i32 %21, %15
br i1 %22, label %23, label %25
23: ; preds = %19
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %27
25: ; preds = %19
%26 = tail call i32 bitcast (i32 (i8)* @putchar to i32 (i32)*)(i32 32)
br label %27
27: ; preds = %23, %25
%28 = add nuw nsw i32 %20, 1
%29 = icmp eq i32 %28, 25
br i1 %29, label %16, label %19
30: ; preds = %16
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %1)
br label %32
32: ; preds = %30, %16
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%34 = tail call i32 @putchar(i8 signext 10)
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
ret void
}