#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 ceil(unsigned int);
unsigned int log(int);
unsigned PrintedLengthInRadix(unsigned bitCount, int radix) {
  if (bitCount == 0)
    bitCount = 1;
  if (radix < 0) {
    bitCount--;
    if (bitCount == 0)
      bitCount = 1;
    radix = -radix;
  }
  return ceil(bitCount * (log(2) / log(radix)));
}


x86 assembly (clang, -O0):
<PrintedLengthInRadix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    113f <PrintedLengthInRadix+0x1f>
movl   $0x1,-0x4(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    116b <PrintedLengthInRadix+0x4b>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1163 <PrintedLengthInRadix+0x43>
movl   $0x1,-0x4(%rbp)
xor    %eax,%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    $0x2,%edi
call   1040 <log@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <log@plt>
mov    -0x10(%rbp),%edi
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
xor    %edx,%edx
div    %ecx
imul   %eax,%edi
call   1030 <ceil@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PrintedLengthInRadix>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebx
test   %edi,%edi
mov    $0x1,%eax
cmove  %eax,%ebx
mov    %ebx,%ecx
add    $0xffffffff,%ecx
cmove  %eax,%ecx
test   %esi,%esi
cmovs  %ecx,%ebx
mov    %esi,%ebp
neg    %ebp
cmovs  %esi,%ebp
mov    $0x2,%edi
call   1040 <log@plt>
mov    %eax,%r14d
mov    %ebp,%edi
call   1040 <log@plt>
mov    %eax,%ecx
mov    %r14d,%eax
xor    %edx,%edx
div    %ecx
imul   %eax,%ebx
mov    %ebx,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <ceil@plt>

LLVM IR (-O0):
define i32 @PrintedLengthInRadix(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %3
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %2
store i32 1, i32* %3
br label %8
8: ; preds = %7, %2
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %20
11: ; preds = %8
%12 = load i32, i32* %3
%13 = add i32 %12, -1
store i32 %13, i32* %3
%14 = load i32, i32* %3
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %11
store i32 1, i32* %3
br label %17
17: ; preds = %16, %11
%18 = load i32, i32* %4
%19 = sub nsw i32 0, %18
store i32 %19, i32* %4
br label %20
20: ; preds = %17, %8
%21 = load i32, i32* %3
%22 = call i32 @log(i32 2)
%23 = load i32, i32* %4
%24 = call i32 @log(i32 %23)
%25 = udiv i32 %22, %24
%26 = mul i32 %21, %25
%27 = call i32 @ceil(i32 %26)
ret i32 %27
}

LLVM IR (-O2):
define i32 @PrintedLengthInRadix(i32 %0, i32 %1) {
%3 = icmp eq i32 %0, 0
%4 = select i1 %3, i32 1, i32 %0
%5 = icmp slt i32 %1, 0
%6 = add i32 %4, -1
%7 = icmp eq i32 %6, 0
%8 = select i1 %7, i32 1, i32 %6
%9 = sub nsw i32 0, %1
%10 = select i1 %5, i32 %8, i32 %4
%11 = select i1 %5, i32 %9, i32 %1
%12 = tail call i32 @log(i32 2)
%13 = tail call i32 @log(i32 %11)
%14 = udiv i32 %12, %13
%15 = mul i32 %14, %10
%16 = tail call i32 @ceil(i32 %15)
ret i32 %16
}