#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 sprintf(char *, char *, int);
void fill_perc_graph(char *perc_graph, int perc) {
  int i;
  static int perc_old = -1;
  if (perc == perc_old)
    return;
  for (i = 21 - 1; i >= 0; i--) {
    perc_graph[i] = ' ';
    if (perc - 50 / 21 > (100 * i) / 21) {
      perc_graph[i] = '=';
    }
  }
  if (perc_graph[4] == '=') {
    i = sprintf(perc_graph + 1, "%i%%", perc);
    perc_graph[i + 1] = '=';
  }
  perc_old = perc;
}


x86 assembly (clang, -O0):
<fill_perc_graph>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    0x2f00(%rip),%eax
jne    1133 <fill_perc_graph+0x23>
jmp    11d6 <fill_perc_graph+0xc6>
movl   $0x14,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jl     1191 <fill_perc_graph+0x81>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movb   $0x20,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x14(%rbp)
imul   $0x64,-0x10(%rbp),%eax
mov    $0x15,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
jle    117e <fill_perc_graph+0x6e>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movb   $0x3d,(%rax,%rcx,1)
jmp    1183 <fill_perc_graph+0x73>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    113a <fill_perc_graph+0x2a>
mov    -0x8(%rbp),%rax
movsbl 0x4(%rax),%eax
cmp    $0x3d,%eax
jne    11cd <fill_perc_graph+0xbd>
mov    -0x8(%rbp),%rdi
add    $0x1,%rdi
mov    -0xc(%rbp),%edx
lea    0xe4c(%rip),%rsi
call   1030 <sprintf@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x3d,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
mov    %eax,0x2e52(%rip)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fill_perc_graph>:
push   %r14
push   %rbx
push   %rax
cmp    %esi,0x2f0e(%rip)
je     1228 <fill_perc_graph+0x118>
mov    %esi,%ebx
mov    %rdi,%r14
lea    -0x2(%rbx),%eax
movd   %eax,%xmm0
pshufd $0x0,%xmm0,%xmm0
movdqa %xmm0,%xmm1
pcmpgtd 0xec3(%rip),%xmm1
movdqa %xmm0,%xmm2
pcmpgtd 0xec7(%rip),%xmm2
packssdw %xmm1,%xmm2
movdqa %xmm0,%xmm1
pcmpgtd 0xec7(%rip),%xmm1
pcmpgtd 0xecf(%rip),%xmm0
packssdw %xmm1,%xmm0
packsswb %xmm2,%xmm0
movdqa %xmm0,%xmm1
pandn  0xecb(%rip),%xmm1
pand   0xed3(%rip),%xmm0
por    %xmm1,%xmm0
pxor   %xmm1,%xmm1
movdqa %xmm0,%xmm2
punpcklbw %xmm1,%xmm2
pshufd $0x4e,%xmm2,%xmm2
pshuflw $0x1b,%xmm2,%xmm2
pshufhw $0x1b,%xmm2,%xmm2
punpckhbw %xmm1,%xmm0
pshufd $0x4e,%xmm0,%xmm0
pshuflw $0x1b,%xmm0,%xmm0
pshufhw $0x1b,%xmm0,%xmm0
packuswb %xmm2,%xmm0
movdqu %xmm0,0x5(%rdi)
cmp    $0x16,%esi
mov    $0x3d,%eax
mov    $0x20,%ecx
cmovge %eax,%ecx
mov    %cl,0x4(%rdi)
cmp    $0x11,%esi
mov    $0x20,%edx
cmovge %eax,%edx
mov    %dl,0x3(%rdi)
cmp    $0xc,%esi
mov    $0x20,%edx
cmovge %eax,%edx
mov    $0x20,%esi
mov    %dl,0x2(%rdi)
cmp    $0x7,%ebx
mov    $0x20,%edx
cmovge %eax,%edx
mov    %dl,0x1(%rdi)
cmp    $0x3,%ebx
cmovge %eax,%esi
mov    %sil,(%rdi)
cmp    $0x3d,%cl
jne    1222 <fill_perc_graph+0x112>
lea    0x1(%r14),%rdi
lea    0xe4d(%rip),%rsi
mov    %ebx,%edx
call   1030 <sprintf@plt>
cltq
movb   $0x3d,0x1(%rax,%r14,1)
mov    %ebx,0x2e00(%rip)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@fill_perc_graph.perc_old = internal global i32 -1
@.str = [5 x i8] c"%i%%\00"
define void @fill_perc_graph(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = load i32, i32* %4
%7 = load i32, i32* @fill_perc_graph.perc_old
%8 = icmp eq i32 %6, %7
br i1 %8, label %9, label %10
9: ; preds = %2
br label %52
10: ; preds = %2
store i32 20, i32* %5
br label %11
11: ; preds = %31, %10
%12 = load i32, i32* %5
%13 = icmp sge i32 %12, 0
br i1 %13, label %14, label %34
14: ; preds = %11
%15 = load i8*, i8** %3
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
store i8 32, i8* %18
%19 = load i32, i32* %4
%20 = sub nsw i32 %19, 2
%21 = load i32, i32* %5
%22 = mul nsw i32 100, %21
%23 = sdiv i32 %22, 21
%24 = icmp sgt i32 %20, %23
br i1 %24, label %25, label %30
25: ; preds = %14
%26 = load i8*, i8** %3
%27 = load i32, i32* %5
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
store i8 61, i8* %29
br label %30
30: ; preds = %25, %14
br label %31
31: ; preds = %30
%32 = load i32, i32* %5
%33 = add nsw i32 %32, -1
store i32 %33, i32* %5
br label %11
34: ; preds = %11
%35 = load i8*, i8** %3
%36 = getelementptr inbounds i8, i8* %35, i64 4
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %38, 61
br i1 %39, label %40, label %50
40: ; preds = %34
%41 = load i8*, i8** %3
%42 = getelementptr inbounds i8, i8* %41, i64 1
%43 = load i32, i32* %4
%44 = call i32 @sprintf(i8* %42, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %43)
store i32 %44, i32* %5
%45 = load i8*, i8** %3
%46 = load i32, i32* %5
%47 = add nsw i32 %46, 1
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %45, i64 %48
store i8 61, i8* %49
br label %50
50: ; preds = %40, %34
%51 = load i32, i32* %4
store i32 %51, i32* @fill_perc_graph.perc_old
br label %52
52: ; preds = %50, %9
ret void
}

