#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 */
scalar_t__ calloc(scalar_t__, int);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ mul_digit_string(int, char *, char **);
int /*<<< orphan*/ printf(char *, int, char *, char *, char const *);
scalar_t__ strlen(char const *);
scalar_t__ strncmp(char *, char const *, scalar_t__);
int /*<<< orphan*/ strncpy(char *, char const *, scalar_t__);
void call_mul_digit_string(const int index, const int *scalars,
                           const char **numeric_input,
                           const char **numeric_output) {
  int a = scalars[index];
  char *b = (char *)calloc(strlen(numeric_input[index]) + 1, sizeof(char));
  strncpy(b, numeric_input[index], strlen(numeric_input[index]));
  char *c = (char *)calloc(strlen(b) + 1, sizeof(char));
  mul_digit_string(a, b, &c);
  if (strncmp(c, numeric_output[index], strlen(numeric_output[index])))
    printf("%d * %s is %s and should be %s\n", a, b, c, numeric_output[index]);
  free(c);
  free(b);
}


x86 assembly (clang, -O0):
<call_mul_digit_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1060 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
mov    $0x1,%esi
call   1090 <calloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x50(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1060 <strlen@plt>
mov    -0x58(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    %rax,%rdx
call   1040 <strncpy@plt>
mov    -0x30(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
mov    $0x1,%esi
call   1090 <calloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x30(%rbp),%rsi
lea    -0x38(%rbp),%rdx
call   1070 <mul_digit_string@plt>
mov    -0x38(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1060 <strlen@plt>
mov    -0x48(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    %rax,%rdx
call   1050 <strncmp@plt>
cmp    $0x0,%rax
je     1288 <call_mul_digit_string+0x118>
mov    -0x24(%rbp),%esi
mov    -0x30(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    -0x20(%rbp),%rax
movslq -0x4(%rbp),%rdi
mov    (%rax,%rdi,8),%r8
lea    0xd7d(%rip),%rdi
call   1080 <printf@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<call_mul_digit_string>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%rbp
movslq %edi,%r13
mov    (%rsi,%r13,4),%r15d
mov    (%rdx,%r13,8),%rdi
call   1060 <strlen@plt>
lea    0x1(%rax),%rdi
mov    $0x1,%esi
call   1090 <calloc@plt>
mov    %rax,%r12
mov    0x0(%rbp,%r13,8),%rbp
mov    %rbp,%rdi
call   1060 <strlen@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %rax,%rdx
call   1040 <strncpy@plt>
mov    %r12,%rdi
call   1060 <strlen@plt>
lea    0x1(%rax),%rdi
mov    $0x1,%esi
call   1090 <calloc@plt>
mov    %rax,(%rsp)
mov    %rsp,%rdx
mov    %r15d,%edi
mov    %r12,%rsi
call   1070 <mul_digit_string@plt>
mov    (%rsp),%rbp
mov    (%r14,%r13,8),%rbx
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1050 <strncmp@plt>
test   %rax,%rax
je     1222 <call_mul_digit_string+0xb2>
mov    (%rsp),%rcx
mov    (%r14,%r13,8),%r8
lea    0xde9(%rip),%rdi
mov    %r15d,%esi
mov    %r12,%rdx
call   1080 <printf@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"%d * %s is %s and should be %s\0A\00"
define void @call_mul_digit_string(i32 %0, i32* %1, i8** %2, i8** %3) {
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i8**
%8 = alloca i8**
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
store i32 %0, i32* %5
store i32* %1, i32** %6
store i8** %2, i8*** %7
store i8** %3, i8*** %8
%12 = load i32*, i32** %6
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i32, i32* %12, i64 %14
%16 = load i32, i32* %15
store i32 %16, i32* %9
%17 = load i8**, i8*** %7
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8*, i8** %17, i64 %19
%21 = load i8*, i8** %20
%22 = call i64 @strlen(i8* %21)
%23 = add nsw i64 %22, 1
%24 = call i64 @calloc(i64 %23, i32 1)
%25 = inttoptr i64 %24 to i8*
store i8* %25, i8** %10
%26 = load i8*, i8** %10
%27 = load i8**, i8*** %7
%28 = load i32, i32* %5
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %27, i64 %29
%31 = load i8*, i8** %30
%32 = load i8**, i8*** %7
%33 = load i32, i32* %5
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8*, i8** %32, i64 %34
%36 = load i8*, i8** %35
%37 = call i64 @strlen(i8* %36)
%38 = call i32 @strncpy(i8* %26, i8* %31, i64 %37)
%39 = load i8*, i8** %10
%40 = call i64 @strlen(i8* %39)
%41 = add nsw i64 %40, 1
%42 = call i64 @calloc(i64 %41, i32 1)
%43 = inttoptr i64 %42 to i8*
store i8* %43, i8** %11
%44 = load i32, i32* %9
%45 = load i8*, i8** %10
%46 = call i32 @mul_digit_string(i32 %44, i8* %45, i8** %11)
%47 = load i8*, i8** %11
%48 = load i8**, i8*** %8
%49 = load i32, i32* %5
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8*, i8** %48, i64 %50
%52 = load i8*, i8** %51
%53 = load i8**, i8*** %8
%54 = load i32, i32* %5
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8*, i8** %53, i64 %55
%57 = load i8*, i8** %56
%58 = call i64 @strlen(i8* %57)
%59 = call i64 @strncmp(i8* %47, i8* %52, i64 %58)
%60 = icmp ne i64 %59, 0
br i1 %60, label %61, label %71
61: ; preds = %4
%62 = load i32, i32* %9
%63 = load i8*, i8** %10
%64 = load i8*, i8** %11
%65 = load i8**, i8*** %8
%66 = load i32, i32* %5
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds i8*, i8** %65, i64 %67
%69 = load i8*, i8** %68
%70 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %62, i8* %63, i8* %64, i8* %69)
br label %71
71: ; preds = %61, %4
%72 = load i8*, i8** %11
%73 = call i32 @free(i8* %72)
%74 = load i8*, i8** %10
%75 = call i32 @free(i8* %74)
ret void
}

LLVM IR (-O2):
@.str = [32 x i8] c"%d * %s is %s and should be %s\0A\00"
define void @call_mul_digit_string(i32 %0, i32* nocapture %1, i8** nocapture %2, i8** nocapture %3) {
%5 = alloca i8*
%6 = sext i32 %0 to i64
%7 = getelementptr inbounds i32, i32* %1, i64 %6
%8 = load i32, i32* %7
%9 = getelementptr inbounds i8*, i8** %2, i64 %6
%10 = load i8*, i8** %9
%11 = tail call i64 @strlen(i8* dereferenceable(1) %10)
%12 = add nsw i64 %11, 1
%13 = tail call i64 @calloc(i64 %12, i32 1)
%14 = inttoptr i64 %13 to i8*
%15 = load i8*, i8** %9
%16 = tail call i64 @strlen(i8* dereferenceable(1) %15)
%17 = tail call i32 @strncpy(i8* %14, i8* %15, i64 %16)
%18 = bitcast i8** %5 to i8*
%19 = tail call i64 @strlen(i8* dereferenceable(1) %14)
%20 = add nsw i64 %19, 1
%21 = tail call i64 @calloc(i64 %20, i32 1)
%22 = inttoptr i64 %21 to i8*
store i8* %22, i8** %5
%23 = call i32 @mul_digit_string(i32 %8, i8* %14, i8** %5)
%24 = load i8*, i8** %5
%25 = getelementptr inbounds i8*, i8** %3, i64 %6
%26 = load i8*, i8** %25
%27 = call i64 @strlen(i8* dereferenceable(1) %26)
%28 = call i64 @strncmp(i8* %24, i8* %26, i64 %27)
%29 = icmp eq i64 %28, 0
br i1 %29, label %34, label %30
30: ; preds = %4
%31 = load i8*, i8** %5
%32 = load i8*, i8** %25
%33 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %8, i8* %14, i8* %31, i8* %32)
br label %34
34: ; preds = %30, %4
%35 = load i8*, i8** %5
%36 = call i32 @free(i8* %35)
%37 = call i32 @free(i8* %14)
ret void
}