#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*/ free(char *);
char *get_table_name(char *, char *);
scalar_t__ piece(char *, char, char *, int);
int /*<<< orphan*/ sprintf(char *, char *, ...);
char *strdup(char *);
char *get_multi_table_name(char *application_name,
                           char *multi_folder_name_list_string) {
  char multi_table_name[1024];
  char *ptr = multi_table_name;
  char folder_name[128];
  char *table_name;
  int i;
  for (i = 0; piece(folder_name, ',', multi_folder_name_list_string, i); i++) {
    if (i)
      ptr += sprintf(ptr, ",");
    table_name = get_table_name(application_name, folder_name);
    ptr += sprintf(ptr, "%s", table_name);
    free(table_name);
  }
  return strdup(multi_table_name);
}


x86 assembly (clang, -O0):
<get_multi_table_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4b0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x410(%rbp),%rax
mov    %rax,-0x418(%rbp)
movl   $0x0,-0x4ac(%rbp)
lea    -0x4a0(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x4ac(%rbp),%ecx
mov    $0x2c,%esi
call   1060 <piece@plt>
cmp    $0x0,%rax
je     1241 <get_multi_table_name+0xf1>
cmpl   $0x0,-0x4ac(%rbp)
je     11d8 <get_multi_table_name+0x88>
mov    -0x418(%rbp),%rdi
lea    0xe45(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
mov    %eax,%ecx
mov    -0x418(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x418(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x4a0(%rbp),%rsi
call   1040 <get_table_name@plt>
mov    %rax,-0x4a8(%rbp)
mov    -0x418(%rbp),%rdi
mov    -0x4a8(%rbp),%rdx
lea    0xdfe(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
mov    %eax,%ecx
mov    -0x418(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x418(%rbp)
mov    -0x4a8(%rbp),%rdi
call   1030 <free@plt>
mov    -0x4ac(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4ac(%rbp)
jmp    117b <get_multi_table_name+0x2b>
lea    -0x410(%rbp),%rdi
call   1070 <strdup@plt>
add    $0x4b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_multi_table_name>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x498,%rsp
mov    %rsi,%r15
mov    %rdi,0x8(%rsp)
lea    0x10(%rsp),%rdi
mov    $0x2c,%esi
mov    %r15,%rdx
xor    %ecx,%ecx
call   1060 <piece@plt>
test   %rax,%rax
je     1253 <get_multi_table_name+0x103>
lea    0x10(%rsp),%r12
mov    0x8(%rsp),%rdi
mov    %r12,%rsi
call   1050 <get_table_name@plt>
mov    %rax,%rbp
lea    0x90(%rsp),%rdi
mov    %rax,%rsi
call   1040 <stpcpy@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
mov    $0x2c,%esi
mov    %r15,%rdx
mov    $0x1,%ecx
call   1060 <piece@plt>
test   %rax,%rax
je     1253 <get_multi_table_name+0x103>
lea    0x90(%rsp),%rax
sub    %eax,%ebx
movslq %ebx,%rax
lea    (%rsp,%rax,1),%r14
add    $0x90,%r14
mov    $0x2,%ebp
lea    0x10(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
movw   $0x2c,(%r14)
lea    0x1(%r14),%r13
mov    0x8(%rsp),%rdi
mov    %r12,%rsi
call   1050 <get_table_name@plt>
mov    %rax,%rbx
mov    %r13,%rdi
mov    %rax,%rsi
call   1040 <stpcpy@plt>
sub    %r13d,%eax
cltq
add    %rax,%r14
add    $0x1,%r14
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
mov    $0x2c,%esi
mov    %r15,%rdx
mov    %ebp,%ecx
call   1060 <piece@plt>
add    $0x1,%ebp
test   %rax,%rax
jne    1200 <get_multi_table_name+0xb0>
lea    0x90(%rsp),%rdi
call   1070 <strdup@plt>
add    $0x498,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define noalias i8* @get_multi_table_name(i8* %0, i8* %1) {
%3 = alloca [1024 x i8]
%4 = alloca [128 x i8]
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%7 = call i64 @piece(i8* %6, i8 signext 44, i8* %1, i32 0)
%8 = icmp eq i64 %7, 0
br i1 %8, label %39, label %9
9: ; preds = %2
%10 = call i8* @get_table_name(i8* %0, i8* %6)
%11 = call i8* @stpcpy(i8* %5, i8* %10)
%12 = call i32 @free(i8* %10)
%13 = call i64 @piece(i8* %6, i8 signext 44, i8* %1, i32 1)
%14 = icmp eq i64 %13, 0
br i1 %14, label %39, label %15
15: ; preds = %9
%16 = ptrtoint i8* %11 to i64
%17 = ptrtoint [1024 x i8]* %3 to i64
%18 = sub i64 %16, %17
%19 = shl i64 %18, 32
%20 = ashr exact i64 %19, 32
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %20
br label %22
22: ; preds = %15, %22
%23 = phi i32 [ %36, %22 ], [ 1, %15 ]
%24 = phi i8* [ %34, %22 ], [ %21, %15 ]
%25 = bitcast i8* %24 to i16*
store i16 44, i16* %25
%26 = getelementptr inbounds i8, i8* %24, i64 1
%27 = call i8* @get_table_name(i8* %0, i8* %6)
%28 = call i8* @stpcpy(i8* %26, i8* %27)
%29 = ptrtoint i8* %28 to i64
%30 = ptrtoint i8* %26 to i64
%31 = sub i64 %29, %30
%32 = shl i64 %31, 32
%33 = ashr exact i64 %32, 32
%34 = getelementptr inbounds i8, i8* %26, i64 %33
%35 = call i32 @free(i8* %27)
%36 = add nuw nsw i32 %23, 1
%37 = call i64 @piece(i8* %6, i8 signext 44, i8* %1, i32 %36)
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %22
39: ; preds = %22, %9, %2
%40 = call i8* @strdup(i8* %5)
ret i8* %40
}