#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 scalar_t__ uint8_t;

/* Variables and functions */
int /*<<< orphan*/ uart_send_byte_blocking(char);
void draw_bar(uint8_t length, uint8_t filled, uint8_t ch) {
  uart_send_byte_blocking('[');
  uint8_t cursor;
  for (cursor = 0; cursor < filled; cursor++)
    uart_send_byte_blocking(ch);
  for (; cursor < length; cursor++)
    uart_send_byte_blocking(' ');
  uart_send_byte_blocking(']');
}


x86 assembly (clang, -O0):
<draw_bar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    $0x5b,%edi
call   1030 <uart_send_byte_blocking@plt>
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jge    1161 <draw_bar+0x51>
mov    -0x18(%rbp),%rax
movsbl %al,%edi
call   1030 <uart_send_byte_blocking@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1136 <draw_bar+0x26>
jmp    1166 <draw_bar+0x56>
mov    -0x20(%rbp),%rax
cmp    -0x8(%rbp),%rax
jge    118f <draw_bar+0x7f>
mov    $0x20,%edi
call   1030 <uart_send_byte_blocking@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1166 <draw_bar+0x56>
mov    $0x5d,%edi
call   1030 <uart_send_byte_blocking@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw_bar>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x5b,%edi
call   1030 <uart_send_byte_blocking@plt>
test   %r14,%r14
jle    1155 <draw_bar+0x45>
movsbl %bpl,%r15d
mov    %r14,%rbp
cs nopw 0x0(%rax,%rax,1)
mov    %r15d,%edi
call   1030 <uart_send_byte_blocking@plt>
add    $0xffffffffffffffff,%rbp
jne    1140 <draw_bar+0x30>
cmp    %rbx,%r14
jl     115d <draw_bar+0x4d>
jmp    1170 <draw_bar+0x60>
xor    %r14d,%r14d
cmp    %rbx,%r14
jge    1170 <draw_bar+0x60>
sub    %r14,%rbx
mov    $0x20,%edi
call   1030 <uart_send_byte_blocking@plt>
add    $0xffffffffffffffff,%rbx
jne    1160 <draw_bar+0x50>
mov    $0x5d,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <uart_send_byte_blocking@plt>

LLVM IR (-O0):
define void @draw_bar(i64 %0, i64 %1, i64 %2) {
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
store i64 %0, i64* %4
store i64 %1, i64* %5
store i64 %2, i64* %6
%8 = call i32 @uart_send_byte_blocking(i8 signext 91)
store i64 0, i64* %7
br label %9
9: ; preds = %17, %3
%10 = load i64, i64* %7
%11 = load i64, i64* %5
%12 = icmp slt i64 %10, %11
br i1 %12, label %13, label %20
13: ; preds = %9
%14 = load i64, i64* %6
%15 = trunc i64 %14 to i8
%16 = call i32 @uart_send_byte_blocking(i8 signext %15)
br label %17
17: ; preds = %13
%18 = load i64, i64* %7
%19 = add nsw i64 %18, 1
store i64 %19, i64* %7
br label %9
20: ; preds = %9
br label %21
21: ; preds = %27, %20
%22 = load i64, i64* %7
%23 = load i64, i64* %4
%24 = icmp slt i64 %22, %23
br i1 %24, label %25, label %30
25: ; preds = %21
%26 = call i32 @uart_send_byte_blocking(i8 signext 32)
br label %27
27: ; preds = %25
%28 = load i64, i64* %7
%29 = add nsw i64 %28, 1
store i64 %29, i64* %7
br label %21
30: ; preds = %21
%31 = call i32 @uart_send_byte_blocking(i8 signext 93)
ret void
}

LLVM IR (-O2):
define void @draw_bar(i64 %0, i64 %1, i64 %2) {
%4 = tail call i32 @uart_send_byte_blocking(i8 signext 91)
%5 = icmp sgt i64 %1, 0
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = trunc i64 %2 to i8
br label %11
8: ; preds = %11, %3
%9 = phi i64 [ 0, %3 ], [ %1, %11 ]
%10 = icmp slt i64 %9, %0
br i1 %10, label %16, label %21
11: ; preds = %6, %11
%12 = phi i64 [ 0, %6 ], [ %14, %11 ]
%13 = tail call i32 @uart_send_byte_blocking(i8 signext %7)
%14 = add nuw nsw i64 %12, 1
%15 = icmp eq i64 %14, %1
br i1 %15, label %8, label %11
16: ; preds = %8, %16
%17 = phi i64 [ %19, %16 ], [ %9, %8 ]
%18 = tail call i32 @uart_send_byte_blocking(i8 signext 32)
%19 = add nuw i64 %17, 1
%20 = icmp eq i64 %19, %0
br i1 %20, label %21, label %16
21: ; preds = %16, %8
%22 = tail call i32 @uart_send_byte_blocking(i8 signext 93)
ret void
}