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

/* Variables and functions */
int /*<<< orphan*/ mvprintw(int, int, char *, ...);
void battery_show(uint8_t capacity) {
  int i;
  mvprintw(7, 29, "%3u%%", capacity);
  mvprintw(7, 35, "          ");
  for (i = 0; i * 10 < capacity; ++i)
    mvprintw(7, 35 + i, "#");
}


x86 assembly (clang, -O0):
<battery_show>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%ecx
mov    $0x7,%edi
mov    $0x1d,%esi
lea    0xed1(%rip),%rdx
mov    $0x0,%al
call   1030 <mvprintw@plt>
mov    $0x7,%edi
mov    $0x23,%esi
lea    0xebf(%rip),%rdx
mov    $0x0,%al
call   1030 <mvprintw@plt>
movl   $0x0,-0x8(%rbp)
imul   $0xa,-0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1189 <battery_show+0x79>
mov    -0x8(%rbp),%esi
add    $0x23,%esi
mov    $0x7,%edi
lea    0xe9d(%rip),%rdx
mov    $0x0,%al
call   1030 <mvprintw@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1155 <battery_show+0x45>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<battery_show>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%r15d
lea    0xedf(%rip),%rdx
mov    $0x7,%edi
mov    $0x1d,%esi
mov    %r15d,%ecx
xor    %eax,%eax
call   1030 <mvprintw@plt>
lea    0xeca(%rip),%rdx
mov    $0x23,%ebp
mov    $0x7,%edi
mov    $0x23,%esi
xor    %eax,%eax
call   1030 <mvprintw@plt>
test   %r15d,%r15d
jle    117c <battery_show+0x6c>
lea    0xeb3(%rip),%r14
xor    %ebx,%ebx
mov    $0x7,%edi
mov    %ebp,%esi
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <mvprintw@plt>
add    $0x1,%ebp
add    $0xa,%ebx
cmp    %r15d,%ebx
jl     1160 <battery_show+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%3u%%\00"
@.str.1 = [11 x i8] c" \00"
@.str.2 = [2 x i8] c"#\00"
define void @battery_show(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 7, i32 29, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 7, i32 35, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %7
7: ; preds = %16, %1
%8 = load i32, i32* %3
%9 = mul nsw i32 %8, 10
%10 = load i32, i32* %2
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %19
12: ; preds = %7
%13 = load i32, i32* %3
%14 = add nsw i32 35, %13
%15 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 7, i32 %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %16
16: ; preds = %12
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 1
store i32 %18, i32* %3
br label %7
19: ; preds = %7
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%3u%%\00"
@.str.1 = [11 x i8] c" \00"
@.str.2 = [2 x i8] c"#\00"
define void @battery_show(i32 %0) {
%2 = tail call i32 (i32, i32, i8*, ...) @mvprintw(i32 7, i32 29, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %0)
%3 = tail call i32 (i32, i32, i8*, ...) @mvprintw(i32 7, i32 35, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp sgt i32 %0, 0
br i1 %4, label %5, label %12
5: ; preds = %1, %5
%6 = phi i32 [ %9, %5 ], [ 0, %1 ]
%7 = add nuw nsw i32 %6, 35
%8 = tail call i32 (i32, i32, i8*, ...) @mvprintw(i32 7, i32 %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%9 = add nuw nsw i32 %6, 1
%10 = mul nsw i32 %9, 10
%11 = icmp slt i32 %10, %0
br i1 %11, label %5, label %12
12: ; preds = %5, %1
ret void
}