#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*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ memcpy(char *, char *, int);
char **realloc(char **, size_t);
int strlen(char *);
void recurse_process(char *s, char *digits, char ***result, int *num) {
  static int Len[10] = {1, 1, 3, 3, 3, 3, 3, 4, 3, 4};
  static char *String[] = {"",    "",    "abc",  "def", "ghi",
                           "jkl", "mno", "pqrs", "tuv", "wxyz"};
  if (*digits == '\0') {
    (*num)++;
    *result = realloc(*result, (size_t)(*num * sizeof(long)));
    (*result)[*num - 1] = s;
    return;
  }
  int i = 0;
  int index = *digits - '0';
  int slen = (!s) ? 0 : strlen(s);
  for (i = 0; i < Len[index]; i++) {
    char *tmp = malloc(slen + 2);
    memcpy(tmp, s, slen);
    tmp[slen] = String[index][i];
    tmp[slen + 1] = '\0';
    recurse_process(tmp, digits + 1, result, num);
  }
  if (s)
    free(s);
}


x86 assembly (clang, -O0):
<recurse_process>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11d4 <recurse_process+0x74>
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x20(%rbp),%rax
movslq (%rax),%rsi
shl    $0x3,%rsi
call   1070 <realloc@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rdx
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    -0x20(%rbp),%rcx
mov    (%rcx),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
jmp    12b9 <recurse_process+0x159>
movl   $0x0,-0x24(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
sub    $0x30,%eax
mov    %eax,-0x28(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    11fd <recurse_process+0x9d>
xor    %eax,%eax
mov    %eax,-0x3c(%rbp)
jmp    1209 <recurse_process+0xa9>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
movslq -0x28(%rbp),%rdx
lea    0x2e3c(%rip),%rcx
cmp    (%rcx,%rdx,4),%eax
jge    12a5 <recurse_process+0x145>
mov    -0x2c(%rbp),%edi
add    $0x2,%edi
call   1060 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x2c(%rbp),%edx
call   1050 <memcpy@plt>
movslq -0x28(%rbp),%rcx
lea    0x2e39(%rip),%rax
mov    (%rax,%rcx,8),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x38(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x38(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x38(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x1,%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1080 <recurse_process@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1216 <recurse_process+0xb6>
cmpq   $0x0,-0x8(%rbp)
je     12b9 <recurse_process+0x159>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<recurse_process>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rcx,%r14
mov    %rdx,%r13
mov    %rdi,%r12
movsbq (%rsi),%rbx
test   %rbx,%rbx
je     119e <recurse_process+0x3e>
mov    %rsi,%rbp
mov    %r14,%r15
lea    -0x30(%rbx),%r14
test   %r12,%r12
mov    %r12,0x8(%rsp)
je     11ca <recurse_process+0x6a>
mov    %r12,%rdi
call   1040 <strlen@plt>
jmp    11cc <recurse_process+0x6c>
movslq (%r14),%rax
lea    0x1(%rax),%rcx
mov    %ecx,(%r14)
mov    0x0(%r13),%rdi
lea    0x8(,%rax,8),%rsi
call   1070 <realloc@plt>
mov    %rax,0x0(%r13)
movslq (%r14),%rcx
mov    %r12,-0x8(%rax,%rcx,8)
jmp    128f <recurse_process+0x12f>
xor    %eax,%eax
lea    0xe2d(%rip),%rcx
mov    -0xc0(%rcx,%rbx,4),%ecx
shl    $0x2,%r14
movslq %eax,%rbx
add    $0x2,%eax
mov    %eax,0x4(%rsp)
add    $0x1,%rbp
mov    %rbp,0x18(%rsp)
cmp    $0x2,%ecx
mov    $0x1,%eax
cmovge %ecx,%eax
mov    %rax,0x20(%rsp)
xor    %r12d,%r12d
lea    0xe1d(%rip),%rax
movslq (%r14,%rax,1),%rax
mov    %rax,0x10(%rsp)
mov    0x8(%rsp),%rbp
nopl   0x0(%rax)
mov    0x4(%rsp),%edi
call   1060 <malloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    %rbp,%rsi
mov    %ebx,%edx
call   1050 <memcpy@plt>
mov    0x10(%rsp),%rax
add    %r12,%rax
lea    0xde0(%rip),%rcx
movzbl (%rcx,%rax,1),%eax
mov    %al,(%r14,%rbx,1)
movb   $0x0,0x1(%r14,%rbx,1)
mov    %r14,%rdi
mov    0x18(%rsp),%rsi
mov    %r13,%rdx
mov    %r15,%rcx
call   1080 <recurse_process@plt>
add    $0x1,%r12
cmp    %r12,0x20(%rsp)
jne    1220 <recurse_process+0xc0>
test   %rbp,%rbp
je     128f <recurse_process+0x12f>
mov    %rbp,%rdi
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@recurse_process.Len = internal global [10 x i32] [i32 1, i32 1, i32 3, i32 3, i32 3, i32 3, i32 3, i32 4, i32 3, i32 4]
@recurse_process.String = internal global [10 x i8*] [i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i32 0, i32 0)]
@.str = [1 x i8] zeroinitializer
@.str.1 = [4 x i8] c"abc\00"
@.str.2 = [4 x i8] c"def\00"
@.str.3 = [4 x i8] c"ghi\00"
@.str.4 = [4 x i8] c"jkl\00"
@.str.5 = [4 x i8] c"mno\00"
@.str.6 = [5 x i8] c"pqrs\00"
@.str.7 = [4 x i8] c"tuv\00"
@.str.8 = [5 x i8] c"wxyz\00"
define void @recurse_process(i8* %0, i8* %1, i8*** %2, i32* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8***
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8*** %2, i8**** %7
store i32* %3, i32** %8
%13 = load i8*, i8** %6
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %37
17: ; preds = %4
%18 = load i32*, i32** %8
%19 = load i32, i32* %18
%20 = add nsw i32 %19, 1
store i32 %20, i32* %18
%21 = load i8***, i8**** %7
%22 = load i8**, i8*** %21
%23 = load i32*, i32** %8
%24 = load i32, i32* %23
%25 = sext i32 %24 to i64
%26 = mul i64 %25, 8
%27 = call i8** @realloc(i8** %22, i64 %26)
%28 = load i8***, i8**** %7
store i8** %27, i8*** %28
%29 = load i8*, i8** %5
%30 = load i8***, i8**** %7
%31 = load i8**, i8*** %30
%32 = load i32*, i32** %8
%33 = load i32, i32* %32
%34 = sub nsw i32 %33, 1
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8*, i8** %31, i64 %35
store i8* %29, i8** %36
br label %96
37: ; preds = %4
store i32 0, i32* %9
%38 = load i8*, i8** %6
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = sub nsw i32 %40, 48
store i32 %41, i32* %10
%42 = load i8*, i8** %5
%43 = icmp ne i8* %42, null
br i1 %43, label %45, label %44
44: ; preds = %37
br label %48
45: ; preds = %37
%46 = load i8*, i8** %5
%47 = call i32 @strlen(i8* %46)
br label %48
48: ; preds = %45, %44
%49 = phi i32 [ 0, %44 ], [ %47, %45 ]
store i32 %49, i32* %11
store i32 0, i32* %9
br label %50
50: ; preds = %87, %48
%51 = load i32, i32* %9
%52 = load i32, i32* %10
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [10 x i32], [10 x i32]* @recurse_process.Len, i64 0, i64 %53
%55 = load i32, i32* %54
%56 = icmp slt i32 %51, %55
br i1 %56, label %57, label %90
57: ; preds = %50
%58 = load i32, i32* %11
%59 = add nsw i32 %58, 2
%60 = call i8* @malloc(i32 %59)
store i8* %60, i8** %12
%61 = load i8*, i8** %12
%62 = load i8*, i8** %5
%63 = load i32, i32* %11
%64 = call i32 @memcpy(i8* %61, i8* %62, i32 %63)
%65 = load i32, i32* %10
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [10 x i8*], [10 x i8*]* @recurse_process.String, i64 0, i64 %66
%68 = load i8*, i8** %67
%69 = load i32, i32* %9
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i8, i8* %68, i64 %70
%72 = load i8, i8* %71
%73 = load i8*, i8** %12
%74 = load i32, i32* %11
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds i8, i8* %73, i64 %75
store i8 %72, i8* %76
%77 = load i8*, i8** %12
%78 = load i32, i32* %11
%79 = add nsw i32 %78, 1
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds i8, i8* %77, i64 %80
store i8 0, i8* %81
%82 = load i8*, i8** %12
%83 = load i8*, i8** %6
%84 = getelementptr inbounds i8, i8* %83, i64 1
%85 = load i8***, i8**** %7
%86 = load i32*, i32** %8
br label %87
87: ; preds = %57
%88 = load i32, i32* %9
%89 = add nsw i32 %88, 1
store i32 %89, i32* %9
br label %50
90: ; preds = %50
%91 = load i8*, i8** %5
%92 = icmp ne i8* %91, null
br i1 %92, label %93, label %96
93: ; preds = %90
%94 = load i8*, i8** %5
%95 = call i32 @free(i8* %94)
br label %96
96: ; preds = %17, %93, %90
ret void
}

LLVM IR (-O2):
@recurse_process.Len = internal unnamed_addr constant [10 x i32] [i32 1, i32 1, i32 3, i32 3, i32 3, i32 3, i32 3, i32 4, i32 3, i32 4]
@reltable.recurse_process = internal unnamed_addr constant [10 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([1 x i8]* @.str to i64), i64 ptrtoint ([10 x i32]* @reltable.recurse_process to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([1 x i8]* @.str to i64), i64 ptrtoint ([10 x i32]* @reltable.recurse_process to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.1 to i64), i64 ptrtoint ([10 x i32]* @reltable.recurse_process to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.2 to i64), i64 ptrtoint ([10 x i32]* @reltable.recurse_process to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.3 to i64), i64 ptrtoint ([10 x i32]* @reltable.recurse_process to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.4 to i64), i64 ptrtoint ([10 x i32]* @reltable.recurse_process to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.5 to i64), i64 ptrtoint ([10 x i32]* @reltable.recurse_process to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.6 to i64), i64 ptrtoint ([10 x i32]* @reltable.recurse_process to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.7 to i64), i64 ptrtoint ([10 x i32]* @reltable.recurse_process to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.8 to i64), i64 ptrtoint ([10 x i32]* @reltable.recurse_process to i64)) to i32)]
@.str = [1 x i8] zeroinitializer
@.str.1 = [4 x i8] c"abc\00"
@.str.2 = [4 x i8] c"def\00"
@.str.3 = [4 x i8] c"ghi\00"
@.str.4 = [4 x i8] c"jkl\00"
@.str.5 = [4 x i8] c"mno\00"
@.str.6 = [5 x i8] c"pqrs\00"
@.str.7 = [4 x i8] c"tuv\00"
@.str.8 = [5 x i8] c"wxyz\00"
define void @recurse_process(i8* %0, i8* nocapture %1, i8*** nocapture %2, i32* nocapture %3) {
%5 = load i8, i8* %1
%6 = icmp eq i8 %5, 0
br i1 %6, label %7, label %18
7: ; preds = %4
%8 = load i32, i32* %3
%9 = add nsw i32 %8, 1
store i32 %9, i32* %3
%10 = load i8**, i8*** %2
%11 = sext i32 %9 to i64
%12 = shl nsw i64 %11, 3
%13 = tail call i8** @realloc(i8** %10, i64 %12)
store i8** %13, i8*** %2
%14 = load i32, i32* %3
%15 = add nsw i32 %14, -1
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8*, i8** %13, i64 %16
store i8* %0, i8** %17
br label %50
18: ; preds = %4
%19 = sext i8 %5 to i64
%20 = add nsw i64 %19, -48
%21 = icmp eq i8* %0, null
br i1 %21, label %24, label %22
22: ; preds = %18
%23 = tail call i32 @strlen(i8* %0)
br label %24
24: ; preds = %22, %18
%25 = phi i32 [ %23, %22 ], [ 0, %18 ]
%26 = getelementptr inbounds [10 x i32], [10 x i32]* @recurse_process.Len, i64 0, i64 %20
%27 = load i32, i32* %26
%28 = add nsw i32 %25, 2
%29 = shl i64 %20, 2
%30 = sext i32 %25 to i64
%31 = add nsw i32 %25, 1
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %1, i64 1
%34 = call i32 @llvm.smax.i32(i32 %27, i32 1)
%35 = zext i32 %34 to i64
br label %36
36: ; preds = %24, %36
%37 = phi i64 [ 0, %24 ], [ %45, %36 ]
%38 = tail call i8* @malloc(i32 %28)
%39 = tail call i32 @memcpy(i8* %38, i8* %0, i32 %25)
%40 = call i8* @llvm.load.relative.i64(i8* bitcast ([10 x i32]* @reltable.recurse_process to i8*), i64 %29)
%41 = getelementptr inbounds i8, i8* %40, i64 %37
%42 = load i8, i8* %41
%43 = getelementptr inbounds i8, i8* %38, i64 %30
store i8 %42, i8* %43
%44 = getelementptr inbounds i8, i8* %38, i64 %32
store i8 0, i8* %44
tail call void @recurse_process(i8* %38, i8* %33, i8*** %2, i32* %3)
%45 = add nuw nsw i64 %37, 1
%46 = icmp eq i64 %45, %35
br i1 %46, label %47, label %36
47: ; preds = %36
br i1 %21, label %50, label %48
48: ; preds = %47
%49 = tail call i32 @free(i8* %0)
br label %50
50: ; preds = %47, %48, %7
ret void
}