#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) {
  long 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    $0x20,%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    1218 <check_battery_level+0x108>
cmpl   $0x170,-0x4(%rbp)
jle    119b <check_battery_level+0x8b>
mov    -0x4(%rbp),%eax
sub    $0x170,%eax
cltq
mov    %rax,-0x10(%rbp)
imul   $0x5a,-0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
movq   $0x32,-0x18(%rbp)
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%rax
cqto
idiv   %rcx
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x9,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1213 <check_battery_level+0x103>
cmpl   $0x145,-0x4(%rbp)
jle    11fb <check_battery_level+0xeb>
mov    -0x4(%rbp),%eax
sub    $0x145,%eax
cltq
mov    %rax,-0x10(%rbp)
imul   $0x9,-0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
movq   $0x2b,-0x18(%rbp)
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%rax
cqto
idiv   %rcx
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    120e <check_battery_level+0xfe>
lea    0xe14(%rip),%rdi
mov    $0x1,%esi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1213 <check_battery_level+0x103>
jmp    1218 <check_battery_level+0x108>
add    $0x20,%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    0xea7(%rip),%rdi
xor    %eax,%eax
jmp    1030 <printf@plt>
lea    0xe99(%rip),%rdi
mov    $0x1,%esi
xor    %eax,%eax
jmp    1030 <printf@plt>

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

LLVM IR (-O2):
@.str = [22 x i8] c"Battery level = 100%\0A\00"
@.str.1 = [21 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 ([22 x i8], [22 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 i64
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i64 %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 i64
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i64 %23)
br label %27
25: ; preds = %15
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 1)
br label %27
27: ; preds = %7, %25, %17, %3
ret void
}