#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 LONG_MAX;
int long_len(const unsigned long l) {
  int len;
  long size[] = {0,      9,       99,       999,       9999,    99999,
                 999999, 9999999, 99999999, 999999999, LONG_MAX};
  for (len = 0; l > size[len]; len++)
    ;
  if (len) {
    len++;
  }
  return len;
}


x86 assembly (clang, -O0):
<long_len>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x70(%rbp)
movq   $0x9,-0x68(%rbp)
movq   $0x63,-0x60(%rbp)
movq   $0x3e7,-0x58(%rbp)
movq   $0x270f,-0x50(%rbp)
movq   $0x1869f,-0x48(%rbp)
movq   $0xf423f,-0x40(%rbp)
movq   $0x98967f,-0x38(%rbp)
movq   $0x5f5e0ff,-0x30(%rbp)
05
movq   $0x3b9ac9ff,-0x28(%rbp)
3b
mov    0x2e81(%rip),%rax
movslq (%rax),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
cmp    -0x70(%rbp,%rcx,8),%rax
jbe    1193 <long_len+0x93>
jmp    1185 <long_len+0x85>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    116d <long_len+0x6d>
cmpl   $0x0,-0xc(%rbp)
je     11a6 <long_len+0xa6>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<long_len>:
movaps 0xef9(%rip),%xmm0
movaps %xmm0,-0x58(%rsp)
movaps 0xefd(%rip),%xmm0
movaps %xmm0,-0x48(%rsp)
movaps 0xf01(%rip),%xmm0
movaps %xmm0,-0x38(%rsp)
movaps 0xf05(%rip),%xmm0
movaps %xmm0,-0x28(%rsp)
movaps 0xf09(%rip),%xmm0
movaps %xmm0,-0x18(%rsp)
mov    0x2e9d(%rip),%rax
movslq (%rax),%rax
mov    %rax,-0x8(%rsp)
test   %rdi,%rdi
je     1170 <long_len+0x70>
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0x1(%rax),%rcx
cmp    %rdi,-0x50(%rsp,%rax,8)
mov    %rcx,%rax
jb     1160 <long_len+0x60>
jmp    1172 <long_len+0x72>
xor    %ecx,%ecx
lea    0x1(%rcx),%eax
test   %ecx,%ecx
cmove  %ecx,%eax
ret

LLVM IR (-O0):
@LONG_MAX = global i32 0
define i32 @long_len(i64 %0) {
%2 = alloca i64
%3 = alloca i32
%4 = alloca [11 x i64]
store i64 %0, i64* %2
%5 = getelementptr inbounds [11 x i64], [11 x i64]* %4, i64 0, i64 0
store i64 0, i64* %5
%6 = getelementptr inbounds i64, i64* %5, i64 1
store i64 9, i64* %6
%7 = getelementptr inbounds i64, i64* %6, i64 1
store i64 99, i64* %7
%8 = getelementptr inbounds i64, i64* %7, i64 1
store i64 999, i64* %8
%9 = getelementptr inbounds i64, i64* %8, i64 1
store i64 9999, i64* %9
%10 = getelementptr inbounds i64, i64* %9, i64 1
store i64 99999, i64* %10
%11 = getelementptr inbounds i64, i64* %10, i64 1
store i64 999999, i64* %11
%12 = getelementptr inbounds i64, i64* %11, i64 1
store i64 9999999, i64* %12
%13 = getelementptr inbounds i64, i64* %12, i64 1
store i64 99999999, i64* %13
%14 = getelementptr inbounds i64, i64* %13, i64 1
store i64 999999999, i64* %14
%15 = getelementptr inbounds i64, i64* %14, i64 1
%16 = load i32, i32* @LONG_MAX
%17 = sext i32 %16 to i64
store i64 %17, i64* %15
store i32 0, i32* %3
br label %18
18: ; preds = %26, %1
%19 = load i64, i64* %2
%20 = load i32, i32* %3
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [11 x i64], [11 x i64]* %4, i64 0, i64 %21
%23 = load i64, i64* %22
%24 = icmp ugt i64 %19, %23
br i1 %24, label %25, label %29
25: ; preds = %18
br label %26
26: ; preds = %25
%27 = load i32, i32* %3
%28 = add nsw i32 %27, 1
store i32 %28, i32* %3
br label %18
29: ; preds = %18
%30 = load i32, i32* %3
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %29
%33 = load i32, i32* %3
%34 = add nsw i32 %33, 1
store i32 %34, i32* %3
br label %35
35: ; preds = %32, %29
%36 = load i32, i32* %3
ret i32 %36
}

LLVM IR (-O2):
@LONG_MAX = global i32 0
define i32 @long_len(i64 %0) {
%2 = alloca [11 x i64]
%3 = bitcast [11 x i64]* %2 to i8*
%4 = bitcast [11 x i64]* %2 to <2 x i64>*
store <2 x i64> <i64 0, i64 9>, <2 x i64>* %4
%5 = getelementptr inbounds [11 x i64], [11 x i64]* %2, i64 0, i64 2
%6 = bitcast i64* %5 to <2 x i64>*
store <2 x i64> <i64 99, i64 999>, <2 x i64>* %6
%7 = getelementptr inbounds [11 x i64], [11 x i64]* %2, i64 0, i64 4
%8 = bitcast i64* %7 to <2 x i64>*
store <2 x i64> <i64 9999, i64 99999>, <2 x i64>* %8
%9 = getelementptr inbounds [11 x i64], [11 x i64]* %2, i64 0, i64 6
%10 = bitcast i64* %9 to <2 x i64>*
store <2 x i64> <i64 999999, i64 9999999>, <2 x i64>* %10
%11 = getelementptr inbounds [11 x i64], [11 x i64]* %2, i64 0, i64 8
%12 = bitcast i64* %11 to <2 x i64>*
store <2 x i64> <i64 99999999, i64 999999999>, <2 x i64>* %12
%13 = getelementptr inbounds [11 x i64], [11 x i64]* %2, i64 0, i64 10
%14 = load i32, i32* @LONG_MAX
%15 = sext i32 %14 to i64
store i64 %15, i64* %13
%16 = icmp eq i64 %0, 0
br i1 %16, label %23, label %17
17: ; preds = %1, %17
%18 = phi i64 [ %22, %17 ], [ 1, %1 ]
%19 = getelementptr inbounds [11 x i64], [11 x i64]* %2, i64 0, i64 %18
%20 = load i64, i64* %19
%21 = icmp ult i64 %20, %0
%22 = add nuw i64 %18, 1
br i1 %21, label %17, label %23
23: ; preds = %17, %1
%24 = phi i64 [ 0, %1 ], [ %18, %17 ]
%25 = trunc i64 %24 to i32
%26 = icmp eq i32 %25, 0
%27 = add nuw nsw i32 %25, 1
%28 = select i1 %26, i32 0, i32 %27
ret i32 %28
}