#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 */
float log10(float);
unsigned char lighten(unsigned char value, float power) {
  int val = value;
  float t = (float)val * log10(power) / 2.0;
  if (t > 0) {
    val = (int)t;
    if (val > 255)
      val = 255;
    if (val < 0)
      val = 0;
    return val;
  } else {
    return 0;
  }
}


x86 assembly (clang, -O0):
<lighten>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x2(%rbp)
movss  %xmm0,-0x8(%rbp)
movzbl -0x2(%rbp),%eax
mov    %eax,-0xc(%rbp)
cvtsi2ssl -0xc(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x8(%rbp),%xmm0
call   1030 <log10@plt>
movaps %xmm0,%xmm1
movss  -0x14(%rbp),%xmm0
mulss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xeaa(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    11ac <lighten+0x9c>
cvttss2si -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0xff,-0xc(%rbp)
jle    1190 <lighten+0x80>
movl   $0xff,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    11a1 <lighten+0x91>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %al,-0x1(%rbp)
jmp    11b0 <lighten+0xa0>
movb   $0x0,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lighten>:
push   %rax
cvtsi2ss %edi,%xmm1
movss  %xmm1,0x4(%rsp)
call   1030 <log10@plt>
mulss  0x4(%rsp),%xmm0
mulss  0xed2(%rip),%xmm0
xor    %eax,%eax
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    114f <lighten+0x3f>
cvttss2si %xmm0,%ecx
cmp    $0xff,%ecx
mov    $0xff,%edx
cmovl  %ecx,%edx
test   %edx,%edx
cmovg  %edx,%eax
pop    %rcx
ret

LLVM IR (-O0):
define zeroext i8 @lighten(i8 zeroext %0, float %1) {
%3 = alloca i8
%4 = alloca i8
%5 = alloca float
%6 = alloca i32
%7 = alloca float
store i8 %0, i8* %4
store float %1, float* %5
%8 = load i8, i8* %4
%9 = zext i8 %8 to i32
store i32 %9, i32* %6
%10 = load i32, i32* %6
%11 = sitofp i32 %10 to float
%12 = load float, float* %5
%13 = call float @log10(float %12)
%14 = fmul float %11, %13
%15 = fpext float %14 to double
%16 = fdiv double %15, 2.000000e+00
%17 = fptrunc double %16 to float
store float %17, float* %7
%18 = load float, float* %7
%19 = fcmp ogt float %18, 0.000000e+00
br i1 %19, label %20, label %33
20: ; preds = %2
%21 = load float, float* %7
%22 = fptosi float %21 to i32
store i32 %22, i32* %6
%23 = load i32, i32* %6
%24 = icmp sgt i32 %23, 255
br i1 %24, label %25, label %26
25: ; preds = %20
store i32 255, i32* %6
br label %26
26: ; preds = %25, %20
%27 = load i32, i32* %6
%28 = icmp slt i32 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %26
store i32 0, i32* %6
br label %30
30: ; preds = %29, %26
%31 = load i32, i32* %6
%32 = trunc i32 %31 to i8
store i8 %32, i8* %3
br label %34
33: ; preds = %2
store i8 0, i8* %3
br label %34
34: ; preds = %33, %30
%35 = load i8, i8* %3
ret i8 %35
}

LLVM IR (-O2):
define zeroext i8 @lighten(i8 zeroext %0, float %1) {
%3 = uitofp i8 %0 to float
%4 = tail call float @log10(float %1)
%5 = fmul float %4, %3
%6 = fmul float %5, 5.000000e-01
%7 = fcmp ogt float %6, 0.000000e+00
br i1 %7, label %8, label %15
8: ; preds = %2
%9 = fptosi float %6 to i32
%10 = icmp slt i32 %9, 255
%11 = select i1 %10, i32 %9, i32 255
%12 = icmp sgt i32 %11, 0
%13 = select i1 %12, i32 %11, i32 0
%14 = trunc i32 %13 to i8
br label %15
15: ; preds = %2, %8
%16 = phi i8 [ %14, %8 ], [ 0, %2 ]
ret i8 %16
}