#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*/ strcat(char *, char *);
int strlen(char *);
int JoinNameIndexToSection(char **section, char *name, char *index) {
  int n1, n2;
  if ((n1 = strlen((char *)name)) < 1)
    return 0;
  if ((n2 = strlen((char *)index)) < 1)
    return 0;
  strcat(*section, name);
  strcat(*section + n1, ":");
  strcat(*section + n1 + 1, index);
  *(*section + n1 + 1 + n2) = '\0';
  return 1;
}


x86 assembly (clang, -O0):
<JoinNameIndexToSection>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x1,%eax
jge    1155 <JoinNameIndexToSection+0x35>
movl   $0x0,-0x4(%rbp)
jmp    11d9 <JoinNameIndexToSection+0xb9>
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x28(%rbp)
cmp    $0x1,%eax
jge    1176 <JoinNameIndexToSection+0x56>
movl   $0x0,-0x4(%rbp)
jmp    11d9 <JoinNameIndexToSection+0xb9>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcat@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
movslq -0x24(%rbp),%rax
add    %rax,%rdi
lea    0xe65(%rip),%rsi
call   1040 <strcat@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
movslq -0x24(%rbp),%rax
add    %rax,%rdi
add    $0x1,%rdi
mov    -0x20(%rbp),%rsi
call   1040 <strcat@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movslq -0x24(%rbp),%rcx
add    %rcx,%rax
movslq -0x28(%rbp),%rcx
movb   $0x0,0x1(%rax,%rcx,1)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<JoinNameIndexToSection>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r13
mov    %rdi,%r12
mov    %rsi,%rdi
call   1030 <strlen@plt>
xor    %ebp,%ebp
test   %eax,%eax
jle    1199 <JoinNameIndexToSection+0x79>
mov    %eax,%ebx
mov    %r14,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    1199 <JoinNameIndexToSection+0x79>
mov    %eax,%r15d
mov    (%r12),%rdi
mov    %r13,%rsi
call   1040 <strcat@plt>
mov    %ebx,%ebx
mov    (%r12),%rdi
add    %rbx,%rdi
lea    0xe91(%rip),%rsi
call   1040 <strcat@plt>
mov    (%r12),%rax
lea    (%rax,%rbx,1),%rdi
add    $0x1,%rdi
mov    %r14,%rsi
call   1040 <strcat@plt>
add    (%r12),%rbx
mov    %r15d,%eax
movb   $0x0,0x1(%rax,%rbx,1)
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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