LLVM IR (-O2):
@fill_perc_graph.perc_old = internal unnamed_addr global i32 -1
@.str = [5 x i8] c"%i%%\00"
define void @fill_perc_graph(i8* nocapture %0, i32 %1) {
%3 = load i32, i32* @fill_perc_graph.perc_old
%4 = icmp eq i32 %3, %1
br i1 %4, label %38, label %5
5: ; preds = %2
%6 = add nsw i32 %1, -2
%7 = insertelement <16 x i32> poison, i32 %6, i64 0
%8 = shufflevector <16 x i32> %7, <16 x i32> poison, <16 x i32> zeroinitializer
%9 = icmp sgt <16 x i32> %8, <i32 95, i32 90, i32 85, i32 80, i32 76, i32 71, i32 66, i32 61, i32 57, i32 52, i32 47, i32 42, i32 38, i32 33, i32 28, i32 23>
%10 = select <16 x i1> %9, <16 x i8> <i8 61, i8 61, i8 61, i8 61, i8 61, i8 61, i8 61, i8 61, i8 61, i8 61, i8 61, i8 61, i8 61, i8 61, i8 61, i8 61>, <16 x i8> <i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32>
%11 = shufflevector <16 x i8> %10, <16 x i8> poison, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
%12 = getelementptr inbounds i8, i8* %0, i64 5
%13 = bitcast i8* %12 to <16 x i8>*
store <16 x i8> %11, <16 x i8>* %13
%14 = getelementptr inbounds i8, i8* %0, i64 4
%15 = icmp sgt i32 %1, 21
%16 = select i1 %15, i8 61, i8 32
store i8 %16, i8* %14
%17 = getelementptr inbounds i8, i8* %0, i64 3
%18 = icmp sgt i32 %1, 16
%19 = select i1 %18, i8 61, i8 32
store i8 %19, i8* %17
%20 = getelementptr inbounds i8, i8* %0, i64 2
%21 = icmp sgt i32 %1, 11
%22 = select i1 %21, i8 61, i8 32
store i8 %22, i8* %20
%23 = getelementptr inbounds i8, i8* %0, i64 1
%24 = icmp sgt i32 %1, 6
%25 = select i1 %24, i8 61, i8 32
store i8 %25, i8* %23
%26 = icmp sgt i32 %1, 2
%27 = select i1 %26, i8 61, i8 32
store i8 %27, i8* %0
%28 = getelementptr inbounds i8, i8* %0, i64 4
%29 = load i8, i8* %28
%30 = icmp eq i8 %29, 61
br i1 %30, label %31, label %37
31: ; preds = %5
%32 = getelementptr inbounds i8, i8* %0, i64 1
%33 = tail call i32 @sprintf(i8* %32, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %1)
%34 = add nsw i32 %33, 1
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %0, i64 %35
store i8 61, i8* %36
br label %37
37: ; preds = %31, %5
store i32 %1, i32* @fill_perc_graph.perc_old
br label %38
38: ; preds = %2, %37
ret void
}