#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*/ align(char **, char **);
char *column_mul(char *, char *);
char *combine(char **, char **, char **, int);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ split(char *, int, char **, char **);
int strlen(char *);
char *sub(char **, char **);
char *sum(char **, char **);
char *karatsuba(char **number1, char **number2) {
  char *x, *y;
  char *a, *b, *c, *d;
  char *z1, *z2;
  char *z3, *z31, *z32, *z3_tmp1, *z3_tmp2;
  char *res;
  int n;
  align(number1, number2);
  x = *number1;
  y = *number2;
  n = strlen(x);
  if (n <= 4) {
    return column_mul(x, y);
  }
  split(x, n, &a, &b);
  split(y, n, &c, &d);
  z1 = karatsuba(&a, &c);
  z2 = karatsuba(&b, &d);
  z31 = sum(&a, &b);
  z32 = sum(&c, &d);
  z3_tmp1 = karatsuba(&z31, &z32);
  z3_tmp2 = sub(&z3_tmp1, &z2);
  z3 = sub(&z3_tmp2, &z1);
  res = combine(&z1, &z2, &z3, n);
  free(a);
  free(b);
  free(c);
  free(d);
  free(z1);
  free(z2);
  free(z31);
  free(z32);
  free(z3);
  free(z3_tmp1);
  free(z3_tmp2);
  return res;
}


