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


x86 assembly (clang, -O0):
<l_usrTbl2usrTopol>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <invertsubstitution@plt>
movl   $0x1,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x24(%rbp),%eax
jg     11c9 <l_usrTbl2usrTopol+0xa9>
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%edx
lea    0xe70(%rip),%rsi
call   1040 <sprintf@plt>
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x30(%rbp)
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
je     11b6 <l_usrTbl2usrTopol+0x96>
jmp    1195 <l_usrTbl2usrTopol+0x75>
jmp    11bb <l_usrTbl2usrTopol+0x9b>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1158 <l_usrTbl2usrTopol+0x38>
mov    -0x30(%rbp),%rax
movb   $0x0,-0x1(%rax)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<l_usrTbl2usrTopol>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%r13d
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
mov    %rsi,%rdi
mov    %rcx,%rsi
call   1030 <invertsubstitution@plt>
mov    %rbx,(%rsp)
test   %r13d,%r13d
jle    1193 <l_usrTbl2usrTopol+0x73>
add    $0x1,%r13d
mov    $0x1,%r14d
lea    0xea4(%rip),%rbp
mov    (%rsp),%rbx
movsbq (%r15,%r14,1),%rax
movsbl (%r12,%rax,1),%edx
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1040 <sprintf@plt>
cs nopw 0x0(%rax,%rax,1)
nop
cmpb   $0x0,0x1(%rbx)
lea    0x1(%rbx),%rbx
jne    1180 <l_usrTbl2usrTopol+0x60>
add    $0x1,%r14
cmp    %r13,%r14
jne    1160 <l_usrTbl2usrTopol+0x40>
movb   $0x0,-0x1(%rbx)
mov    (%rsp),%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_usrTbl2usrTopol(i8* %0, i8* %1, i8* %2, i8* %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i32 %4, i32* %10
%14 = load i8*, i8** %6
store i8* %14, i8** %11
%15 = load i8*, i8** %7
%16 = load i8*, i8** %9
%17 = call i32 @invertsubstitution(i8* %15, i8* %16)
store i32 1, i32* %12
br label %18
18: ; preds = %46, %5
%19 = load i32, i32* %12
%20 = load i32, i32* %10
%21 = icmp sle i32 %19, %20
br i1 %21, label %22, label %49
22: ; preds = %18
%23 = load i8*, i8** %8
%24 = load i32, i32* %12
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
store i32 %28, i32* %13
%29 = load i8*, i8** %7
%30 = load i32, i32* %13
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
store i32 %34, i32* %13
%35 = load i8*, i8** %11
%36 = load i32, i32* %13
%37 = call i32 @sprintf(i8* %35, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %36)
br label %38
38: ; preds = %44, %22
%39 = load i8*, i8** %11
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %11
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %45
44: ; preds = %38
br label %38
45: ; preds = %38
br label %46
46: ; preds = %45
%47 = load i32, i32* %12
%48 = add nsw i32 %47, 1
store i32 %48, i32* %12
br label %18
49: ; preds = %18
%50 = load i8*, i8** %11
%51 = getelementptr inbounds i8, i8* %50, i64 -1
store i8 0, i8* %51
%52 = load i8*, i8** %6
ret i8* %52
}

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