#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 */
typedef int /*<<< orphan*/ name;

/* Variables and functions */
int /*<<< orphan*/ App_Set_Channel_Name(int, char *);
int /*<<< orphan*/ File_Fifo_Respond(char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *strtok(int /*<<< orphan*/ *, char *);
void File_Fifo_Set_Channel_Name(char *tokens) {
  int response;
  int channel;
  char buffer[128];
  char name[128];
  if (tokens != NULL) {
    sscanf(tokens, "%d", &channel);
    tokens = strtok(NULL, " \n");
    if (strlen(tokens) < (sizeof(name) - 1))
      strcpy(name, tokens);
    App_Set_Channel_Name(channel, name);
    response = 0;
  } else {
    response = -1;
  }
  sprintf(buffer, "%d\n", response);
  File_Fifo_Respond(buffer);
}


x86 assembly (clang, -O0):
<File_Fifo_Set_Channel_Name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11f2 <File_Fifo_Set_Channel_Name+0x82>
mov    -0x8(%rbp),%rdi
lea    0xe6b(%rip),%rsi
lea    -0x10(%rbp),%rdx
call   1070 <sscanf@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe5a(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
cltq
cmp    $0x7f,%rax
jae    11d7 <File_Fifo_Set_Channel_Name+0x67>
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%edi
lea    -0x110(%rbp),%rsi
call   1050 <App_Set_Channel_Name@plt>
movl   $0x0,-0xc(%rbp)
jmp    11f9 <File_Fifo_Set_Channel_Name+0x89>
movl   $0xffffffff,-0xc(%rbp)
lea    -0x90(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xdfc(%rip),%rsi
call   1090 <sprintf@plt>
lea    -0x90(%rbp),%rdi
call   1060 <File_Fifo_Respond@plt>
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<File_Fifo_Set_Channel_Name>:
push   %r14
push   %rbx
sub    $0x118,%rsp
test   %rdi,%rdi
je     11ce <File_Fifo_Set_Channel_Name+0x5e>
lea    0xe7a(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1070 <sscanf@plt>
lea    0xe6c(%rip),%rsi
xor    %r14d,%r14d
xor    %edi,%edi
call   1080 <strtok@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <strlen@plt>
cmp    $0x7e,%eax
ja     11be <File_Fifo_Set_Channel_Name+0x4e>
lea    0x10(%rsp),%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    0xc(%rsp),%edi
lea    0x10(%rsp),%rsi
call   1050 <App_Set_Channel_Name@plt>
jmp    11d4 <File_Fifo_Set_Channel_Name+0x64>
mov    $0xffffffff,%r14d
lea    0xe2b(%rip),%rsi
lea    0x90(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14d,%edx
call   1090 <sprintf@plt>
mov    %rbx,%rdi
call   1060 <File_Fifo_Respond@plt>
add    $0x118,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c" \0A\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define void @File_Fifo_Set_Channel_Name(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca [128 x i8]
%6 = alloca [128 x i8]
store i8* %0, i8** %2
%7 = load i8*, i8** %2
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %25
9: ; preds = %1
%10 = load i8*, i8** %2
%11 = call i32 @sscanf(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%12 = call i8* @strtok(i32* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i8* %12, i8** %2
%13 = load i8*, i8** %2
%14 = call i32 @strlen(i8* %13)
%15 = sext i32 %14 to i64
%16 = icmp ult i64 %15, 127
br i1 %16, label %17, label %21
17: ; preds = %9
%18 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%19 = load i8*, i8** %2
%20 = call i32 @strcpy(i8* %18, i8* %19)
br label %21
21: ; preds = %17, %9
%22 = load i32, i32* %4
%23 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%24 = call i32 @App_Set_Channel_Name(i32 %22, i8* %23)
store i32 0, i32* %3
br label %26
25: ; preds = %1
store i32 -1, i32* %3
br label %26
26: ; preds = %25, %21
%27 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%28 = load i32, i32* %3
%29 = call i32 @sprintf(i8* %27, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %28)
%30 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%31 = call i32 @File_Fifo_Respond(i8* %30)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c" \0A\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define void @File_Fifo_Set_Channel_Name(i8* %0) {
%2 = alloca i32
%3 = alloca [128 x i8]
%4 = alloca [128 x i8]
%5 = bitcast i32* %2 to i8*
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%8 = icmp eq i8* %0, null
br i1 %8, label %19, label %9
9: ; preds = %1
%10 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%11 = call i8* @strtok(i32* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @strlen(i8* %11)
%13 = icmp ult i32 %12, 127
br i1 %13, label %14, label %16
14: ; preds = %9
%15 = call i32 @strcpy(i8* %7, i8* %11)
br label %16
16: ; preds = %14, %9
%17 = load i32, i32* %2
%18 = call i32 @App_Set_Channel_Name(i32 %17, i8* %7)
br label %19
19: ; preds = %1, %16
%20 = phi i32 [ 0, %16 ], [ -1, %1 ]
%21 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %20)
%22 = call i32 @File_Fifo_Respond(i8* %6)
ret void
}