#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 mul_int_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__);
int call_mul_int_string(const int index, const int *scalars, const char **input,
                        const char **output) {
  int a = scalars[index];
  char *b = (char *)calloc(strlen(input[index]) + 1, sizeof(char));
  strncpy(b, input[index], strlen(input[index]));
  char *c = (char *)calloc(strlen(b) + 1, sizeof(char));
  int status = mul_int_string(a, b, &c);
  if (strncmp(c, output[index], strlen(output[index])))
    printf("%d * %s is %s and should be %s\n", a, b, c, output[index]);
  free(c);
  free(b);
  return status;
}


x86 assembly (clang, -O0):
<call_mul_int_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   1080 <calloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x58(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1060 <strlen@plt>
mov    -0x60(%rbp),%rdi
mov    -0x58(%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   1080 <calloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x30(%rbp),%rsi
lea    -0x38(%rbp),%rdx
call   1090 <mul_int_string@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1060 <strlen@plt>
mov    -0x50(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    %rax,%rdx
call   1050 <strncmp@plt>
cmp    $0x0,%rax
je     128b <call_mul_int_string+0x11b>
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    0xd7a(%rip),%rdi
call   1070 <printf@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x3c(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<call_mul_int_string>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%r12
mov    %rdx,%rbp
movslq %edi,%r14
mov    (%rsi,%r14,4),%ebx
mov    (%rdx,%r14,8),%rdi
call   1060 <strlen@plt>
lea    0x1(%rax),%rdi
mov    $0x1,%esi
call   1080 <calloc@plt>
mov    %rax,%r13
mov    0x0(%rbp,%r14,8),%rbp
mov    %rbp,%rdi
call   1060 <strlen@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
mov    %rax,%rdx
call   1040 <strncpy@plt>
mov    %r13,%rdi
call   1060 <strlen@plt>
lea    0x1(%rax),%rdi
mov    $0x1,%esi
call   1080 <calloc@plt>
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rdx
mov    %ebx,0x10(%rsp)
mov    %ebx,%edi
mov    %r13,%rsi
call   1090 <mul_int_string@plt>
mov    %eax,0x14(%rsp)
mov    0x8(%rsp),%rbp
mov    %r12,%r15
mov    (%r12,%r14,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     1235 <call_mul_int_string+0xc5>
mov    0x8(%rsp),%rcx
mov    (%r15,%r14,8),%r8
lea    0xdd7(%rip),%rdi
mov    0x10(%rsp),%esi
mov    %r13,%rdx
call   1070 <printf@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1030 <free@plt>
mov    0x14(%rsp),%eax
add    $0x18,%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 i32 @call_mul_int_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*
%12 = alloca i32
store i32 %0, i32* %5
store i32* %1, i32** %6
store i8** %2, i8*** %7
store i8** %3, i8*** %8
%13 = load i32*, i32** %6
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i32, i32* %13, i64 %15
%17 = load i32, i32* %16
store i32 %17, i32* %9
%18 = load i8**, i8*** %7
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8*, i8** %18, i64 %20
%22 = load i8*, i8** %21
%23 = call i64 @strlen(i8* %22)
%24 = add nsw i64 %23, 1
%25 = call i64 @calloc(i64 %24, i32 1)
%26 = inttoptr i64 %25 to i8*
store i8* %26, i8** %10
%27 = load i8*, i8** %10
%28 = load i8**, i8*** %7
%29 = load i32, i32* %5
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8*, i8** %28, i64 %30
%32 = load i8*, i8** %31
%33 = load i8**, i8*** %7
%34 = load i32, i32* %5
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8*, i8** %33, i64 %35
%37 = load i8*, i8** %36
%38 = call i64 @strlen(i8* %37)
%39 = call i32 @strncpy(i8* %27, i8* %32, i64 %38)
%40 = load i8*, i8** %10
%41 = call i64 @strlen(i8* %40)
%42 = add nsw i64 %41, 1
%43 = call i64 @calloc(i64 %42, i32 1)
%44 = inttoptr i64 %43 to i8*
store i8* %44, i8** %11
%45 = load i32, i32* %9
%46 = load i8*, i8** %10
%47 = call i32 @mul_int_string(i32 %45, i8* %46, i8** %11)
store i32 %47, i32* %12
%48 = load i8*, i8** %11
%49 = load i8**, i8*** %8
%50 = load i32, i32* %5
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8*, i8** %49, i64 %51
%53 = load i8*, i8** %52
%54 = load i8**, i8*** %8
%55 = load i32, i32* %5
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8*, i8** %54, i64 %56
%58 = load i8*, i8** %57
%59 = call i64 @strlen(i8* %58)
%60 = call i64 @strncmp(i8* %48, i8* %53, i64 %59)
%61 = icmp ne i64 %60, 0
br i1 %61, label %62, label %72
62: ; preds = %4
%63 = load i32, i32* %9
%64 = load i8*, i8** %10
%65 = load i8*, i8** %11
%66 = load i8**, i8*** %8
%67 = load i32, i32* %5
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i8*, i8** %66, i64 %68
%70 = load i8*, i8** %69
%71 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %63, i8* %64, i8* %65, i8* %70)
br label %72
72: ; preds = %62, %4
%73 = load i8*, i8** %11
%74 = call i32 @free(i8* %73)
%75 = load i8*, i8** %10
%76 = call i32 @free(i8* %75)
%77 = load i32, i32* %12
ret i32 %77
}

LLVM IR (-O2):
@.str = [32 x i8] c"%d * %s is %s and should be %s\0A\00"
define i32 @call_mul_int_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_int_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 i32 %23
}