#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 *App_Get_Channel_Name(int);
int /*<<< orphan*/ File_Fifo_Respond(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
void File_Fifo_Get_Channel_Names(void) {
  int i;
  char buffer[1024] = {0};
  char *name;
  strcpy(buffer, "1\n");
  for (i = 0; i < (11 - 1); i++) {
    name = App_Get_Channel_Name(i);
    sprintf(buffer, "%s%s,", buffer, name);
  }
  buffer[strlen(buffer) - 1] = '\n';
  File_Fifo_Respond(buffer);
}


x86 assembly (clang, -O0):
<File_Fifo_Get_Channel_Names>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
lea    -0x410(%rbp),%rdi
lea    0xe74(%rip),%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0xa,-0x4(%rbp)
jge    11e0 <File_Fifo_Get_Channel_Names+0x80>
mov    -0x4(%rbp),%edi
call   1060 <App_Get_Channel_Name@plt>
mov    %rax,-0x418(%rbp)
lea    -0x410(%rbp),%rdi
lea    -0x410(%rbp),%rdx
mov    -0x418(%rbp),%rcx
lea    0xe36(%rip),%rsi
call   1080 <sprintf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1198 <File_Fifo_Get_Channel_Names+0x38>
lea    -0x410(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0xa,-0x410(%rbp,%rax,1)
0a
lea    -0x410(%rbp),%rdi
call   1070 <File_Fifo_Respond@plt>
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<File_Fifo_Get_Channel_Names>:
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    %rsp,%rbx
mov    $0x400,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
lea    0xe7d(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
xor    %edi,%edi
call   1060 <App_Get_Channel_Name@plt>
lea    0xe6a(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %rax,%rcx
call   1080 <sprintf@plt>
mov    $0x1,%edi
call   1060 <App_Get_Channel_Name@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %rax,%rcx
call   1080 <sprintf@plt>
mov    $0x2,%edi
call   1060 <App_Get_Channel_Name@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %rax,%rcx
call   1080 <sprintf@plt>
mov    $0x3,%edi
call   1060 <App_Get_Channel_Name@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %rax,%rcx
call   1080 <sprintf@plt>
mov    $0x4,%edi
call   1060 <App_Get_Channel_Name@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %rax,%rcx
call   1080 <sprintf@plt>
mov    $0x5,%edi
call   1060 <App_Get_Channel_Name@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %rax,%rcx
call   1080 <sprintf@plt>
mov    $0x6,%edi
call   1060 <App_Get_Channel_Name@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %rax,%rcx
call   1080 <sprintf@plt>
mov    $0x7,%edi
call   1060 <App_Get_Channel_Name@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %rax,%rcx
call   1080 <sprintf@plt>
mov    $0x8,%edi
call   1060 <App_Get_Channel_Name@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %rax,%rcx
call   1080 <sprintf@plt>
mov    $0x9,%edi
call   1060 <App_Get_Channel_Name@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %rax,%rcx
call   1080 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
movb   $0xa,-0x1(%rax,%rbx,1)
mov    %rbx,%rdi
call   1070 <File_Fifo_Respond@plt>
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"1\0A\00"
@.str.1 = [6 x i8] c"%s%s,\00"
define void @File_Fifo_Get_Channel_Names() {
%1 = alloca i32
%2 = alloca [1024 x i8]
%3 = alloca i8*
%4 = bitcast [1024 x i8]* %2 to i8*
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%6 = call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %1
br label %7
7: ; preds = %17, %0
%8 = load i32, i32* %1
%9 = icmp slt i32 %8, 10
br i1 %9, label %10, label %20
10: ; preds = %7
%11 = load i32, i32* %1
%12 = call i8* @App_Get_Channel_Name(i32 %11)
store i8* %12, i8** %3
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%15 = load i8*, i8** %3
%16 = call i32 @sprintf(i8* %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %14, i8* %15)
br label %17
17: ; preds = %10
%18 = load i32, i32* %1
%19 = add nsw i32 %18, 1
store i32 %19, i32* %1
br label %7
20: ; preds = %7
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%22 = call i32 @strlen(i8* %21)
%23 = sub nsw i32 %22, 1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %24
store i8 10, i8* %25
%26 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%27 = call i32 @File_Fifo_Respond(i8* %26)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"1\0A\00"
@.str.1 = [6 x i8] c"%s%s,\00"
define void @File_Fifo_Get_Channel_Names() {
%1 = alloca [1024 x i8]
%2 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%3 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%4 = call i8* @App_Get_Channel_Name(i32 0)
%5 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %2, i8* %4)
%6 = call i8* @App_Get_Channel_Name(i32 1)
%7 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %2, i8* %6)
%8 = call i8* @App_Get_Channel_Name(i32 2)
%9 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %2, i8* %8)
%10 = call i8* @App_Get_Channel_Name(i32 3)
%11 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %2, i8* %10)
%12 = call i8* @App_Get_Channel_Name(i32 4)
%13 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %2, i8* %12)
%14 = call i8* @App_Get_Channel_Name(i32 5)
%15 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %2, i8* %14)
%16 = call i8* @App_Get_Channel_Name(i32 6)
%17 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %2, i8* %16)
%18 = call i8* @App_Get_Channel_Name(i32 7)
%19 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %2, i8* %18)
%20 = call i8* @App_Get_Channel_Name(i32 8)
%21 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %2, i8* %20)
%22 = call i8* @App_Get_Channel_Name(i32 9)
%23 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %2, i8* %22)
%24 = call i32 @strlen(i8* %2)
%25 = add nsw i32 %24, -1
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 %26
store i8 10, i8* %27
%28 = call i32 @File_Fifo_Respond(i8* %2)
ret void
}