#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 */
char *C_mkAssign(char *, char *);
char *C_mkIndexName2(char *);
char *UTIL_mallocStr(scalar_t__);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
char *C_mkIndex2(char *name, char *indexNum) {
  char *varName = C_mkIndexName2(name);
  char *assign = C_mkAssign(varName, indexNum);
  char *index = UTIL_mallocStr(strlen(assign) + strlen("    "));
  free(varName);
  strcpy(index, "    ");
  strcat(index, assign);
  free(assign);
  return index;
}


x86 assembly (clang, -O0):
<C_mkIndex2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1080 <C_mkIndexName2@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <C_mkAssign@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,-0x30(%rbp)
lea    0xe4e(%rip),%rdi
call   1060 <strlen@plt>
mov    -0x30(%rbp),%rdi
add    %rax,%rdi
call   1070 <UTIL_mallocStr@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
lea    0xe25(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1090 <strcat@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<C_mkIndex2>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
call   1080 <C_mkIndexName2@plt>
mov    %rax,%r15
mov    %rax,%rdi
mov    %r14,%rsi
call   1050 <C_mkAssign@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1060 <strlen@plt>
lea    0x4(%rax),%rdi
call   1070 <UTIL_mallocStr@plt>
mov    %rax,%rbx
mov    %r15,%rdi
call   1030 <free@plt>
lea    0xe4f(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1090 <strcat@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c" \00"
define i8* @C_mkIndex2(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = load i8*, i8** %3
%9 = call i8* @C_mkIndexName2(i8* %8)
store i8* %9, i8** %5
%10 = load i8*, i8** %5
%11 = load i8*, i8** %4
%12 = call i8* @C_mkAssign(i8* %10, i8* %11)
store i8* %12, i8** %6
%13 = load i8*, i8** %6
%14 = call i64 @strlen(i8* %13)
%15 = call i64 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%16 = add nsw i64 %14, %15
%17 = call i8* @UTIL_mallocStr(i64 %16)
store i8* %17, i8** %7
%18 = load i8*, i8** %5
%19 = call i32 @free(i8* %18)
%20 = load i8*, i8** %7
%21 = call i32 @strcpy(i8* %20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%22 = load i8*, i8** %7
%23 = load i8*, i8** %6
%24 = call i32 @strcat(i8* %22, i8* %23)
%25 = load i8*, i8** %6
%26 = call i32 @free(i8* %25)
%27 = load i8*, i8** %7
ret i8* %27
}

LLVM IR (-O2):
@.str = [5 x i8] c" \00"
define i8* @C_mkIndex2(i8* %0, i8* %1) {
%3 = tail call i8* @C_mkIndexName2(i8* %0)
%4 = tail call i8* @C_mkAssign(i8* %3, i8* %1)
%5 = tail call i64 @strlen(i8* dereferenceable(1) %4)
%6 = add nsw i64 %5, 4
%7 = tail call i8* @UTIL_mallocStr(i64 %6)
%8 = tail call i32 @free(i8* %3)
%9 = tail call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 @strcat(i8* %7, i8* %4)
%11 = tail call i32 @free(i8* %4)
ret i8* %7
}