#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 atoi(char const *);
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char const *);
scalar_t__ strncmp(char const *, char *, int);
int createSartanoString(const char *pChannelStr, const char *pOn_offStr,
                        char *pTxStr) {
  *pTxStr = '\0';
  int on_offCode;
  int bit;
  on_offCode = atoi(pOn_offStr);
  if ((strlen(pChannelStr) != 10) || (on_offCode < 0) || (on_offCode > 1)) {
  } else {
    strcat(pTxStr, "S");
    for (bit = 0; bit <= 9; bit++) {
      if (strncmp(pChannelStr + bit, "1", 1) == 0) {
        strcat(pTxStr, "$k$k");
      } else {
        strcat(pTxStr, "$kk$");
      }
    }
    if (on_offCode >= 1)
      strcat(pTxStr, "$k$k$kk$");
    else
      strcat(pTxStr, "$kk$$k$k");
    strcat(pTxStr, "$k+");
  }
  return strlen(pTxStr);
}


x86 assembly (clang, -O0):
<createSartanoString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0xa,%eax
jne    118d <createSartanoString+0x4d>
cmpl   $0x0,-0x1c(%rbp)
jl     118d <createSartanoString+0x4d>
cmpl   $0x1,-0x1c(%rbp)
jle    1192 <createSartanoString+0x52>
jmp    1250 <createSartanoString+0x110>
mov    -0x18(%rbp),%rdi
lea    0xe63(%rip),%rsi
call   1060 <strcat@plt>
movl   $0x0,-0x20(%rbp)
cmpl   $0x9,-0x20(%rbp)
jg     1211 <createSartanoString+0xd1>
mov    -0x8(%rbp),%rdi
movslq -0x20(%rbp),%rax
add    %rax,%rdi
lea    0xe3d(%rip),%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11ee <createSartanoString+0xae>
mov    -0x18(%rbp),%rdi
lea    0xe2d(%rip),%rsi
call   1060 <strcat@plt>
jmp    11fe <createSartanoString+0xbe>
mov    -0x18(%rbp),%rdi
lea    0xe0f(%rip),%rsi
call   1060 <strcat@plt>
jmp    1203 <createSartanoString+0xc3>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11a9 <createSartanoString+0x69>
cmpl   $0x1,-0x1c(%rbp)
jl     1230 <createSartanoString+0xf0>
mov    -0x18(%rbp),%rdi
lea    0xdde(%rip),%rsi
call   1060 <strcat@plt>
jmp    1240 <createSartanoString+0x100>
mov    -0x18(%rbp),%rdi
lea    0xdd2(%rip),%rsi
call   1060 <strcat@plt>
mov    -0x18(%rbp),%rdi
lea    0xdcb(%rip),%rsi
call   1060 <strcat@plt>
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<createSartanoString>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rdi,%rbp
movb   $0x0,(%rdx)
mov    %rsi,%rdi
call   1050 <atoi@plt>
mov    %eax,%r14d
mov    %rbp,%rdi
call   1040 <strlen@plt>
cmp    $0xa,%eax
jne    1333 <createSartanoString+0x1f3>
test   %r14d,%r14d
js     1333 <createSartanoString+0x1f3>
cmp    $0x1,%r14d
jg     1333 <createSartanoString+0x1f3>
lea    0xe76(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
lea    0xe69(%rip),%r15
mov    %rbp,%rdi
mov    %r15,%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
lea    0xe5e(%rip),%r13
lea    0xe4e(%rip),%r12
mov    %r12,%rsi
cmove  %r13,%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
lea    0x1(%rbp),%rdi
mov    %r15,%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
mov    %r12,%rsi
cmove  %r13,%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
lea    0x2(%rbp),%rdi
mov    %r15,%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
mov    %r12,%rsi
cmove  %r13,%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
lea    0x3(%rbp),%rdi
mov    %r15,%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
mov    %r12,%rsi
cmove  %r13,%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
lea    0x4(%rbp),%rdi
mov    %r15,%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
mov    %r12,%rsi
cmove  %r13,%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
lea    0x5(%rbp),%rdi
mov    %r15,%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
mov    %r12,%rsi
cmove  %r13,%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
lea    0x6(%rbp),%rdi
mov    %r15,%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
mov    %r12,%rsi
cmove  %r13,%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
lea    0x7(%rbp),%rdi
mov    %r15,%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
mov    %r12,%rsi
cmove  %r13,%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
lea    0x8(%rbp),%rdi
mov    %r15,%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
mov    %r12,%rsi
cmove  %r13,%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
add    $0x9,%rbp
mov    %rbp,%rdi
mov    %r15,%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
cmove  %r13,%r12
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <strcat@plt>
test   %r14d,%r14d
lea    0xcf3(%rip),%rax
lea    0xcf5(%rip),%rsi
cmovg  %rax,%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
lea    0xceb(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <strlen@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"S\00"
@.str.1 = [2 x i8] c"1\00"
@.str.2 = [5 x i8] c"$k$k\00"
@.str.3 = [5 x i8] c"$kk$\00"
@.str.4 = [9 x i8] c"$k$k$kk$\00"
@.str.5 = [9 x i8] c"$kk$$k$k\00"
@.str.6 = [4 x i8] c"$k+\00"
define i32 @createSartanoString(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%9 = load i8*, i8** %6
store i8 0, i8* %9
%10 = load i8*, i8** %5
%11 = call i32 @atoi(i8* %10)
store i32 %11, i32* %7
%12 = load i8*, i8** %4
%13 = call i32 @strlen(i8* %12)
%14 = icmp ne i32 %13, 10
br i1 %14, label %21, label %15
15: ; preds = %3
%16 = load i32, i32* %7
%17 = icmp slt i32 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %15
%19 = load i32, i32* %7
%20 = icmp sgt i32 %19, 1
br i1 %20, label %21, label %22
21: ; preds = %18, %15, %3
br label %57
22: ; preds = %18
%23 = load i8*, i8** %6
%24 = call i32 @strcat(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %8
br label %25
25: ; preds = %42, %22
%26 = load i32, i32* %8
%27 = icmp sle i32 %26, 9
br i1 %27, label %28, label %45
28: ; preds = %25
%29 = load i8*, i8** %4
%30 = load i32, i32* %8
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
%33 = call i64 @strncmp(i8* %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %38
35: ; preds = %28
%36 = load i8*, i8** %6
%37 = call i32 @strcat(i8* %36, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %41
38: ; preds = %28
%39 = load i8*, i8** %6
%40 = call i32 @strcat(i8* %39, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %41
41: ; preds = %38, %35
br label %42
42: ; preds = %41
%43 = load i32, i32* %8
%44 = add nsw i32 %43, 1
store i32 %44, i32* %8
br label %25
45: ; preds = %25
%46 = load i32, i32* %7
%47 = icmp sge i32 %46, 1
br i1 %47, label %48, label %51
48: ; preds = %45
%49 = load i8*, i8** %6
%50 = call i32 @strcat(i8* %49, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
br label %54
51: ; preds = %45
%52 = load i8*, i8** %6
%53 = call i32 @strcat(i8* %52, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
br label %54
54: ; preds = %51, %48
%55 = load i8*, i8** %6
%56 = call i32 @strcat(i8* %55, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
br label %57
57: ; preds = %54, %21
%58 = load i8*, i8** %6
%59 = call i32 @strlen(i8* %58)
ret i32 %59
}

LLVM IR (-O2):
@.str = [2 x i8] c"S\00"
@.str.1 = [2 x i8] c"1\00"
@.str.2 = [5 x i8] c"$k$k\00"
@.str.3 = [5 x i8] c"$kk$\00"
@.str.4 = [9 x i8] c"$k$k$kk$\00"
@.str.5 = [9 x i8] c"$kk$$k$k\00"
@.str.6 = [4 x i8] c"$k+\00"
define i32 @createSartanoString(i8* %0, i8* nocapture %1, i8* %2) {
store i8 0, i8* %2
%4 = tail call i32 @atoi(i8* %1)
%5 = tail call i32 @strlen(i8* %0)
%6 = icmp ne i32 %5, 10
%7 = icmp slt i32 %4, 0
%8 = select i1 %6, i1 true, i1 %7
%9 = icmp sgt i32 %4, 1
%10 = select i1 %8, i1 true, i1 %9
br i1 %10, label %66, label %11
11: ; preds = %3
%12 = tail call i32 @strcat(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%13 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%14 = icmp eq i64 %13, 0
%15 = select i1 %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0)
%16 = tail call i32 @strcat(i8* %2, i8* %15)
%17 = getelementptr inbounds i8, i8* %0, i64 1
%18 = tail call i64 @strncmp(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%19 = icmp eq i64 %18, 0
%20 = select i1 %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0)
%21 = tail call i32 @strcat(i8* %2, i8* %20)
%22 = getelementptr inbounds i8, i8* %0, i64 2
%23 = tail call i64 @strncmp(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%24 = icmp eq i64 %23, 0
%25 = select i1 %24, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0)
%26 = tail call i32 @strcat(i8* %2, i8* %25)
%27 = getelementptr inbounds i8, i8* %0, i64 3
%28 = tail call i64 @strncmp(i8* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%29 = icmp eq i64 %28, 0
%30 = select i1 %29, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0)
%31 = tail call i32 @strcat(i8* %2, i8* %30)
%32 = getelementptr inbounds i8, i8* %0, i64 4
%33 = tail call i64 @strncmp(i8* %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%34 = icmp eq i64 %33, 0
%35 = select i1 %34, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0)
%36 = tail call i32 @strcat(i8* %2, i8* %35)
%37 = getelementptr inbounds i8, i8* %0, i64 5
%38 = tail call i64 @strncmp(i8* %37, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%39 = icmp eq i64 %38, 0
%40 = select i1 %39, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0)
%41 = tail call i32 @strcat(i8* %2, i8* %40)
%42 = getelementptr inbounds i8, i8* %0, i64 6
%43 = tail call i64 @strncmp(i8* %42, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%44 = icmp eq i64 %43, 0
%45 = select i1 %44, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0)
%46 = tail call i32 @strcat(i8* %2, i8* %45)
%47 = getelementptr inbounds i8, i8* %0, i64 7
%48 = tail call i64 @strncmp(i8* %47, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%49 = icmp eq i64 %48, 0
%50 = select i1 %49, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0)
%51 = tail call i32 @strcat(i8* %2, i8* %50)
%52 = getelementptr inbounds i8, i8* %0, i64 8
%53 = tail call i64 @strncmp(i8* %52, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%54 = icmp eq i64 %53, 0
%55 = select i1 %54, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0)
%56 = tail call i32 @strcat(i8* %2, i8* %55)
%57 = getelementptr inbounds i8, i8* %0, i64 9
%58 = tail call i64 @strncmp(i8* %57, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%59 = icmp eq i64 %58, 0
%60 = select i1 %59, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0)
%61 = tail call i32 @strcat(i8* %2, i8* %60)
%62 = icmp sgt i32 %4, 0
%63 = select i1 %62, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0)
%64 = tail call i32 @strcat(i8* %2, i8* %63)
%65 = tail call i32 @strcat(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
br label %66
66: ; preds = %3, %11
%67 = tail call i32 @strlen(i8* %2)
ret i32 %67
}