#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*/ fputc(char, int /*<<< orphan*/);
int /*<<< orphan*/ fputs(char const *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char const *, int);
int /*<<< orphan*/ stdout;
void __progress(int pct, char c) {
  const int width = 70;
  static const char *nl = "";
  static int pos;
  if (pos % width == 0)
    printf("%s%3d %% [", nl, pct);
  fputc(c, stdout);
  nl = "]\n";
  pos++;
  if (pct == 100) {
    while (pos++ < width)
      fputc(' ', stdout);
    fputs(nl, stdout);
  }
  fflush(stdout);
}


x86 assembly (clang, -O0):
<__progress>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %edi,-0x4(%rbp)
mov    %al,-0x5(%rbp)
movl   $0x46,-0xc(%rbp)
mov    0x2eee(%rip),%eax
mov    $0x46,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1185 <__progress+0x45>
mov    0x2eca(%rip),%rsi
mov    -0x4(%rbp),%edx
lea    0xe80(%rip),%rdi
call   1030 <printf@plt>
mov    -0x5(%rbp),%al
mov    0x2e51(%rip),%rcx
mov    (%rcx),%esi
movsbl %al,%edi
call   1050 <fputc@plt>
lea    0xe6b(%rip),%rax
mov    %rax,0x2e99(%rip)
mov    0x2e9f(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2e96(%rip)
cmpl   $0x64,-0x4(%rbp)
jne    120c <__progress+0xcc>
jmp    11c5 <__progress+0x85>
mov    0x2e81(%rip),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,0x2e76(%rip)
cmp    $0x46,%eax
jge    11f7 <__progress+0xb7>
mov    0x2dfa(%rip),%rax
mov    (%rax),%esi
mov    $0x20,%edi
call   1050 <fputc@plt>
jmp    11c5 <__progress+0x85>
mov    0x2e42(%rip),%rdi
mov    0x2ddb(%rip),%rax
mov    (%rax),%esi
call   1040 <fputs@plt>
mov    0x2dcd(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__progress>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %edi,%r14d
imul   $0x8af8af8b,0x2ef9(%rip),%eax
af f8 8a
add    $0x3a83a82,%eax
ror    %eax
cmp    $0x3a83a82,%eax
ja     1177 <__progress+0x37>
mov    0x2ed8(%rip),%rsi
lea    0xe91(%rip),%rdi
mov    %r14d,%edx
call   1030 <printf@plt>
mov    0x2e62(%rip),%rbx
mov    (%rbx),%esi
movsbl %bpl,%edi
call   1050 <fputc@plt>
lea    0xe7b(%rip),%rdi
mov    %rdi,0x2ea9(%rip)
mov    0x2eaf(%rip),%eax
lea    0x1(%rax),%ecx
mov    %ecx,0x2ea6(%rip)
cmp    $0x64,%r14d
jne    11ee <__progress+0xae>
lea    0x2(%rax),%ecx
mov    %ecx,0x2e97(%rip)
cmp    $0x44,%eax
jg     11e7 <__progress+0xa7>
nopw   0x0(%rax,%rax,1)
mov    (%rbx),%esi
mov    $0x20,%edi
call   1050 <fputc@plt>
mov    0x2e7a(%rip),%eax
lea    0x1(%rax),%ecx
mov    %ecx,0x2e71(%rip)
cmp    $0x46,%eax
jl     11c0 <__progress+0x80>
mov    0x2e59(%rip),%rdi
mov    (%rbx),%esi
call   1040 <fputs@plt>
mov    (%rbx),%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1060 <fflush@plt>

LLVM IR (-O0):
@__progress.nl = internal global i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i32 0, i32 0)
@.str = [1 x i8] zeroinitializer
@__progress.pos = internal global i32 0
@.str.1 = [11 x i8] c"%s%3d %% [\00"
@stdout = global i32 0
@.str.2 = [3 x i8] c"]\0A\00"
define void @__progress(i32 %0, i8 signext %1) {
%3 = alloca i32
%4 = alloca i8
%5 = alloca i32
store i32 %0, i32* %3
store i8 %1, i8* %4
store i32 70, i32* %5
%6 = load i32, i32* @__progress.pos
%7 = srem i32 %6, 70
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = load i8*, i8** @__progress.nl
%11 = load i32, i32* %3
%12 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %10, i32 %11)
br label %13
13: ; preds = %9, %2
%14 = load i8, i8* %4
%15 = load i32, i32* @stdout
%16 = call i32 @fputc(i8 signext %14, i32 %15)
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** @__progress.nl
%17 = load i32, i32* @__progress.pos
%18 = add nsw i32 %17, 1
store i32 %18, i32* @__progress.pos
%19 = load i32, i32* %3
%20 = icmp eq i32 %19, 100
br i1 %20, label %21, label %33
21: ; preds = %13
br label %22
22: ; preds = %26, %21
%23 = load i32, i32* @__progress.pos
%24 = add nsw i32 %23, 1
store i32 %24, i32* @__progress.pos
%25 = icmp slt i32 %23, 70
br i1 %25, label %26, label %29
26: ; preds = %22
%27 = load i32, i32* @stdout
%28 = call i32 @fputc(i8 signext 32, i32 %27)
br label %22
29: ; preds = %22
%30 = load i8*, i8** @__progress.nl
%31 = load i32, i32* @stdout
%32 = call i32 @fputs(i8* %30, i32 %31)
br label %33
33: ; preds = %29, %13
%34 = load i32, i32* @stdout
%35 = call i32 @fflush(i32 %34)
ret void
}

LLVM IR (-O2):
@__progress.nl = internal unnamed_addr global i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0)
@.str = [1 x i8] zeroinitializer
@__progress.pos = internal unnamed_addr global i32 0
@.str.1 = [11 x i8] c"%s%3d %% [\00"
@stdout = global i32 0
@.str.2 = [3 x i8] c"]\0A\00"
define void @__progress(i32 %0, i8 signext %1) {
%3 = load i32, i32* @__progress.pos
%4 = srem i32 %3, 70
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = load i8*, i8** @__progress.nl
%8 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %7, i32 %0)
br label %9
9: ; preds = %6, %2
%10 = load i32, i32* @stdout
%11 = tail call i32 @fputc(i8 signext %1, i32 %10)
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** @__progress.nl
%12 = load i32, i32* @__progress.pos
%13 = add nsw i32 %12, 1
store i32 %13, i32* @__progress.pos
%14 = icmp eq i32 %0, 100
br i1 %14, label %15, label %30
15: ; preds = %9
%16 = add nsw i32 %12, 2
store i32 %16, i32* @__progress.pos
%17 = icmp slt i32 %12, 69
br i1 %17, label %18, label %26
18: ; preds = %15, %18
%19 = load i32, i32* @stdout
%20 = tail call i32 @fputc(i8 signext 32, i32 %19)
%21 = load i32, i32* @__progress.pos
%22 = add nsw i32 %21, 1
store i32 %22, i32* @__progress.pos
%23 = icmp slt i32 %21, 70
br i1 %23, label %18, label %24
24: ; preds = %18
%25 = load i8*, i8** @__progress.nl
br label %26
26: ; preds = %24, %15
%27 = phi i8* [ %25, %24 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), %15 ]
%28 = load i32, i32* @stdout
%29 = tail call i32 @fputs(i8* %27, i32 %28)
br label %30
30: ; preds = %26, %9
%31 = load i32, i32* @stdout
%32 = tail call i32 @fflush(i32 %31)
ret void
}