#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*/ printf(char *, ...);
void check_battery_level(int level) {
  int buf1, buf2;
  if (level > 418) {
    printf("Battery level = 100%%\n");
  } else if (level > 368) {
    buf1 = level - 368;
    buf1 *= 90;
    buf2 = 418 - 368;
    buf1 /= buf2;
    buf1 += 9;
    printf("Battery level = %d%%\n", buf1);
  } else if (level > 325) {
    buf1 = level - 325;
    buf1 *= 9;
    buf2 = 368 - 325;
    buf1 /= buf2;
    buf1 += 1;
    printf("Battery level = %d%%\n", buf1);
  } else {
    printf("Battery level = %d%%\n", 1);
  }
}


x86 assembly (clang, -O0):
<check_battery_level>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x1a2,-0x4(%rbp)
jle    113b <check_battery_level+0x2b>
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11fa <check_battery_level+0xea>
cmpl   $0x170,-0x4(%rbp)
jle    118c <check_battery_level+0x7c>
mov    -0x4(%rbp),%eax
sub    $0x170,%eax
mov    %eax,-0x8(%rbp)
imul   $0x5a,-0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
movl   $0x32,-0xc(%rbp)
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x9,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f5 <check_battery_level+0xe5>
cmpl   $0x145,-0x4(%rbp)
jle    11dd <check_battery_level+0xcd>
mov    -0x4(%rbp),%eax
sub    $0x145,%eax
mov    %eax,-0x8(%rbp)
imul   $0x9,-0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
movl   $0x2b,-0xc(%rbp)
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f0 <check_battery_level+0xe0>
lea    0xe33(%rip),%rdi
mov    $0x1,%esi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f5 <check_battery_level+0xe5>
jmp    11fa <check_battery_level+0xea>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_battery_level>:
cmp    $0x1a3,%edi
jl     1126 <check_battery_level+0x16>
lea    0xee1(%rip),%rdi
xor    %eax,%eax
jmp    1030 <printf@plt>
cmp    $0x171,%edi
jl     1149 <check_battery_level+0x39>
imul   $0x5a,%edi,%eax
add    $0x7ea0,%eax
movzwl %ax,%eax
shr    %eax
imul   $0x147b,%eax,%esi
shr    $0x11,%esi
add    $0x9,%esi
jmp    1168 <check_battery_level+0x58>
cmp    $0x146,%edi
jl     1176 <check_battery_level+0x66>
lea    (%rdi,%rdi,8),%eax
add    $0xfffff493,%eax
movzwl %ax,%eax
imul   $0xbe83,%eax,%esi
shr    $0x15,%esi
add    $0x1,%esi
lea    0xea8(%rip),%rdi
xor    %eax,%eax
jmp    1030 <printf@plt>
lea    0xe9a(%rip),%rdi
mov    $0x1,%esi
xor    %eax,%eax
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"Battery level = 100%%\0A\00"
@.str.1 = [22 x i8] c"Battery level = %d%%\0A\00"
define void @check_battery_level(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = icmp sgt i32 %5, 418
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %43
9: ; preds = %1
%10 = load i32, i32* %2
%11 = icmp sgt i32 %10, 368
br i1 %11, label %12, label %24
12: ; preds = %9
%13 = load i32, i32* %2
%14 = sub nsw i32 %13, 368
store i32 %14, i32* %3
%15 = load i32, i32* %3
%16 = mul nsw i32 %15, 90
store i32 %16, i32* %3
store i32 50, i32* %4
%17 = load i32, i32* %4
%18 = load i32, i32* %3
%19 = sdiv i32 %18, %17
store i32 %19, i32* %3
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 9
store i32 %21, i32* %3
%22 = load i32, i32* %3
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %22)
br label %42
24: ; preds = %9
%25 = load i32, i32* %2
%26 = icmp sgt i32 %25, 325
br i1 %26, label %27, label %39
27: ; preds = %24
%28 = load i32, i32* %2
%29 = sub nsw i32 %28, 325
store i32 %29, i32* %3
%30 = load i32, i32* %3
%31 = mul nsw i32 %30, 9
store i32 %31, i32* %3
store i32 43, i32* %4
%32 = load i32, i32* %4
%33 = load i32, i32* %3
%34 = sdiv i32 %33, %32
store i32 %34, i32* %3
%35 = load i32, i32* %3
%36 = add nsw i32 %35, 1
store i32 %36, i32* %3
%37 = load i32, i32* %3
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %37)
br label %41
39: ; preds = %24
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 1)
br label %41
41: ; preds = %39, %27
br label %42
42: ; preds = %41, %12
br label %43
43: ; preds = %42, %7
ret void
}

LLVM IR (-O2):
@.str = [23 x i8] c"Battery level = 100%%\0A\00"
@.str.1 = [22 x i8] c"Battery level = %d%%\0A\00"
define void @check_battery_level(i32 %0) {
%2 = icmp sgt i32 %0, 418
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %27
5: ; preds = %1
%6 = icmp sgt i32 %0, 368
br i1 %6, label %7, label %15
7: ; preds = %5
%8 = trunc i32 %0 to i16
%9 = mul nuw i16 %8, 90
%10 = add nsw i16 %9, 32416
%11 = udiv i16 %10, 50
%12 = add nuw nsw i16 %11, 9
%13 = zext i16 %12 to i32
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %13)
br label %27
15: ; preds = %5
%16 = icmp sgt i32 %0, 325
br i1 %16, label %17, label %25
17: ; preds = %15
%18 = trunc i32 %0 to i16
%19 = mul nuw nsw i16 %18, 9
%20 = add nsw i16 %19, -2925
%21 = udiv i16 %20, 43
%22 = add nuw nsw i16 %21, 1
%23 = zext i16 %22 to i32
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %23)
br label %27
25: ; preds = %15
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 1)
br label %27
27: ; preds = %7, %25, %17, %3
ret void
}