#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 atoi(char *);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
scalar_t__ realloc(char *, int);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
int /*<<< orphan*/ strcat(char *, char const *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char const *);
void BanglaNumber(char *number, char **outputString, const char *constString,
                  int printLength) {
  int length = strlen(number);
  char tempString[printLength + 1];
  char *banglaString =
      (char *)malloc((printLength + strlen(constString) + 1) * sizeof(char));
  if (length > 1) {
    for (int i = 0, j = length - printLength; j <= length; i++, j++)
      tempString[i] = number[j];
  } else
    tempString[0] = number[length - 1];
  int value = atoi(tempString);
  if (value) {
    strcpy(banglaString, tempString);
    strcat(banglaString, constString);
    char temporaryString[strlen(*outputString) + 1];
    strcpy(temporaryString, *outputString);
    *outputString =
        (char *)realloc(*outputString, (printLength + strlen(constString) +
                                        strlen(*outputString) + 1) *
                                           sizeof(char));
    sprintf(*outputString, "%s%s", banglaString, temporaryString);
  }
  free(banglaString);
  number[length - printLength] = '\0';
}


x86 assembly (clang, -O0):
<BanglaNumber>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x68(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x5c(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x5c(%rbp),%eax
add    %ecx,%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x38(%rbp)
cmpl   $0x1,-0x20(%rbp)
jle    1251 <BanglaNumber+0xd1>
movl   $0x0,-0x3c(%rbp)
mov    -0x20(%rbp),%eax
sub    -0x1c(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x20(%rbp),%eax
jg     124c <BanglaNumber+0xcc>
mov    -0x68(%rbp),%rax
mov    -0x8(%rbp),%rcx
movslq -0x40(%rbp),%rdx
mov    (%rcx,%rdx,1),%dl
movslq -0x3c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1213 <BanglaNumber+0x93>
jmp    1267 <BanglaNumber+0xe7>
mov    -0x68(%rbp),%rax
mov    -0x8(%rbp),%rcx
mov    -0x20(%rbp),%edx
sub    $0x1,%edx
movslq %edx,%rdx
mov    (%rcx,%rdx,1),%cl
mov    %cl,(%rax)
mov    -0x68(%rbp),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
je     1352 <BanglaNumber+0x1d2>
mov    -0x68(%rbp),%rsi
mov    -0x38(%rbp),%rdi
call   1040 <strcpy@plt>
mov    -0x38(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1090 <strcat@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <strlen@plt>
add    $0x1,%eax
mov    %rsp,%rcx
mov    %rcx,-0x50(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x70(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x58(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
call   1040 <strcpy@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x80(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x84(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x84(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x74(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <strlen@plt>
mov    -0x80(%rbp),%rdi
mov    %eax,%ecx
mov    -0x74(%rbp),%eax
add    %ecx,%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%esi
call   1070 <realloc@plt>
mov    -0x70(%rbp),%rcx
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
mov    %rdx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x38(%rbp),%rdx
lea    0xcba(%rip),%rsi
call   10a0 <sprintf@plt>
mov    -0x50(%rbp),%rax
mov    %rax,%rsp
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%ecx
sub    -0x1c(%rbp),%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BanglaNumber>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %ecx,%r15d
mov    %rdx,%r13
mov    %rsi,-0x60(%rbp)
mov    %rdi,-0x30(%rbp)
call   1050 <strlen@plt>
mov    %eax,%r14d
lea    0x1(%r15),%ebx
mov    %rsp,%r12
lea    0xf(%rbx),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
mov    %r13,%rdi
call   1050 <strlen@plt>
lea    (%r15,%rax,1),%edi
add    $0x1,%edi
call   1070 <malloc@plt>
cmp    $0x2,%r14d
mov    %rbx,-0x58(%rbp)
mov    %r13,-0x50(%rbp)
mov    %rax,%r13
jl     1222 <BanglaNumber+0x92>
test   %r15d,%r15d
js     1231 <BanglaNumber+0xa1>
mov    %r14d,%eax
sub    %r15d,%eax
movslq %eax,%rdx
mov    -0x30(%rbp),%rax
lea    (%rax,%rdx,1),%rsi
cmp    %edx,%r14d
cmovg  %r14d,%edx
add    %r15d,%edx
sub    %r14d,%edx
add    $0x1,%rdx
mov    %r12,%rdi
call   1060 <memcpy@plt>
jmp    1231 <BanglaNumber+0xa1>
movslq %r14d,%rax
mov    -0x30(%rbp),%rcx
mov    -0x1(%rax,%rcx,1),%al
mov    %al,(%r12)
mov    %r12,%rdi
call   1090 <atoi@plt>
test   %eax,%eax
je     12da <BanglaNumber+0x14a>
mov    %r13,%rdi
mov    %r12,%rsi
call   1040 <strcpy@plt>
mov    %r13,%rdi
mov    -0x50(%rbp),%r12
mov    %r12,%rsi
call   10a0 <strcat@plt>
mov    %r15,-0x48(%rbp)
mov    -0x60(%rbp),%r15
mov    (%r15),%rdi
call   1050 <strlen@plt>
mov    %rsp,-0x40(%rbp)
add    $0x1,%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    (%r15),%rsi
mov    %rbx,%rdi
call   1040 <strcpy@plt>
mov    (%r15),%rax
mov    %rax,-0x38(%rbp)
mov    %r12,%rdi
call   1050 <strlen@plt>
mov    %eax,%r12d
mov    (%r15),%rdi
call   1050 <strlen@plt>
mov    -0x58(%rbp),%rsi
add    %r12d,%esi
add    %eax,%esi
mov    -0x38(%rbp),%rdi
call   1080 <realloc@plt>
mov    %rax,(%r15)
mov    -0x48(%rbp),%r15
lea    0xd38(%rip),%rsi
mov    %rax,%rdi
mov    %r13,%rdx
mov    %rbx,%rcx
call   10b0 <sprintf@plt>
mov    -0x40(%rbp),%rsp
mov    %r13,%rdi
call   1030 <free@plt>
sub    %r15d,%r14d
movslq %r14d,%rax
mov    -0x30(%rbp),%rcx
movb   $0x0,(%rcx,%rax,1)
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%s%s\00"
define void @BanglaNumber(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 i8*
%11 = alloca i64
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i8*
%17 = alloca i64
store i8* %0, i8** %5
store i8** %1, i8*** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%18 = load i8*, i8** %5
%19 = call i32 @strlen(i8* %18)
store i32 %19, i32* %9
%20 = load i32, i32* %8
%21 = add nsw i32 %20, 1
%22 = zext i32 %21 to i64
%23 = call i8* @llvm.stacksave()
store i8* %23, i8** %10
%24 = alloca i8, i64 %22
store i64 %22, i64* %11
%25 = load i32, i32* %8
%26 = load i8*, i8** %7
%27 = call i32 @strlen(i8* %26)
%28 = add nsw i32 %25, %27
%29 = add nsw i32 %28, 1
%30 = sext i32 %29 to i64
%31 = mul i64 %30, 1
%32 = trunc i64 %31 to i32
%33 = call i64 @malloc(i32 %32)
%34 = inttoptr i64 %33 to i8*
store i8* %34, i8** %12
%35 = load i32, i32* %9
%36 = icmp sgt i32 %35, 1
br i1 %36, label %37, label %60
37: ; preds = %4
store i32 0, i32* %13
%38 = load i32, i32* %9
%39 = load i32, i32* %8
%40 = sub nsw i32 %38, %39
store i32 %40, i32* %14
br label %41
41: ; preds = %54, %37
%42 = load i32, i32* %14
%43 = load i32, i32* %9
%44 = icmp sle i32 %42, %43
br i1 %44, label %45, label %59
45: ; preds = %41
%46 = load i8*, i8** %5
%47 = load i32, i32* %14
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %46, i64 %48
%50 = load i8, i8* %49
%51 = load i32, i32* %13
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %24, i64 %52
store i8 %50, i8* %53
br label %54
54: ; preds = %45
%55 = load i32, i32* %13
%56 = add nsw i32 %55, 1
store i32 %56, i32* %13
%57 = load i32, i32* %14
%58 = add nsw i32 %57, 1
store i32 %58, i32* %14
br label %41
59: ; preds = %41
br label %68
60: ; preds = %4
%61 = load i8*, i8** %5
%62 = load i32, i32* %9
%63 = sub nsw i32 %62, 1
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i8, i8* %61, i64 %64
%66 = load i8, i8* %65
%67 = getelementptr inbounds i8, i8* %24, i64 0
store i8 %66, i8* %67
br label %68
68: ; preds = %60, %59
%69 = call i32 @atoi(i8* %24)
store i32 %69, i32* %15
%70 = load i32, i32* %15
%71 = icmp ne i32 %70, 0
br i1 %71, label %72, label %110
72: ; preds = %68
%73 = load i8*, i8** %12
%74 = call i32 @strcpy(i8* %73, i8* %24)
%75 = load i8*, i8** %12
%76 = load i8*, i8** %7
%77 = call i32 @strcat(i8* %75, i8* %76)
%78 = load i8**, i8*** %6
%79 = load i8*, i8** %78
%80 = call i32 @strlen(i8* %79)
%81 = add nsw i32 %80, 1
%82 = zext i32 %81 to i64
%83 = call i8* @llvm.stacksave()
store i8* %83, i8** %16
%84 = alloca i8, i64 %82
store i64 %82, i64* %17
%85 = load i8**, i8*** %6
%86 = load i8*, i8** %85
%87 = call i32 @strcpy(i8* %84, i8* %86)
%88 = load i8**, i8*** %6
%89 = load i8*, i8** %88
%90 = load i32, i32* %8
%91 = load i8*, i8** %7
%92 = call i32 @strlen(i8* %91)
%93 = add nsw i32 %90, %92
%94 = load i8**, i8*** %6
%95 = load i8*, i8** %94
%96 = call i32 @strlen(i8* %95)
%97 = add nsw i32 %93, %96
%98 = add nsw i32 %97, 1
%99 = sext i32 %98 to i64
%100 = mul i64 %99, 1
%101 = trunc i64 %100 to i32
%102 = call i64 @realloc(i8* %89, i32 %101)
%103 = inttoptr i64 %102 to i8*
%104 = load i8**, i8*** %6
store i8* %103, i8** %104
%105 = load i8**, i8*** %6
%106 = load i8*, i8** %105
%107 = load i8*, i8** %12
%108 = call i32 @sprintf(i8* %106, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %107, i8* %84)
%109 = load i8*, i8** %16
br label %110
110: ; preds = %72, %68
%111 = load i8*, i8** %12
%112 = call i32 @free(i8* %111)
%113 = load i8*, i8** %5
%114 = load i32, i32* %9
%115 = load i32, i32* %8
%116 = sub nsw i32 %114, %115
%117 = sext i32 %116 to i64
%118 = getelementptr inbounds i8, i8* %113, i64 %117
store i8 0, i8* %118
%119 = load i8*, i8** %10
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"%s%s\00"
define void @BanglaNumber(i8* %0, i8** nocapture %1, i8* %2, i32 %3) {
%5 = tail call i32 @strlen(i8* %0)
%6 = add i32 %3, 1
%7 = zext i32 %6 to i64
%8 = alloca i8, i64 %7
%9 = tail call i32 @strlen(i8* %2)
%10 = add i32 %6, %9
%11 = tail call i64 @malloc(i32 %10)
%12 = inttoptr i64 %11 to i8*
%13 = icmp sgt i32 %5, 1
br i1 %13, label %14, label %25
14: ; preds = %4
%15 = sub i32 %5, %3
%16 = icmp slt i32 %3, 0
br i1 %16, label %30, label %17
17: ; preds = %14
%18 = sext i32 %15 to i64
%19 = getelementptr i8, i8* %0, i64 %18
%20 = call i32 @llvm.smax.i32(i32 %5, i32 %15)
%21 = add nuw i32 %20, %3
%22 = sub i32 %21, %5
%23 = zext i32 %22 to i64
%24 = add nuw nsw i64 %23, 1
br label %30
25: ; preds = %4
%26 = add nsw i32 %5, -1
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %0, i64 %27
%29 = load i8, i8* %28
store i8 %29, i8* %8
br label %30
30: ; preds = %17, %14, %25
%31 = call i32 @atoi(i8* %8)
%32 = icmp eq i32 %31, 0
br i1 %32, label %53, label %33
33: ; preds = %30
%34 = call i32 @strcpy(i8* %12, i8* %8)
%35 = call i32 @strcat(i8* %12, i8* %2)
%36 = load i8*, i8** %1
%37 = call i32 @strlen(i8* %36)
%38 = add nsw i32 %37, 1
%39 = zext i32 %38 to i64
%40 = call i8* @llvm.stacksave()
%41 = alloca i8, i64 %39
%42 = load i8*, i8** %1
%43 = call i32 @strcpy(i8* %41, i8* %42)
%44 = load i8*, i8** %1
%45 = call i32 @strlen(i8* %2)
%46 = load i8*, i8** %1
%47 = call i32 @strlen(i8* %46)
%48 = add i32 %6, %45
%49 = add i32 %48, %47
%50 = call i64 @realloc(i8* %44, i32 %49)
%51 = inttoptr i64 %50 to i8*
store i8* %51, i8** %1
%52 = call i32 @sprintf(i8* dereferenceable(1) %51, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %12, i8* %41)
br label %53
53: ; preds = %33, %30
%54 = call i32 @free(i8* %12)
%55 = sub nsw i32 %5, %3
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8, i8* %0, i64 %56
store i8 0, i8* %57
ret void
}