#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*/ assert(int);
int Aig_Base10Log(unsigned n) {
  int r;
  assert(n >= 0);
  if (n < 2)
    return n;
  for (r = 0, n--; n; n /= 10, r++)
    ;
  return r;
}


x86 assembly (clang, -O0):
<Aig_Base10Log>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
setae  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x2,-0x8(%rbp)
jae    1141 <Aig_Base10Log+0x31>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1183 <Aig_Base10Log+0x73>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     117d <Aig_Base10Log+0x6d>
jmp    1160 <Aig_Base10Log+0x50>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1151 <Aig_Base10Log+0x41>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Aig_Base10Log>:
push   %rbx
mov    %edi,%ebx
mov    $0x1,%edi
call   1030 <assert@plt>
cmp    $0x2,%ebx
jb     1144 <Aig_Base10Log+0x34>
mov    %ebx,%eax
add    $0xffffffff,%eax
xor    %ebx,%ebx
mov    $0xcccccccd,%ecx
xchg   %ax,%ax
mov    %eax,%edx
imul   %rcx,%rdx
shr    $0x23,%rdx
add    $0x1,%ebx
cmp    $0x9,%eax
mov    %edx,%eax
ja     1130 <Aig_Base10Log+0x20>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @Aig_Base10Log(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = icmp uge i32 %5, 0
%7 = zext i1 %6 to i32
%8 = call i32 @assert(i32 %7)
%9 = load i32, i32* %3
%10 = icmp ult i32 %9, 2
br i1 %10, label %11, label %13
11: ; preds = %1
%12 = load i32, i32* %3
store i32 %12, i32* %2
br label %27
13: ; preds = %1
store i32 0, i32* %4
%14 = load i32, i32* %3
%15 = add i32 %14, -1
store i32 %15, i32* %3
br label %16
16: ; preds = %20, %13
%17 = load i32, i32* %3
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %25
19: ; preds = %16
br label %20
20: ; preds = %19
%21 = load i32, i32* %3
%22 = udiv i32 %21, 10
store i32 %22, i32* %3
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 1
store i32 %24, i32* %4
br label %16
25: ; preds = %16
%26 = load i32, i32* %4
store i32 %26, i32* %2
br label %27
27: ; preds = %25, %11
%28 = load i32, i32* %2
ret i32 %28
}

LLVM IR (-O2):
define i32 @Aig_Base10Log(i32 %0) {
%2 = tail call i32 @assert(i32 1)
%3 = icmp ult i32 %0, 2
br i1 %3, label %12, label %4
4: ; preds = %1
%5 = add i32 %0, -1
br label %6
6: ; preds = %4, %6
%7 = phi i32 [ %10, %6 ], [ 0, %4 ]
%8 = phi i32 [ %9, %6 ], [ %5, %4 ]
%9 = udiv i32 %8, 10
%10 = add nuw nsw i32 %7, 1
%11 = icmp ult i32 %8, 10
br i1 %11, label %12, label %6
12: ; preds = %6, %1
%13 = phi i32 [ %0, %1 ], [ %10, %6 ]
ret i32 %13
}