#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 */
size_t factors(int /*<<< orphan*/ *, int, char const);
size_t maxl(const char *string) {
  size_t i;
  size_t nmax = 1;
  size_t elnum;
  for (i = 0; *(string + i); i++) {
    elnum = factors(NULL, 10, 10);
    elnum += factors(NULL, 10, *(string + i) / 10);
    if (elnum > nmax)
      nmax = elnum;
    factors(NULL, 0, 0);
  }
  return nmax;
}


x86 assembly (clang, -O0):
<maxl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x1,-0x18(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     11b3 <maxl+0xa3>
xor    %eax,%eax
mov    %eax,%edi
mov    $0xa,%edx
mov    %edx,%esi
call   1030 <factors@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
xor    %ecx,%ecx
mov    %ecx,%edi
mov    $0xa,%esi
movsbl %al,%edx
call   1030 <factors@plt>
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jbe    1195 <maxl+0x85>
mov    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
mov    %eax,%edi
xor    %edx,%edx
mov    %edx,%esi
call   1030 <factors@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    112c <maxl+0x1c>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<maxl>:
push   %r15
push   %r14
push   %rbx
cmpb   $0x0,(%rdi)
je     1187 <maxl+0x77>
mov    %rdi,%r14
add    $0x1,%r14
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
xor    %edi,%edi
mov    $0xa,%esi
mov    $0xa,%edx
call   1030 <factors@plt>
mov    %rax,%r15
movsbl -0x1(%r14),%eax
imul   $0x67,%eax,%eax
movzwl %ax,%ecx
shr    $0xa,%eax
shr    $0xf,%ecx
add    %al,%cl
movsbl %cl,%edx
xor    %edi,%edi
mov    $0xa,%esi
call   1030 <factors@plt>
add    %r15,%rax
cmp    %rbx,%rax
cmova  %rax,%rbx
xor    %edi,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1030 <factors@plt>
cmpb   $0x0,(%r14)
lea    0x1(%r14),%r14
jne    1130 <maxl+0x20>
jmp    118c <maxl+0x7c>
mov    $0x1,%ebx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @maxl(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
store i8* %0, i8** %2
store i64 1, i64* %4
store i64 0, i64* %3
br label %6
6: ; preds = %31, %1
%7 = load i8*, i8** %2
%8 = load i64, i64* %3
%9 = getelementptr inbounds i8, i8* %7, i64 %8
%10 = load i8, i8* %9
%11 = icmp ne i8 %10, 0
br i1 %11, label %12, label %34
12: ; preds = %6
%13 = call i64 @factors(i32* null, i32 10, i8 signext 10)
store i64 %13, i64* %5
%14 = load i8*, i8** %2
%15 = load i64, i64* %3
%16 = getelementptr inbounds i8, i8* %14, i64 %15
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = sdiv i32 %18, 10
%20 = trunc i32 %19 to i8
%21 = call i64 @factors(i32* null, i32 10, i8 signext %20)
%22 = load i64, i64* %5
%23 = add i64 %22, %21
store i64 %23, i64* %5
%24 = load i64, i64* %5
%25 = load i64, i64* %4
%26 = icmp ugt i64 %24, %25
br i1 %26, label %27, label %29
27: ; preds = %12
%28 = load i64, i64* %5
store i64 %28, i64* %4
br label %29
29: ; preds = %27, %12
%30 = call i64 @factors(i32* null, i32 0, i8 signext 0)
br label %31
31: ; preds = %29
%32 = load i64, i64* %3
%33 = add i64 %32, 1
store i64 %33, i64* %3
br label %6
34: ; preds = %6
%35 = load i64, i64* %4
ret i64 %35
}

LLVM IR (-O2):
define i64 @maxl(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %20, label %4
4: ; preds = %1, %4
%5 = phi i8* [ %17, %4 ], [ %0, %1 ]
%6 = phi i64 [ %14, %4 ], [ 1, %1 ]
%7 = phi i64 [ %16, %4 ], [ 0, %1 ]
%8 = tail call i64 @factors(i32* null, i32 10, i8 signext 10)
%9 = load i8, i8* %5
%10 = sdiv i8 %9, 10
%11 = tail call i64 @factors(i32* null, i32 10, i8 signext %10)
%12 = add i64 %11, %8
%13 = icmp ugt i64 %12, %6
%14 = select i1 %13, i64 %12, i64 %6
%15 = tail call i64 @factors(i32* null, i32 0, i8 signext 0)
%16 = add i64 %7, 1
%17 = getelementptr inbounds i8, i8* %0, i64 %16
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 0
br i1 %19, label %20, label %4
20: ; preds = %4, %1
%21 = phi i64 [ 1, %1 ], [ %14, %4 ]
ret i64 %21
}