#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*/ led_clear();
int /*<<< orphan*/ led_set_code(int, unsigned int);
int /*<<< orphan*/ led_set_dp(int);
scalar_t__ power_5v_get_enable();
unsigned int power_get_percent();
unsigned int power_get_voltage();
void display_power_percent(void) {
  unsigned int val;
  if (power_5v_get_enable()) {
    val = power_get_voltage();
    led_clear();
    led_set_code(5, 'P');
    led_set_code(4, 'O');
    led_set_code(3, '-');
    led_set_dp(2);
  } else {
    val = power_get_percent();
    ;
    led_clear();
    led_set_code(5, 'P');
    led_set_code(4, 'E');
    led_set_code(3, '-');
  }
  led_set_code(2, val / 100 + 0x30);
  led_set_code(1, (val % 100) / 10 + 0x30);
  led_set_code(0, (val % 100) % 10 + 0x30);
}


x86 assembly (clang, -O0):
<display_power_percent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1080 <power_5v_get_enable@plt>
cmp    $0x0,%rax
je     11c6 <display_power_percent+0x66>
mov    $0x0,%al
call   1070 <power_get_voltage@plt>
mov    %eax,-0x4(%rbp)
mov    $0x0,%al
call   1050 <led_clear@plt>
mov    $0x5,%edi
mov    $0x50,%esi
call   1060 <led_set_code@plt>
mov    $0x4,%edi
mov    $0x4f,%esi
call   1060 <led_set_code@plt>
mov    $0x3,%edi
mov    $0x2d,%esi
call   1060 <led_set_code@plt>
mov    $0x2,%edi
call   1040 <led_set_dp@plt>
jmp    1204 <display_power_percent+0xa4>
mov    $0x0,%al
call   1030 <power_get_percent@plt>
mov    %eax,-0x4(%rbp)
mov    $0x0,%al
call   1050 <led_clear@plt>
mov    $0x5,%edi
mov    $0x50,%esi
call   1060 <led_set_code@plt>
mov    $0x4,%edi
mov    $0x45,%esi
call   1060 <led_set_code@plt>
mov    $0x3,%edi
mov    $0x2d,%esi
call   1060 <led_set_code@plt>
mov    -0x4(%rbp),%eax
mov    $0x64,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,%esi
add    $0x30,%esi
mov    $0x2,%edi
call   1060 <led_set_code@plt>
mov    -0x4(%rbp),%eax
mov    $0x64,%ecx
xor    %edx,%edx
div    %ecx
mov    %edx,%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,%esi
add    $0x30,%esi
mov    $0x1,%edi
call   1060 <led_set_code@plt>
mov    -0x4(%rbp),%eax
mov    $0x64,%ecx
xor    %edx,%edx
div    %ecx
mov    %edx,%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    %edx,%esi
add    $0x30,%esi
xor    %edi,%edi
call   1060 <led_set_code@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display_power_percent>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1080 <power_5v_get_enable@plt>
test   %rax,%rax
je     11b8 <display_power_percent+0x58>
xor    %eax,%eax
call   1070 <power_get_voltage@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1050 <led_clear@plt>
mov    $0x5,%edi
mov    $0x50,%esi
call   1060 <led_set_code@plt>
mov    $0x4,%edi
mov    $0x4f,%esi
call   1060 <led_set_code@plt>
mov    $0x3,%edi
mov    $0x2d,%esi
call   1060 <led_set_code@plt>
mov    $0x2,%edi
call   1040 <led_set_dp@plt>
jmp    11f5 <display_power_percent+0x95>
xor    %eax,%eax
call   1030 <power_get_percent@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1050 <led_clear@plt>
mov    $0x5,%edi
mov    $0x50,%esi
call   1060 <led_set_code@plt>
mov    $0x4,%edi
mov    $0x45,%esi
call   1060 <led_set_code@plt>
mov    $0x3,%edi
mov    $0x2d,%esi
call   1060 <led_set_code@plt>
mov    %ebp,%eax
imul   $0x51eb851f,%rax,%rbx
shr    $0x25,%rbx
lea    0x30(%rbx),%esi
mov    $0x2,%edi
call   1060 <led_set_code@plt>
imul   $0x64,%ebx,%eax
sub    %eax,%ebp
imul   $0xcd,%ebp,%eax
movzwl %ax,%ebx
shr    $0xb,%ebx
mov    %ebx,%eax
or     $0x30,%al
movzbl %al,%esi
mov    $0x1,%edi
call   1060 <led_set_code@plt>
add    %ebx,%ebx
lea    (%rbx,%rbx,4),%eax
sub    %al,%bpl
or     $0x30,%bpl
movzbl %bpl,%esi
xor    %edi,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1060 <led_set_code@plt>

