#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 getWeightMaximalFactoring(char *, int /*<<< orphan*/, int, int **);
int /*<<< orphan*/ memset(int **, int, int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, char *);
scalar_t__ strlen(char *);
int main(void) {
  char inputStr[100 + 1];
  int memoTable[100][100];
  while (1) {
    scanf("%s", inputStr);
    if (inputStr[0] == '*')
      break;
    memset(memoTable, -1, 100 * 100 * sizeof(int));
    printf("%d\n", getWeightMaximalFactoring(
                       inputStr, 0, (int)strlen(inputStr) - 1, memoTable));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x9cc0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x70(%rbp),%rsi
lea    0xe93(%rip),%rdi
call   1070 <scanf@plt>
movsbl -0x70(%rbp),%eax
cmp    $0x2a,%eax
jne    1184 <main+0x34>
jmp    11db <main+0x8b>
lea    -0x9cb0(%rbp),%rdi
mov    $0xffffffff,%esi
mov    $0x9c40,%edx
call   1060 <memset@plt>
lea    -0x70(%rbp),%rax
mov    %rax,-0x9cb8(%rbp)
lea    -0x70(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x9cb8(%rbp),%rdi
mov    %eax,%edx
sub    $0x1,%edx
lea    -0x9cb0(%rbp),%rcx
xor    %esi,%esi
call   1030 <getWeightMaximalFactoring@plt>
mov    %eax,%esi
lea    0xe32(%rip),%rdi
call   1050 <printf@plt>
jmp    1162 <main+0x12>
xor    %eax,%eax
add    $0x9cc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x9cb8,%rsp
lea    0xe9b(%rip),%rdi
mov    %rsp,%rsi
call   1070 <scanf@plt>
cmpb   $0x2a,(%rsp)
je     11d5 <main+0x85>
lea    0x70(%rsp),%r14
mov    %rsp,%rbx
lea    0xe81(%rip),%r15
lea    0xe77(%rip),%r12
nopl   0x0(%rax)
mov    %r14,%rdi
mov    $0xffffffff,%esi
mov    $0x9c40,%edx
call   1060 <memset@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    -0x1(%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
mov    %r14,%rcx
call   1030 <getWeightMaximalFactoring@plt>
mov    %r15,%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
cmpb   $0x2a,(%rsp)
jne    1190 <main+0x40>
xor    %eax,%eax
add    $0x9cb8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [101 x i8]
%3 = alloca [100 x [100 x i32]]
store i32 0, i32* %1
br label %4
4: ; preds = %0, %12
%5 = getelementptr inbounds [101 x i8], [101 x i8]* %2, i64 0, i64 0
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = getelementptr inbounds [101 x i8], [101 x i8]* %2, i64 0, i64 0
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 42
br i1 %10, label %11, label %12
11: ; preds = %4
br label %25
12: ; preds = %4
%13 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %3, i64 0, i64 0
%14 = bitcast [100 x i32]* %13 to i32**
%15 = call i32 @memset(i32** %14, i32 -1, i32 40000)
%16 = getelementptr inbounds [101 x i8], [101 x i8]* %2, i64 0, i64 0
%17 = getelementptr inbounds [101 x i8], [101 x i8]* %2, i64 0, i64 0
%18 = call i64 @strlen(i8* %17)
%19 = trunc i64 %18 to i32
%20 = sub nsw i32 %19, 1
%21 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %3, i64 0, i64 0
%22 = bitcast [100 x i32]* %21 to i32**
%23 = call i32 @getWeightMaximalFactoring(i8* %16, i32 0, i32 %20, i32** %22)
%24 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %23)
br label %4
25: ; preds = %11
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [101 x i8]
%2 = alloca [100 x [100 x i32]]
%3 = getelementptr inbounds [101 x i8], [101 x i8]* %1, i64 0, i64 0
%4 = bitcast [100 x [100 x i32]]* %2 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
%6 = load i8, i8* %3
%7 = icmp eq i8 %6, 42
br i1 %7, label %20, label %8
8: ; preds = %0
%9 = bitcast [100 x [100 x i32]]* %2 to i32**
br label %10
10: ; preds = %8, %10
%11 = call i32 @memset(i32** %9, i32 -1, i32 40000)
%12 = call i64 @strlen(i8* %3)
%13 = trunc i64 %12 to i32
%14 = add nsw i32 %13, -1
%15 = call i32 @getWeightMaximalFactoring(i8* %3, i32 0, i32 %14, i32** %9)
%16 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
%18 = load i8, i8* %3
%19 = icmp eq i8 %18, 42
br i1 %19, label %20, label %10
20: ; preds = %10, %0
ret i32 0
}