x86 assembly (clang, -O0):
<karatsuba>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1080 <align@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x8c(%rbp)
cmpl   $0x4,-0x8c(%rbp)
jg     11f8 <karatsuba+0x68>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1070 <column_mul@plt>
mov    %rax,-0x8(%rbp)
jmp    1329 <karatsuba+0x199>
mov    -0x20(%rbp),%rdi
mov    -0x8c(%rbp),%esi
lea    -0x30(%rbp),%rdx
lea    -0x38(%rbp),%rcx
call   1090 <split@plt>
mov    -0x28(%rbp),%rdi
mov    -0x8c(%rbp),%esi
lea    -0x40(%rbp),%rdx
lea    -0x48(%rbp),%rcx
call   1090 <split@plt>
lea    -0x30(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1030 <karatsuba@plt>
mov    %rax,-0x50(%rbp)
lea    -0x38(%rbp),%rdi
lea    -0x48(%rbp),%rsi
call   1030 <karatsuba@plt>
mov    %rax,-0x58(%rbp)
lea    -0x30(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   10a0 <sum@plt>
mov    %rax,-0x68(%rbp)
lea    -0x40(%rbp),%rdi
lea    -0x48(%rbp),%rsi
call   10a0 <sum@plt>
mov    %rax,-0x70(%rbp)
lea    -0x68(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1030 <karatsuba@plt>
mov    %rax,-0x78(%rbp)
lea    -0x78(%rbp),%rdi
lea    -0x58(%rbp),%rsi
call   10b0 <sub@plt>
mov    %rax,-0x80(%rbp)
lea    -0x80(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   10b0 <sub@plt>
mov    %rax,-0x60(%rbp)
mov    -0x8c(%rbp),%ecx
lea    -0x50(%rbp),%rdi
lea    -0x58(%rbp),%rsi
lea    -0x60(%rbp),%rdx
call   1060 <combine@plt>
mov    %rax,-0x88(%rbp)
mov    -0x30(%rbp),%rdi
call   1040 <free@plt>
mov    -0x38(%rbp),%rdi
call   1040 <free@plt>
mov    -0x40(%rbp),%rdi
call   1040 <free@plt>
mov    -0x48(%rbp),%rdi
call   1040 <free@plt>
mov    -0x50(%rbp),%rdi
call   1040 <free@plt>
mov    -0x58(%rbp),%rdi
call   1040 <free@plt>
mov    -0x68(%rbp),%rdi
call   1040 <free@plt>
mov    -0x70(%rbp),%rdi
call   1040 <free@plt>
mov    -0x60(%rbp),%rdi
call   1040 <free@plt>
mov    -0x78(%rbp),%rdi
call   1040 <free@plt>
mov    -0x80(%rbp),%rdi
call   1040 <free@plt>
mov    -0x88(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<karatsuba>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rsi,%rbx
mov    %rdi,%rbp
call   1080 <align@plt>
mov    0x0(%rbp),%rbp
mov    (%rbx),%rbx
mov    %rbp,%rdi
call   1050 <strlen@plt>
cmp    $0x4,%eax
jg     11d6 <karatsuba+0x46>
mov    %rbp,%rdi
mov    %rbx,%rsi
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <column_mul@plt>
mov    %eax,%r12d
lea    0x50(%rsp),%r14
lea    0x48(%rsp),%r15
mov    %rbp,%rdi
mov    %eax,%esi
mov    %r14,%rdx
mov    %r15,%rcx
call   1090 <split@plt>
lea    0x40(%rsp),%rbp
lea    0x38(%rsp),%r13
mov    %rbx,%rdi
mov    %r12d,%esi
mov    %rbp,%rdx
mov    %r13,%rcx
call   1090 <split@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
call   1030 <karatsuba@plt>
mov    %rax,0x30(%rsp)
mov    %r15,%rdi
mov    %r13,%rsi
call   1030 <karatsuba@plt>
mov    %rax,0x28(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
call   10a0 <sum@plt>
mov    %rax,0x18(%rsp)
mov    %rbp,%rdi
mov    %r13,%rsi
call   10a0 <sum@plt>
mov    %rax,0x10(%rsp)
lea    0x18(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1030 <karatsuba@plt>
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rdi
lea    0x28(%rsp),%rbx
mov    %rbx,%rsi
call   10b0 <sub@plt>
mov    %rax,(%rsp)
mov    %rsp,%rdi
lea    0x30(%rsp),%rbp
mov    %rbp,%rsi
call   10b0 <sub@plt>
mov    %rax,0x20(%rsp)
lea    0x20(%rsp),%rdx
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r12d,%ecx
call   1060 <combine@plt>
mov    %rax,%rbx
mov    0x50(%rsp),%rdi
call   1040 <free@plt>
mov    0x48(%rsp),%rdi
call   1040 <free@plt>
mov    0x40(%rsp),%rdi
call   1040 <free@plt>
mov    0x38(%rsp),%rdi
call   1040 <free@plt>
mov    0x30(%rsp),%rdi
call   1040 <free@plt>
mov    0x28(%rsp),%rdi
call   1040 <free@plt>
mov    0x18(%rsp),%rdi
call   1040 <free@plt>
mov    0x10(%rsp),%rdi
call   1040 <free@plt>
mov    0x20(%rsp),%rdi
call   1040 <free@plt>
mov    0x8(%rsp),%rdi
call   1040 <free@plt>
mov    (%rsp),%rdi
call   1040 <free@plt>
mov    %rbx,%rax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @karatsuba(i8** %0, i8** %1) {
%3 = alloca i8*
%4 = alloca i8**
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca i8*
%19 = alloca i8*
%20 = alloca i32
store i8** %0, i8*** %4
store i8** %1, i8*** %5
%21 = load i8**, i8*** %4
%22 = load i8**, i8*** %5
%23 = call i32 @align(i8** %21, i8** %22)
%24 = load i8**, i8*** %4
%25 = load i8*, i8** %24
store i8* %25, i8** %6
%26 = load i8**, i8*** %5
%27 = load i8*, i8** %26
store i8* %27, i8** %7
%28 = load i8*, i8** %6
%29 = call i32 @strlen(i8* %28)
store i32 %29, i32* %20
%30 = load i32, i32* %20
%31 = icmp sle i32 %30, 4
br i1 %31, label %32, label %36
32: ; preds = %2
%33 = load i8*, i8** %6
%34 = load i8*, i8** %7
%35 = call i8* @column_mul(i8* %33, i8* %34)
store i8* %35, i8** %3
br label %75
36: ; preds = %2
%37 = load i8*, i8** %6
%38 = load i32, i32* %20
%39 = call i32 @split(i8* %37, i32 %38, i8** %8, i8** %9)
%40 = load i8*, i8** %7
%41 = load i32, i32* %20
%42 = call i32 @split(i8* %40, i32 %41, i8** %10, i8** %11)
%43 = call i8* @karatsuba(i8** %8, i8** %10)
store i8* %43, i8** %12
%44 = call i8* @karatsuba(i8** %9, i8** %11)
store i8* %44, i8** %13
%45 = call i8* @sum(i8** %8, i8** %9)
store i8* %45, i8** %15
%46 = call i8* @sum(i8** %10, i8** %11)
store i8* %46, i8** %16
%47 = call i8* @karatsuba(i8** %15, i8** %16)
store i8* %47, i8** %17
%48 = call i8* @sub(i8** %17, i8** %13)
store i8* %48, i8** %18
%49 = call i8* @sub(i8** %18, i8** %12)
store i8* %49, i8** %14
%50 = load i32, i32* %20
%51 = call i8* @combine(i8** %12, i8** %13, i8** %14, i32 %50)
store i8* %51, i8** %19
%52 = load i8*, i8** %8
%53 = call i32 @free(i8* %52)
%54 = load i8*, i8** %9
%55 = call i32 @free(i8* %54)
%56 = load i8*, i8** %10
%57 = call i32 @free(i8* %56)
%58 = load i8*, i8** %11
%59 = call i32 @free(i8* %58)
%60 = load i8*, i8** %12
%61 = call i32 @free(i8* %60)
%62 = load i8*, i8** %13
%63 = call i32 @free(i8* %62)
%64 = load i8*, i8** %15
%65 = call i32 @free(i8* %64)
%66 = load i8*, i8** %16
%67 = call i32 @free(i8* %66)
%68 = load i8*, i8** %14
%69 = call i32 @free(i8* %68)
%70 = load i8*, i8** %17
%71 = call i32 @free(i8* %70)
%72 = load i8*, i8** %18
%73 = call i32 @free(i8* %72)
%74 = load i8*, i8** %19
store i8* %74, i8** %3
br label %75
75: ; preds = %36, %32
%76 = load i8*, i8** %3
ret i8* %76
}

LLVM IR (-O2):
define i8* @karatsuba(i8** %0, i8** %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = bitcast i8** %3 to i8*
%15 = bitcast i8** %4 to i8*
%16 = bitcast i8** %5 to i8*
%17 = bitcast i8** %6 to i8*
%18 = bitcast i8** %7 to i8*
%19 = bitcast i8** %8 to i8*
%20 = bitcast i8** %9 to i8*
%21 = bitcast i8** %10 to i8*
%22 = bitcast i8** %11 to i8*
%23 = bitcast i8** %12 to i8*
%24 = bitcast i8** %13 to i8*
%25 = tail call i32 @align(i8** %0, i8** %1)
%26 = load i8*, i8** %0
%27 = load i8*, i8** %1
%28 = tail call i32 @strlen(i8* %26)
%29 = icmp slt i32 %28, 5
br i1 %29, label %30, label %32
30: ; preds = %2
%31 = tail call i8* @column_mul(i8* %26, i8* %27)
br label %65
32: ; preds = %2
%33 = call i32 @split(i8* %26, i32 %28, i8** %3, i8** %4)
%34 = call i32 @split(i8* %27, i32 %28, i8** %5, i8** %6)
%35 = call i8* @karatsuba(i8** %3, i8** %5)
store i8* %35, i8** %7
%36 = call i8* @karatsuba(i8** %4, i8** %6)
store i8* %36, i8** %8
%37 = call i8* @sum(i8** %3, i8** %4)
store i8* %37, i8** %10
%38 = call i8* @sum(i8** %5, i8** %6)
store i8* %38, i8** %11
%39 = call i8* @karatsuba(i8** %10, i8** %11)
store i8* %39, i8** %12
%40 = call i8* @sub(i8** %12, i8** %8)
store i8* %40, i8** %13
%41 = call i8* @sub(i8** %13, i8** %7)
store i8* %41, i8** %9
%42 = call i8* @combine(i8** %7, i8** %8, i8** %9, i32 %28)
%43 = load i8*, i8** %3
%44 = call i32 @free(i8* %43)
%45 = load i8*, i8** %4
%46 = call i32 @free(i8* %45)
%47 = load i8*, i8** %5
%48 = call i32 @free(i8* %47)
%49 = load i8*, i8** %6
%50 = call i32 @free(i8* %49)
%51 = load i8*, i8** %7
%52 = call i32 @free(i8* %51)
%53 = load i8*, i8** %8
%54 = call i32 @free(i8* %53)
%55 = load i8*, i8** %10
%56 = call i32 @free(i8* %55)
%57 = load i8*, i8** %11
%58 = call i32 @free(i8* %57)
%59 = load i8*, i8** %9
%60 = call i32 @free(i8* %59)
%61 = load i8*, i8** %12
%62 = call i32 @free(i8* %61)
%63 = load i8*, i8** %13
%64 = call i32 @free(i8* %63)
br label %65
65: ; preds = %32, %30
%66 = phi i8* [ %31, %30 ], [ %42, %32 ]
ret i8* %66
}