#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 add_digit_strings(char *, char *, char **);
scalar_t__ calloc(int, int);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *, char *, char *, char *, char const *);
int strlen(char const *);
scalar_t__ strncmp(char *, char const *, int);
int /*<<< orphan*/ strncpy(char *, char const *, int);
int call_add_digit_strings(const int index, const char **input1,
                           const char **input2, const char **output) {
  char *a = (char *)calloc(strlen(input1[index]) + 1, sizeof(char));
  strncpy(a, input1[index], strlen(input1[index]));
  int lena = strlen(a);
  char *b = (char *)calloc(strlen(input2[index]) + 1, sizeof(char));
  strncpy(b, input2[index], strlen(input2[index]));
  int lenb = strlen(b);
  int maxlen = (lena > lenb) ? lena : lenb;
  char *c = (char *)calloc(maxlen + 1, sizeof(char));
  int status = add_digit_strings(a, b, &c);
  if (strncmp(c, output[index], strlen(output[index])))
    printf("%s + %s is %s and should be %s\n", a, b, c, output[index]);
  free(c);
  free(b);
  free(a);
  return status;
}


x86 assembly (clang, -O0):
<call_add_digit_strings>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%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,8),%rdi
call   1060 <strlen@plt>
mov    %eax,%edi
add    $0x1,%edi
mov    $0x1,%esi
call   1080 <calloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x68(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1060 <strlen@plt>
mov    -0x70(%rbp),%rdi
mov    -0x68(%rbp),%rsi
mov    %eax,%edx
call   1040 <strncpy@plt>
mov    -0x28(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1060 <strlen@plt>
mov    %eax,%edi
add    $0x1,%edi
mov    $0x1,%esi
call   1080 <calloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%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    %eax,%edx
call   1040 <strncpy@plt>
mov    -0x38(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jle    1271 <call_add_digit_strings+0x101>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x74(%rbp)
jmp    1277 <call_add_digit_strings+0x107>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x74(%rbp)
mov    -0x74(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%edi
add    $0x1,%edi
mov    $0x1,%esi
call   1080 <calloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x38(%rbp),%rsi
lea    -0x48(%rbp),%rdx
call   1090 <add_digit_strings@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x80(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1060 <strlen@plt>
mov    -0x88(%rbp),%rdi
mov    -0x80(%rbp),%rsi
mov    %eax,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%rax
je     1311 <call_add_digit_strings+0x1a1>
mov    -0x28(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    -0x48(%rbp),%rcx
mov    -0x20(%rbp),%rax
movslq -0x4(%rbp),%rdi
mov    (%rax,%rdi,8),%r8
lea    0xcf4(%rip),%rdi
call   1070 <printf@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x4c(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<call_add_digit_strings>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,0x10(%rsp)
mov    %rdx,%r12
mov    %rsi,%rbx
movslq %edi,%r14
mov    (%rsi,%r14,8),%rdi
call   1060 <strlen@plt>
lea    0x1(%rax),%edi
mov    $0x1,%esi
call   1080 <calloc@plt>
mov    %rax,%r15
mov    (%rbx,%r14,8),%rbx
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <strncpy@plt>
mov    %r15,%rdi
call   1060 <strlen@plt>
mov    %eax,%ebp
mov    (%r12,%r14,8),%rdi
call   1060 <strlen@plt>
lea    0x1(%rax),%edi
mov    $0x1,%esi
call   1080 <calloc@plt>
mov    %rax,%r13
mov    (%r12,%r14,8),%rbx
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <strncpy@plt>
mov    %r13,%rdi
call   1060 <strlen@plt>
cmp    %eax,%ebp
cmovle %eax,%ebp
add    $0x1,%ebp
mov    %ebp,%edi
mov    $0x1,%esi
call   1080 <calloc@plt>
mov    %rax,(%rsp)
mov    %rsp,%rdx
mov    %r15,%rdi
mov    %r13,%rsi
call   1090 <add_digit_strings@plt>
mov    %eax,0xc(%rsp)
mov    (%rsp),%rbx
mov    0x10(%rsp),%rax
mov    %rax,%r12
mov    (%rax,%r14,8),%rbp
mov    %rbp,%rdi
call   1060 <strlen@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %eax,%edx
call   1050 <strncmp@plt>
test   %rax,%rax
je     1270 <call_add_digit_strings+0x100>
mov    (%rsp),%rcx
mov    (%r12,%r14,8),%r8
lea    0xd9b(%rip),%rdi
mov    %r15,%rsi
mov    %r13,%rdx
call   1070 <printf@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    0xc(%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"%s + %s is %s and should be %s\0A\00"
define i32 @call_add_digit_strings(i32 %0, i8** %1, i8** %2, i8** %3) {
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i8**
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8*
%15 = alloca i32
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
store i8** %3, i8*** %8
%16 = load i8**, i8*** %6
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8*, i8** %16, i64 %18
%20 = load i8*, i8** %19
%21 = call i32 @strlen(i8* %20)
%22 = add nsw i32 %21, 1
%23 = call i64 @calloc(i32 %22, i32 1)
%24 = inttoptr i64 %23 to i8*
store i8* %24, i8** %9
%25 = load i8*, i8** %9
%26 = load i8**, i8*** %6
%27 = load i32, i32* %5
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8*, i8** %26, i64 %28
%30 = load i8*, i8** %29
%31 = load i8**, i8*** %6
%32 = load i32, i32* %5
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8*, i8** %31, i64 %33
%35 = load i8*, i8** %34
%36 = call i32 @strlen(i8* %35)
%37 = call i32 @strncpy(i8* %25, i8* %30, i32 %36)
%38 = load i8*, i8** %9
%39 = call i32 @strlen(i8* %38)
store i32 %39, i32* %10
%40 = load i8**, i8*** %7
%41 = load i32, i32* %5
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8*, i8** %40, i64 %42
%44 = load i8*, i8** %43
%45 = call i32 @strlen(i8* %44)
%46 = add nsw i32 %45, 1
%47 = call i64 @calloc(i32 %46, i32 1)
%48 = inttoptr i64 %47 to i8*
store i8* %48, i8** %11
%49 = load i8*, i8** %11
%50 = load i8**, i8*** %7
%51 = load i32, i32* %5
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8*, i8** %50, i64 %52
%54 = load i8*, i8** %53
%55 = load i8**, i8*** %7
%56 = load i32, i32* %5
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8*, i8** %55, i64 %57
%59 = load i8*, i8** %58
%60 = call i32 @strlen(i8* %59)
%61 = call i32 @strncpy(i8* %49, i8* %54, i32 %60)
%62 = load i8*, i8** %11
%63 = call i32 @strlen(i8* %62)
store i32 %63, i32* %12
%64 = load i32, i32* %10
%65 = load i32, i32* %12
%66 = icmp sgt i32 %64, %65
br i1 %66, label %67, label %69
67: ; preds = %4
%68 = load i32, i32* %10
br label %71
69: ; preds = %4
%70 = load i32, i32* %12
br label %71
71: ; preds = %69, %67
%72 = phi i32 [ %68, %67 ], [ %70, %69 ]
store i32 %72, i32* %13
%73 = load i32, i32* %13
%74 = add nsw i32 %73, 1
%75 = call i64 @calloc(i32 %74, i32 1)
%76 = inttoptr i64 %75 to i8*
store i8* %76, i8** %14
%77 = load i8*, i8** %9
%78 = load i8*, i8** %11
%79 = call i32 @add_digit_strings(i8* %77, i8* %78, i8** %14)
store i32 %79, i32* %15
%80 = load i8*, i8** %14
%81 = load i8**, i8*** %8
%82 = load i32, i32* %5
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds i8*, i8** %81, i64 %83
%85 = load i8*, i8** %84
%86 = load i8**, i8*** %8
%87 = load i32, i32* %5
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds i8*, i8** %86, i64 %88
%90 = load i8*, i8** %89
%91 = call i32 @strlen(i8* %90)
%92 = call i64 @strncmp(i8* %80, i8* %85, i32 %91)
%93 = icmp ne i64 %92, 0
br i1 %93, label %94, label %104
94: ; preds = %71
%95 = load i8*, i8** %9
%96 = load i8*, i8** %11
%97 = load i8*, i8** %14
%98 = load i8**, i8*** %8
%99 = load i32, i32* %5
%100 = sext i32 %99 to i64
%101 = getelementptr inbounds i8*, i8** %98, i64 %100
%102 = load i8*, i8** %101
%103 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %95, i8* %96, i8* %97, i8* %102)
br label %104
104: ; preds = %94, %71
%105 = load i8*, i8** %14
%106 = call i32 @free(i8* %105)
%107 = load i8*, i8** %11
%108 = call i32 @free(i8* %107)
%109 = load i8*, i8** %9
%110 = call i32 @free(i8* %109)
%111 = load i32, i32* %15
ret i32 %111
}

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