#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 *rtl_htblGet(void *, char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strlen(char *);
char *rtl_iniStr(void *ht, char *sec, int index, char *var, char *def) {
  char path[256];
  char tmp[256];
  char *pt;
  char *val;
  pt = path;
  path[0] = '\0';
  if (sec && *sec)
    strcat(path, sec);
  if (index >= 0) {
    sprintf(tmp, ":%d", index);
    strcat(path, tmp);
  }
  if (strlen(path))
    strcat(path, ".");
  strcat(path, var);
  if (*pt == '.')
    pt++;
  val = rtl_htblGet(ht, pt);
  if (!val)
    return def;
  return val;
}


x86 assembly (clang, -O0):
<rtl_iniStr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x240,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
lea    -0x130(%rbp),%rax
mov    %rax,-0x238(%rbp)
movb   $0x0,-0x130(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     119e <rtl_iniStr+0x5e>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     119e <rtl_iniStr+0x5e>
lea    -0x130(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcat@plt>
cmpl   $0x0,-0x1c(%rbp)
jl     11d1 <rtl_iniStr+0x91>
lea    -0x230(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    0xe47(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x130(%rbp),%rdi
lea    -0x230(%rbp),%rsi
call   1050 <strcat@plt>
lea    -0x130(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%rax
je     11fa <rtl_iniStr+0xba>
lea    -0x130(%rbp),%rdi
lea    0xe0f(%rip),%rsi
call   1050 <strcat@plt>
lea    -0x130(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1050 <strcat@plt>
mov    -0x238(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    122f <rtl_iniStr+0xef>
mov    -0x238(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x238(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x238(%rbp),%rsi
call   1040 <rtl_htblGet@plt>
mov    %rax,-0x240(%rbp)
cmpq   $0x0,-0x240(%rbp)
jne    1261 <rtl_iniStr+0x121>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    126c <rtl_iniStr+0x12c>
mov    -0x240(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x240,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rtl_iniStr>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x200,%rsp
mov    %r8,%r14
mov    %rcx,%r12
mov    %edx,%ebp
mov    %rdi,%r15
movb   $0x0,(%rsp)
test   %rsi,%rsi
je     1160 <rtl_iniStr+0x30>
cmpb   $0x0,(%rsi)
je     1160 <rtl_iniStr+0x30>
mov    %rsp,%rdi
call   1040 <strcat@plt>
test   %ebp,%ebp
js     1188 <rtl_iniStr+0x58>
lea    0xe95(%rip),%rsi
lea    0x100(%rsp),%rbx
mov    %rbx,%rdi
mov    %ebp,%edx
call   1050 <sprintf@plt>
mov    %rsp,%rdi
mov    %rbx,%rsi
call   1040 <strcat@plt>
cmpb   $0x0,(%rsp)
je     119d <rtl_iniStr+0x6d>
lea    0xe6f(%rip),%rsi
mov    %rsp,%rdi
call   1040 <strcat@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <strcat@plt>
cmpb   $0x2e,(%rsp)
lea    0x1(%rsp),%rsi
cmovne %rbx,%rsi
mov    %r15,%rdi
call   1030 <rtl_htblGet@plt>
test   %rax,%rax
cmove  %r14,%rax
add    $0x200,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c":%d\00"
@.str.1 = [2 x i8] c".\00"
define i8* @rtl_iniStr(i8* %0, i8* %1, i32 %2, i8* %3, i8* %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca [256 x i8]
%13 = alloca [256 x i8]
%14 = alloca i8*
%15 = alloca i8*
store i8* %0, i8** %7
store i8* %1, i8** %8
store i32 %2, i32* %9
store i8* %3, i8** %10
store i8* %4, i8** %11
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
store i8* %16, i8** %14
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
store i8 0, i8* %17
%18 = load i8*, i8** %8
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %29
20: ; preds = %5
%21 = load i8*, i8** %8
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %20
%26 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%27 = load i8*, i8** %8
%28 = call i32 @strcat(i8* %26, i8* %27)
br label %29
29: ; preds = %25, %20, %5
%30 = load i32, i32* %9
%31 = icmp sge i32 %30, 0
br i1 %31, label %32, label %39
32: ; preds = %29
%33 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%34 = load i32, i32* %9
%35 = call i32 @sprintf(i8* %33, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %34)
%36 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%37 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%38 = call i32 @strcat(i8* %36, i8* %37)
br label %39
39: ; preds = %32, %29
%40 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%41 = call i64 @strlen(i8* %40)
%42 = icmp ne i64 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %39
%44 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%45 = call i32 @strcat(i8* %44, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %46
46: ; preds = %43, %39
%47 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%48 = load i8*, i8** %10
%49 = call i32 @strcat(i8* %47, i8* %48)
%50 = load i8*, i8** %14
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = icmp eq i32 %52, 46
br i1 %53, label %54, label %57
54: ; preds = %46
%55 = load i8*, i8** %14
%56 = getelementptr inbounds i8, i8* %55, i32 1
store i8* %56, i8** %14
br label %57
57: ; preds = %54, %46
%58 = load i8*, i8** %7
%59 = load i8*, i8** %14
%60 = call i8* @rtl_htblGet(i8* %58, i8* %59)
store i8* %60, i8** %15
%61 = load i8*, i8** %15
%62 = icmp ne i8* %61, null
br i1 %62, label %65, label %63
63: ; preds = %57
%64 = load i8*, i8** %11
store i8* %64, i8** %6
br label %67
65: ; preds = %57
%66 = load i8*, i8** %15
store i8* %66, i8** %6
br label %67
67: ; preds = %65, %63
%68 = load i8*, i8** %6
ret i8* %68
}

LLVM IR (-O2):
@.str = [4 x i8] c":%d\00"
@.str.1 = [2 x i8] c".\00"
define i8* @rtl_iniStr(i8* %0, i8* %1, i32 %2, i8* %3, i8* readnone %4) {
%6 = alloca [256 x i8]
%7 = alloca [256 x i8]
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
store i8 0, i8* %8
%10 = icmp eq i8* %1, null
br i1 %10, label %16, label %11
11: ; preds = %5
%12 = load i8, i8* %1
%13 = icmp eq i8 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %11
%15 = call i32 @strcat(i8* %8, i8* %1)
br label %16
16: ; preds = %14, %11, %5
%17 = icmp sgt i32 %2, -1
br i1 %17, label %18, label %21
18: ; preds = %16
%19 = call i32 @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %2)
%20 = call i32 @strcat(i8* %8, i8* %9)
br label %21
21: ; preds = %18, %16
%22 = load i8, i8* %8
%23 = icmp eq i8 %22, 0
br i1 %23, label %26, label %24
24: ; preds = %21
%25 = call i32 @strcat(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %26
26: ; preds = %24, %21
%27 = call i32 @strcat(i8* %8, i8* %3)
%28 = load i8, i8* %8
%29 = icmp eq i8 %28, 46
%30 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 1
%31 = select i1 %29, i8* %30, i8* %8
%32 = call i8* @rtl_htblGet(i8* %0, i8* %31)
%33 = icmp eq i8* %32, null
%34 = select i1 %33, i8* %4, i8* %32
ret i8* %34
}