#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 A_BOLD;
int COLOR_PAIR(int);
int /*<<< orphan*/ addch(char);
int /*<<< orphan*/ attrset(int);
int ceil(double);
int floor(float);
void bar_draw(int len, float val) {
  int num;
  int i, colour;
  num = ceil(((double)len) * val / 100.);
  num = num > len ? len : num;
  colour = floor(val / 33.) + 1;
  colour = colour > 3 ? 3 : colour;
  attrset(COLOR_PAIR(colour) | A_BOLD);
  for (i = 0; i < num; i++)
    addch('=');
  for (i = 0; i < len - num; i++)
    addch(' ');
}


x86 assembly (clang, -O0):
<bar_draw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movss  %xmm0,-0x8(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe86(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <ceil@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jle    119d <bar_draw+0x4d>
mov    -0x4(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    11a3 <bar_draw+0x53>
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe4e(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1070 <floor@plt>
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jle    11e4 <bar_draw+0x94>
mov    $0x3,%eax
mov    %eax,-0x1c(%rbp)
jmp    11ea <bar_draw+0x9a>
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <COLOR_PAIR@plt>
mov    %eax,%edi
mov    0x2ddf(%rip),%rax
or     (%rax),%edi
call   1060 <attrset@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1233 <bar_draw+0xe3>
mov    $0x3d,%edi
call   1050 <addch@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    120f <bar_draw+0xbf>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    -0xc(%rbp),%ecx
cmp    %ecx,%eax
jge    1263 <bar_draw+0x113>
mov    $0x20,%edi
call   1050 <addch@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    123a <bar_draw+0xea>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bar_draw>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
movss  %xmm0,0xc(%rsp)
mov    %edi,%ebx
cvtsi2sd %edi,%xmm1
cvtss2sd %xmm0,%xmm0
mulsd  %xmm1,%xmm0
divsd  0xe8c(%rip),%xmm0
call   1030 <ceil@plt>
mov    %eax,%r14d
cmp    %ebx,%eax
cmovg  %ebx,%r14d
movss  0xc(%rsp),%xmm0
divss  0xe78(%rip),%xmm0
call   1070 <floor@plt>
cmp    $0x2,%eax
mov    $0x2,%edi
cmovl  %eax,%edi
add    $0x1,%edi
call   1040 <COLOR_PAIR@plt>
mov    0x2e31(%rip),%rcx
or     (%rcx),%eax
mov    %eax,%edi
call   1060 <attrset@plt>
test   %r14d,%r14d
jle    11cf <bar_draw+0x7f>
mov    %r14d,%ebp
mov    $0x3d,%edi
call   1050 <addch@plt>
add    $0xffffffff,%ebp
jne    11c0 <bar_draw+0x70>
sub    %r14d,%ebx
test   %ebx,%ebx
jle    11ef <bar_draw+0x9f>
cs nopw 0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1050 <addch@plt>
add    $0xffffffff,%ebx
jne    11e0 <bar_draw+0x90>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@A_BOLD = global i32 0
define void @bar_draw(i32 %0, float %1) {
%3 = alloca i32
%4 = alloca float
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store float %1, float* %4
%8 = load i32, i32* %3
%9 = sitofp i32 %8 to double
%10 = load float, float* %4
%11 = fpext float %10 to double
%12 = fmul double %9, %11
%13 = fdiv double %12, 1.000000e+02
%14 = call i32 @ceil(double %13)
store i32 %14, i32* %5
%15 = load i32, i32* %5
%16 = load i32, i32* %3
%17 = icmp sgt i32 %15, %16
br i1 %17, label %18, label %20
18: ; preds = %2
%19 = load i32, i32* %3
br label %22
20: ; preds = %2
%21 = load i32, i32* %5
br label %22
22: ; preds = %20, %18
%23 = phi i32 [ %19, %18 ], [ %21, %20 ]
store i32 %23, i32* %5
%24 = load float, float* %4
%25 = fpext float %24 to double
%26 = fdiv double %25, 3.300000e+01
%27 = fptrunc double %26 to float
%28 = call i32 @floor(float %27)
%29 = add nsw i32 %28, 1
store i32 %29, i32* %7
%30 = load i32, i32* %7
%31 = icmp sgt i32 %30, 3
br i1 %31, label %32, label %33
32: ; preds = %22
br label %35
33: ; preds = %22
%34 = load i32, i32* %7
br label %35
35: ; preds = %33, %32
%36 = phi i32 [ 3, %32 ], [ %34, %33 ]
store i32 %36, i32* %7
%37 = load i32, i32* %7
%38 = call i32 @COLOR_PAIR(i32 %37)
%39 = load i32, i32* @A_BOLD
%40 = or i32 %38, %39
%41 = call i32 @attrset(i32 %40)
store i32 0, i32* %6
br label %42
42: ; preds = %48, %35
%43 = load i32, i32* %6
%44 = load i32, i32* %5
%45 = icmp slt i32 %43, %44
br i1 %45, label %46, label %51
46: ; preds = %42
%47 = call i32 @addch(i8 signext 61)
br label %48
48: ; preds = %46
%49 = load i32, i32* %6
%50 = add nsw i32 %49, 1
store i32 %50, i32* %6
br label %42
51: ; preds = %42
store i32 0, i32* %6
br label %52
52: ; preds = %60, %51
%53 = load i32, i32* %6
%54 = load i32, i32* %3
%55 = load i32, i32* %5
%56 = sub nsw i32 %54, %55
%57 = icmp slt i32 %53, %56
br i1 %57, label %58, label %63
58: ; preds = %52
%59 = call i32 @addch(i8 signext 32)
br label %60
60: ; preds = %58
%61 = load i32, i32* %6
%62 = add nsw i32 %61, 1
store i32 %62, i32* %6
br label %52
63: ; preds = %52
ret void
}

LLVM IR (-O2):
@A_BOLD = global i32 0
define void @bar_draw(i32 %0, float %1) {
%3 = sitofp i32 %0 to double
%4 = fpext float %1 to double
%5 = fmul double %3, %4
%6 = fdiv double %5, 1.000000e+02
%7 = tail call i32 @ceil(double %6)
%8 = icmp sgt i32 %7, %0
%9 = select i1 %8, i32 %0, i32 %7
%10 = fdiv float %1, 3.300000e+01
%11 = tail call i32 @floor(float %10)
%12 = icmp slt i32 %11, 2
%13 = select i1 %12, i32 %11, i32 2
%14 = add nsw i32 %13, 1
%15 = tail call i32 @COLOR_PAIR(i32 %14)
%16 = load i32, i32* @A_BOLD
%17 = or i32 %16, %15
%18 = tail call i32 @attrset(i32 %17)
%19 = icmp sgt i32 %9, 0
br i1 %19, label %23, label %20
20: ; preds = %23, %2
%21 = sub i32 %0, %9
%22 = icmp sgt i32 %21, 0
br i1 %22, label %28, label %33
23: ; preds = %2, %23
%24 = phi i32 [ %26, %23 ], [ 0, %2 ]
%25 = tail call i32 @addch(i8 signext 61)
%26 = add nuw nsw i32 %24, 1
%27 = icmp eq i32 %26, %9
br i1 %27, label %20, label %23
28: ; preds = %20, %28
%29 = phi i32 [ %31, %28 ], [ 0, %20 ]
%30 = tail call i32 @addch(i8 signext 32)
%31 = add nuw nsw i32 %29, 1
%32 = icmp eq i32 %31, %21
br i1 %32, label %33, label %28
33: ; preds = %28, %20
ret void
}