#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);
char *l_mkFullSubst(char *bufret, char *usr2red, int n) {
  char *tmp = bufret;
  int i, res;
  for (i = 1; i <= n; i++) {
    res = usr2red[i];
    sprintf(tmp, "%d:", res);
    while (*(++tmp) != '\0')
      ;
  }
  *(tmp - 1) = '\0';
  return bufret;
}


x86 assembly (clang, -O0):
<l_mkFullSubst>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     1194 <l_mkFullSubst+0x84>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%edx
lea    0xea5(%rip),%rsi
call   1030 <sprintf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
je     1181 <l_mkFullSubst+0x71>
jmp    1160 <l_mkFullSubst+0x50>
jmp    1186 <l_mkFullSubst+0x76>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1132 <l_mkFullSubst+0x22>
mov    -0x20(%rbp),%rax
movb   $0x0,-0x1(%rax)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<l_mkFullSubst>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
mov    %rdi,%rbx
test   %edx,%edx
jle    1163 <l_mkFullSubst+0x53>
mov    %edx,%r12d
mov    %rsi,%r15
add    $0x1,%r12d
mov    $0x1,%ebp
lea    0xec5(%rip),%r13
mov    %r14,%rbx
xchg   %ax,%ax
movsbl (%r15,%rbp,1),%edx
mov    %rbx,%rdi
mov    %r13,%rsi
call   1030 <sprintf@plt>
cmpb   $0x0,0x1(%rbx)
lea    0x1(%rbx),%rbx
jne    1150 <l_mkFullSubst+0x40>
add    $0x1,%rbp
cmp    %r12,%rbp
jne    1140 <l_mkFullSubst+0x30>
movb   $0x0,-0x1(%rbx)
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d:\00"
define i8* @l_mkFullSubst(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%10 = load i8*, i8** %4
store i8* %10, i8** %7
store i32 1, i32* %8
br label %11
11: ; preds = %33, %3
%12 = load i32, i32* %8
%13 = load i32, i32* %6
%14 = icmp sle i32 %12, %13
br i1 %14, label %15, label %36
15: ; preds = %11
%16 = load i8*, i8** %5
%17 = load i32, i32* %8
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
store i32 %21, i32* %9
%22 = load i8*, i8** %7
%23 = load i32, i32* %9
%24 = call i32 @sprintf(i8* %22, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %23)
br label %25
25: ; preds = %31, %15
%26 = load i8*, i8** %7
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %7
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %25
br label %25
32: ; preds = %25
br label %33
33: ; preds = %32
%34 = load i32, i32* %8
%35 = add nsw i32 %34, 1
store i32 %35, i32* %8
br label %11
36: ; preds = %11
%37 = load i8*, i8** %7
%38 = getelementptr inbounds i8, i8* %37, i64 -1
store i8 0, i8* %38
%39 = load i8*, i8** %4
ret i8* %39
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d:\00"
define i8* @l_mkFullSubst(i8* returned %0, i8* nocapture %1, i32 %2) {
%4 = icmp slt i32 %2, 1
br i1 %4, label %23, label %5
5: ; preds = %3
%6 = add nuw i32 %2, 1
%7 = zext i32 %6 to i64
br label %8
8: ; preds = %5, %20
%9 = phi i64 [ 1, %5 ], [ %21, %20 ]
%10 = phi i8* [ %0, %5 ], [ %17, %20 ]
%11 = getelementptr inbounds i8, i8* %1, i64 %9
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = tail call i32 @sprintf(i8* dereferenceable(1) %10, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %13)
br label %15
15: ; preds = %15, %8
%16 = phi i8* [ %10, %8 ], [ %17, %15 ]
%17 = getelementptr inbounds i8, i8* %16, i64 1
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 0
br i1 %19, label %20, label %15
20: ; preds = %15
%21 = add nuw nsw i64 %9, 1
%22 = icmp eq i64 %21, %7
br i1 %22, label %23, label %8
23: ; preds = %20, %3
%24 = phi i8* [ %0, %3 ], [ %17, %20 ]
%25 = getelementptr inbounds i8, i8* %24, i64 -1
store i8 0, i8* %25
ret i8* %0
}