#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*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strcspn(char *, char *);
int /*<<< orphan*/ strncpy(char *, char *, int /*<<< orphan*/);
char *strstr(char *, char *);
void insert_txtlen(char *text_rec, int txtrec_ctr) {
  char *temp_txtrec_r, temp_txtrec_l[100] = "", temp_ctr[5] = "";
  strncpy(temp_txtrec_l, text_rec, strcspn(text_rec, "-"));
  temp_txtrec_r = strstr(text_rec, "-") + 1;
  sprintf(temp_ctr, "%02d", txtrec_ctr);
  strcat(temp_txtrec_l, temp_ctr);
  strcat(temp_txtrec_l, temp_txtrec_r);
  strcpy(text_rec, temp_txtrec_l);
}


x86 assembly (clang, -O0):
<insert_txtlen>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1050 <memset@plt>
lea    -0x85(%rbp),%rdi
xor    %esi,%esi
mov    $0x5,%edx
call   1050 <memset@plt>
lea    -0x80(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe3a(%rip),%rsi
call   1060 <strcspn@plt>
mov    -0x98(%rbp),%rdi
mov    -0x90(%rbp),%rsi
mov    %eax,%edx
call   1030 <strncpy@plt>
mov    -0x8(%rbp),%rdi
lea    0xe15(%rip),%rsi
call   1090 <strstr@plt>
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
lea    -0x85(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xdf9(%rip),%rsi
call   1080 <sprintf@plt>
lea    -0x80(%rbp),%rdi
lea    -0x85(%rbp),%rsi
call   1070 <strcat@plt>
lea    -0x80(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <strcat@plt>
mov    -0x8(%rbp),%rdi
lea    -0x80(%rbp),%rsi
call   1040 <strcpy@plt>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<insert_txtlen>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x80,%rsp
mov    %esi,%r14d
mov    %rdi,%rbx
xorps  %xmm0,%xmm0
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movl   $0x0,0x70(%rsp)
movb   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
lea    0xe4e(%rip),%rsi
call   1060 <strcspn@plt>
lea    0x10(%rsp),%r15
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <strncpy@plt>
mov    %rbx,%rdi
mov    $0x2d,%esi
call   1050 <strchr@plt>
lea    0x1(%rax),%rbp
lea    0xe21(%rip),%rsi
lea    0x8(%rsp),%r12
mov    %r12,%rdi
mov    %r14d,%edx
call   1080 <sprintf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <strcat@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
call   1070 <strcat@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcpy@plt>
add    $0x80,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"-\00"
@.str.1 = [5 x i8] c"%02d\00"
define void @insert_txtlen(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca [100 x i8]
%7 = alloca [5 x i8]
store i8* %0, i8** %3
store i32 %1, i32* %4
%8 = bitcast [100 x i8]* %6 to i8*
%9 = bitcast [5 x i8]* %7 to i8*
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%11 = load i8*, i8** %3
%12 = load i8*, i8** %3
%13 = call i32 @strcspn(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @strncpy(i8* %10, i8* %11, i32 %13)
%15 = load i8*, i8** %3
%16 = call i8* @strstr(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%17 = getelementptr inbounds i8, i8* %16, i64 1
store i8* %17, i8** %5
%18 = getelementptr inbounds [5 x i8], [5 x i8]* %7, i64 0, i64 0
%19 = load i32, i32* %4
%20 = call i32 @sprintf(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%22 = getelementptr inbounds [5 x i8], [5 x i8]* %7, i64 0, i64 0
%23 = call i32 @strcat(i8* %21, i8* %22)
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%25 = load i8*, i8** %5
%26 = call i32 @strcat(i8* %24, i8* %25)
%27 = load i8*, i8** %3
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%29 = call i32 @strcpy(i8* %27, i8* %28)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"-\00"
@.str.1 = [5 x i8] c"%02d\00"
define void @insert_txtlen(i8* %0, i32 %1) {
%3 = alloca [100 x i8]
%4 = alloca [5 x i8]
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%7 = tail call i32 @strcspn(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @strncpy(i8* %5, i8* %0, i32 %7)
%9 = call i8* @strchr(i8* dereferenceable(1) %0, i32 45)
%10 = getelementptr inbounds i8, i8* %9, i64 1
%11 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %1)
%12 = call i32 @strcat(i8* %5, i8* %6)
%13 = call i32 @strcat(i8* %5, i8* %10)
%14 = call i32 @strcpy(i8* %0, i8* %5)
ret void
}