#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 *chan_name(int /*<<< orphan*/);
char *malloc(scalar_t__);
int /*<<< orphan*/ sprintf(char *, char *, char const *, int, int, char const *,
                           char const *);
scalar_t__ strlen(char const *);
int assemble_epiname(char **enam, const char *indir, const char *timeslot,
                     int sat, int rss, int iodc) {
  char *arr = malloc(61 + strlen(indir) + 1);
  const char *band;
  band = chan_name(0);
  if (rss == 1)
    sprintf(arr, "%sH-000-MSG%d__-MSG%d_RSS____-%s___-EPI______-%s-__", indir,
            sat, sat, band, timeslot);
  else if (iodc == 1)
    sprintf(arr, "%sH-000-MSG%d__-MSG%d_IODC___-%s___-EPI______-%s-__", indir,
            sat, sat, band, timeslot);
  else
    sprintf(arr, "%sH-000-MSG%d__-MSG%d________-%s___-EPI______-%s-__", indir,
            sat, sat, band, timeslot);
  *enam = arr;
  return 0;
}


x86 assembly (clang, -O0):
<assemble_epiname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rdi
add    $0x3d,%rdi
add    $0x1,%rdi
call   1050 <malloc@plt>
mov    %rax,-0x30(%rbp)
xor    %edi,%edi
call   1030 <chan_name@plt>
mov    %rax,-0x38(%rbp)
cmpl   $0x1,-0x20(%rbp)
jne    11bd <assemble_epiname+0x7d>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
mov    -0x38(%rbp),%r9
mov    -0x18(%rbp),%rax
lea    0xe51(%rip),%rsi
mov    %rax,(%rsp)
call   1060 <sprintf@plt>
jmp    121f <assemble_epiname+0xdf>
cmpl   $0x1,-0x24(%rbp)
jne    11f3 <assemble_epiname+0xb3>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
mov    -0x38(%rbp),%r9
mov    -0x18(%rbp),%rax
lea    0xe4f(%rip),%rsi
mov    %rax,(%rsp)
call   1060 <sprintf@plt>
jmp    121a <assemble_epiname+0xda>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
mov    -0x38(%rbp),%r9
mov    -0x18(%rbp),%rax
lea    0xe57(%rip),%rsi
mov    %rax,(%rsp)
call   1060 <sprintf@plt>
jmp    121f <assemble_epiname+0xdf>
mov    -0x30(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<assemble_epiname>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9d,%r12d
mov    %r8d,%r13d
mov    %ecx,%ebp
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,0x10(%rsp)
mov    %rsi,%rdi
call   1040 <strlen@plt>
lea    0x3e(%rax),%rdi
call   1050 <malloc@plt>
mov    %rax,%r14
xor    %edi,%edi
call   1030 <chan_name@plt>
cmp    $0x1,%r12d
lea    0xead(%rip),%rcx
lea    0xeda(%rip),%rdx
cmove  %rcx,%rdx
cmp    $0x1,%r13d
lea    0xe63(%rip),%rsi
cmovne %rdx,%rsi
mov    %r15,(%rsp)
mov    %r14,%rdi
mov    %rbx,%rdx
mov    %ebp,%ecx
mov    %ebp,%r8d
mov    %rax,%r9
call   1060 <sprintf@plt>
mov    0x10(%rsp),%rax
mov    %r14,(%rax)
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [52 x i8] c"%sH-000-MSG%d__-MSG%d_RSS____-%s___-EPI______-%s-__\00"
@.str.1 = [52 x i8] c"%sH-000-MSG%d__-MSG%d_IODC___-%s___-EPI______-%s-__\00"
@.str.2 = [52 x i8] c"%sH-000-MSG%d__-MSG%d________-%s___-EPI______-%s-__\00"
define i32 @assemble_epiname(i8** %0, i8* %1, i8* %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca i8**
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i8*
store i8** %0, i8*** %7
store i8* %1, i8** %8
store i8* %2, i8** %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i32 %5, i32* %12
%15 = load i8*, i8** %8
%16 = call i64 @strlen(i8* %15)
%17 = add nsw i64 61, %16
%18 = add nsw i64 %17, 1
%19 = call i8* @malloc(i64 %18)
store i8* %19, i8** %13
%20 = call i8* @chan_name(i32 0)
store i8* %20, i8** %14
%21 = load i32, i32* %11
%22 = icmp eq i32 %21, 1
br i1 %22, label %23, label %31
23: ; preds = %6
%24 = load i8*, i8** %13
%25 = load i8*, i8** %8
%26 = load i32, i32* %10
%27 = load i32, i32* %10
%28 = load i8*, i8** %14
%29 = load i8*, i8** %9
%30 = call i32 @sprintf(i8* %24, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), i8* %25, i32 %26, i32 %27, i8* %28, i8* %29)
br label %51
31: ; preds = %6
%32 = load i32, i32* %12
%33 = icmp eq i32 %32, 1
br i1 %33, label %34, label %42
34: ; preds = %31
%35 = load i8*, i8** %13
%36 = load i8*, i8** %8
%37 = load i32, i32* %10
%38 = load i32, i32* %10
%39 = load i8*, i8** %14
%40 = load i8*, i8** %9
%41 = call i32 @sprintf(i8* %35, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0), i8* %36, i32 %37, i32 %38, i8* %39, i8* %40)
br label %50
42: ; preds = %31
%43 = load i8*, i8** %13
%44 = load i8*, i8** %8
%45 = load i32, i32* %10
%46 = load i32, i32* %10
%47 = load i8*, i8** %14
%48 = load i8*, i8** %9
%49 = call i32 @sprintf(i8* %43, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), i8* %44, i32 %45, i32 %46, i8* %47, i8* %48)
br label %50
50: ; preds = %42, %34
br label %51
51: ; preds = %50, %23
%52 = load i8*, i8** %13
%53 = load i8**, i8*** %7
store i8* %52, i8** %53
ret i32 0
}

LLVM IR (-O2):
@.str = [52 x i8] c"%sH-000-MSG%d__-MSG%d_RSS____-%s___-EPI______-%s-__\00"
@.str.1 = [52 x i8] c"%sH-000-MSG%d__-MSG%d_IODC___-%s___-EPI______-%s-__\00"
@.str.2 = [52 x i8] c"%sH-000-MSG%d__-MSG%d________-%s___-EPI______-%s-__\00"
define i32 @assemble_epiname(i8** nocapture writeonly %0, i8* %1, i8* %2, i32 %3, i32 %4, i32 %5) {
%7 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%8 = add nsw i64 %7, 62
%9 = tail call i8* @malloc(i64 %8)
%10 = tail call i8* @chan_name(i32 0)
%11 = icmp eq i32 %4, 1
%12 = icmp eq i32 %5, 1
%13 = select i1 %12, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0)
%14 = select i1 %11, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), i8* %13
%15 = tail call i32 @sprintf(i8* dereferenceable(1) %9, i8* dereferenceable(1) %14, i8* %1, i32 %3, i32 %3, i8* %10, i8* %2)
store i8* %9, i8** %0
ret i32 0
}