LLVM IR (-O0):
define void @display_power_percent() {
%1 = alloca i32
%2 = call i64 (...) @power_5v_get_enable()
%3 = icmp ne i64 %2, 0
br i1 %3, label %4, label %11
4: ; preds = %0
%5 = call i32 (...) @power_get_voltage()
store i32 %5, i32* %1
%6 = call i32 (...) @led_clear()
%7 = call i32 @led_set_code(i32 5, i32 80)
%8 = call i32 @led_set_code(i32 4, i32 79)
%9 = call i32 @led_set_code(i32 3, i32 45)
%10 = call i32 @led_set_dp(i32 2)
br label %17
11: ; preds = %0
%12 = call i32 (...) @power_get_percent()
store i32 %12, i32* %1
%13 = call i32 (...) @led_clear()
%14 = call i32 @led_set_code(i32 5, i32 80)
%15 = call i32 @led_set_code(i32 4, i32 69)
%16 = call i32 @led_set_code(i32 3, i32 45)
br label %17
17: ; preds = %11, %4
%18 = load i32, i32* %1
%19 = udiv i32 %18, 100
%20 = add i32 %19, 48
%21 = call i32 @led_set_code(i32 2, i32 %20)
%22 = load i32, i32* %1
%23 = urem i32 %22, 100
%24 = udiv i32 %23, 10
%25 = add i32 %24, 48
%26 = call i32 @led_set_code(i32 1, i32 %25)
%27 = load i32, i32* %1
%28 = urem i32 %27, 100
%29 = urem i32 %28, 10
%30 = add i32 %29, 48
%31 = call i32 @led_set_code(i32 0, i32 %30)
ret void
}

LLVM IR (-O2):
define void @display_power_percent() {
%1 = tail call i64 (...) @power_5v_get_enable()
%2 = icmp eq i64 %1, 0
br i1 %2, label %10, label %3
3: ; preds = %0
%4 = tail call i32 (...) @power_get_voltage()
%5 = tail call i32 (...) @led_clear()
%6 = tail call i32 @led_set_code(i32 5, i32 80)
%7 = tail call i32 @led_set_code(i32 4, i32 79)
%8 = tail call i32 @led_set_code(i32 3, i32 45)
%9 = tail call i32 @led_set_dp(i32 2)
br label %16
10: ; preds = %0
%11 = tail call i32 (...) @power_get_percent()
%12 = tail call i32 (...) @led_clear()
%13 = tail call i32 @led_set_code(i32 5, i32 80)
%14 = tail call i32 @led_set_code(i32 4, i32 69)
%15 = tail call i32 @led_set_code(i32 3, i32 45)
br label %16
16: ; preds = %10, %3
%17 = phi i32 [ %4, %3 ], [ %11, %10 ]
%18 = udiv i32 %17, 100
%19 = add nuw nsw i32 %18, 48
%20 = tail call i32 @led_set_code(i32 2, i32 %19)
%21 = urem i32 %17, 100
%22 = trunc i32 %21 to i8
%23 = udiv i8 %22, 10
%24 = or i8 %23, 48
%25 = zext i8 %24 to i32
%26 = tail call i32 @led_set_code(i32 1, i32 %25)
%27 = urem i8 %22, 10
%28 = or i8 %27, 48
%29 = zext i8 %28 to i32
%30 = tail call i32 @led_set_code(i32 0, i32 %29)
ret void
}