#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 *malloc(int);
int /*<<< orphan*/ morse_put(char *, char const, char *, char *);
char *morse_str(char const);
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char const *);
char *morse_encode(char *_signal, const char *message, int unit_len,
                   int pad_len) {
  char *signal = _signal;
  char *dot, *tier, *dt_separ, *sym_separ, *word_separ;
  dot = malloc(unit_len + 1);
  tier = malloc(unit_len * 3 + 1);
  dt_separ = malloc(unit_len + 1);
  sym_separ = malloc(unit_len * 3 + 1);
  word_separ = malloc(unit_len * 7 + 1);
  signal[0] = '\0';
  dot[0] = '\0';
  tier[0] = '\0';
  dt_separ[0] = '\0';
  sym_separ[0] = '\0';
  word_separ[0] = '\0';
  for (int i = 0; i < unit_len; i++)
    strcat(dot, "1");
  for (int i = 0; i < 3; i++)
    strcat(tier, dot);
  for (int i = 0; i < unit_len; i++)
    strcat(dt_separ, "0");
  for (int i = 0; i < 3; i++)
    strcat(sym_separ, dt_separ);
  for (int i = 0; i < 7; i++)
    strcat(word_separ, dt_separ);
  for (int i = 0; i < pad_len; i++)
    strcat(signal, "0");
  for (size_t i = 0; i < strlen(message); i++) {
    if (message[i] == ' ') {
      strcat(signal, word_separ);
      continue;
    }
    const char *mr = morse_str(message[i]);
    size_t j;
    for (j = 0; j < strlen(mr) - 1; j++) {
      morse_put(signal, mr[j], dot, tier);
      strcat(signal, dt_separ);
    }
    morse_put(signal, mr[j], dot, tier);
    if (message[i + 1] != ' ' && message[i + 1] != '\0')
      strcat(signal, sym_separ);
  }
  for (int i = 0; i < pad_len; i++)
    strcat(signal, "0");
  free(dot);
  free(tier);
  free(dt_separ);
  free(sym_separ);
  free(word_separ);
  return signal;
}


x86 assembly (clang, -O0):
<morse_encode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
add    $0x1,%edi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
imul   $0x3,-0x14(%rbp),%edi
add    $0x1,%edi
call   1060 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x14(%rbp),%edi
add    $0x1,%edi
call   1060 <malloc@plt>
mov    %rax,-0x38(%rbp)
imul   $0x3,-0x14(%rbp),%edi
add    $0x1,%edi
call   1060 <malloc@plt>
mov    %rax,-0x40(%rbp)
imul   $0x7,-0x14(%rbp),%edi
add    $0x1,%edi
call   1060 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x38(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x40(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x48(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    122a <morse_encode+0xca>
mov    -0x28(%rbp),%rdi
lea    0xde9(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    1200 <morse_encode+0xa0>
movl   $0x0,-0x50(%rbp)
cmpl   $0x3,-0x50(%rbp)
jge    1256 <morse_encode+0xf6>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1070 <strcat@plt>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    1231 <morse_encode+0xd1>
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1287 <morse_encode+0x127>
mov    -0x38(%rbp),%rdi
lea    0xd8e(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    125d <morse_encode+0xfd>
movl   $0x0,-0x58(%rbp)
cmpl   $0x3,-0x58(%rbp)
jge    12b3 <morse_encode+0x153>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1070 <strcat@plt>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    128e <morse_encode+0x12e>
movl   $0x0,-0x5c(%rbp)
cmpl   $0x7,-0x5c(%rbp)
jge    12df <morse_encode+0x17f>
mov    -0x48(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1070 <strcat@plt>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    12ba <morse_encode+0x15a>
movl   $0x0,-0x60(%rbp)
mov    -0x60(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1310 <morse_encode+0x1b0>
mov    -0x20(%rbp),%rdi
lea    0xd05(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    12e6 <morse_encode+0x186>
movq   $0x0,-0x68(%rbp)
mov    -0x68(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x88(%rbp),%rax
movslq %ecx,%rcx
cmp    %rcx,%rax
jae    145c <morse_encode+0x2fc>
mov    -0x10(%rbp),%rax
mov    -0x68(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    1368 <morse_encode+0x208>
mov    -0x20(%rbp),%rdi
mov    -0x48(%rbp),%rsi
call   1070 <strcat@plt>
jmp    144b <morse_encode+0x2eb>
mov    -0x10(%rbp),%rax
mov    -0x68(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1050 <morse_str@plt>
mov    %rax,-0x70(%rbp)
movq   $0x0,-0x78(%rbp)
mov    -0x78(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x70(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x90(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
cmp    %rcx,%rax
jae    13ee <morse_encode+0x28e>
mov    -0x20(%rbp),%rdi
mov    -0x70(%rbp),%rax
mov    -0x78(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
movsbl %al,%esi
call   1080 <morse_put@plt>
mov    -0x20(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1070 <strcat@plt>
mov    -0x78(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x78(%rbp)
jmp    1385 <morse_encode+0x225>
mov    -0x20(%rbp),%rdi
mov    -0x70(%rbp),%rax
mov    -0x78(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
movsbl %al,%esi
call   1080 <morse_put@plt>
mov    -0x10(%rbp),%rax
mov    -0x68(%rbp),%rcx
movsbl 0x1(%rax,%rcx,1),%eax
cmp    $0x20,%eax
je     1446 <morse_encode+0x2e6>
mov    -0x10(%rbp),%rax
mov    -0x68(%rbp),%rcx
movsbl 0x1(%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1446 <morse_encode+0x2e6>
mov    -0x20(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   1070 <strcat@plt>
jmp    144b <morse_encode+0x2eb>
mov    -0x68(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x68(%rbp)
jmp    1318 <morse_encode+0x1b8>
movl   $0x0,-0x7c(%rbp)
mov    -0x7c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    148d <morse_encode+0x32d>
mov    -0x20(%rbp),%rdi
lea    0xb88(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
jmp    1463 <morse_encode+0x303>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<morse_encode>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %ecx,0xc(%rsp)
mov    %edx,%r13d
mov    %rsi,0x30(%rsp)
mov    %rdi,%r15
lea    0x1(%r13),%r12d
mov    %r12d,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0x1(%r13,%r13,2),%ebp
mov    %ebp,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
mov    %r12d,%edi
mov    %rbx,%r12
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    %ebp,%edi
call   1060 <malloc@plt>
mov    %rax,%rbp
lea    0x0(,%r13,8),%edi
sub    %r13d,%edi
add    $0x1,%edi
call   1060 <malloc@plt>
movb   $0x0,(%r15)
movb   $0x0,(%r12)
movb   $0x0,(%r14)
mov    %rbx,0x10(%rsp)
movb   $0x0,(%rbx)
mov    %rbp,0x20(%rsp)
movb   $0x0,0x0(%rbp)
mov    %rax,0x38(%rsp)
movb   $0x0,(%rax)
test   %r13d,%r13d
mov    %r14,0x18(%rsp)
mov    %r12,0x28(%rsp)
jle    1273 <morse_encode+0x113>
lea    0xdfe(%rip),%r14
mov    %r13d,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r12,%rdi
mov    %r14,%rsi
call   1070 <strcat@plt>
add    $0xffffffff,%ebx
jne    1210 <morse_encode+0xb0>
mov    0x18(%rsp),%rbx
mov    %rbx,%rdi
mov    %r12,%rsi
call   1070 <strcat@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1070 <strcat@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1070 <strcat@plt>
test   %r13d,%r13d
mov    0x10(%rsp),%rbx
mov    0x30(%rsp),%r12
jle    129e <morse_encode+0x13e>
lea    0xda6(%rip),%rbp
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1070 <strcat@plt>
add    $0xffffffff,%r13d
jne    1260 <morse_encode+0x100>
jmp    129e <morse_encode+0x13e>
mov    %r14,%rdi
mov    %r12,%rsi
call   1070 <strcat@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1070 <strcat@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1070 <strcat@plt>
mov    0x10(%rsp),%rbx
mov    0x30(%rsp),%r12
mov    0x20(%rsp),%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1070 <strcat@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1070 <strcat@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1070 <strcat@plt>
mov    0x38(%rsp),%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1070 <strcat@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1070 <strcat@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1070 <strcat@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1070 <strcat@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1070 <strcat@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1070 <strcat@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1070 <strcat@plt>
mov    0xc(%rsp),%ebx
test   %ebx,%ebx
jle    1340 <morse_encode+0x1e0>
lea    0xcdd(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r15,%rdi
mov    %rbp,%rsi
call   1070 <strcat@plt>
add    $0xffffffff,%ebx
jne    1330 <morse_encode+0x1d0>
mov    %r12,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
je     145d <morse_encode+0x2fd>
xor    %ebx,%ebx
jmp    138a <morse_encode+0x22a>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
mov    0x38(%rsp),%rsi
call   1070 <strcat@plt>
add    $0x1,%rbx
mov    %rbx,%r14
mov    %r12,%rdi
call   1040 <strlen@plt>
cltq
mov    %r14,%rbx
cmp    %rax,%r14
jae    145d <morse_encode+0x2fd>
mov    (%r12,%rbx,1),%al
cmp    $0x20,%al
je     1360 <morse_encode+0x200>
movsbl %al,%edi
call   1050 <morse_str@plt>
mov    %rax,%rbp
mov    %rax,%rdi
call   1040 <strlen@plt>
cmp    $0x1,%eax
mov    %rbx,0x40(%rsp)
jne    13c0 <morse_encode+0x260>
xor    %ebx,%ebx
mov    0x18(%rsp),%r12
mov    0x28(%rsp),%r13
jmp    1414 <morse_encode+0x2b4>
nopl   (%rax)
xor    %ebx,%ebx
mov    0x18(%rsp),%r12
mov    0x28(%rsp),%r13
mov    0x10(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl 0x0(%rbp,%rbx,1),%esi
mov    %r15,%rdi
mov    %r13,%rdx
mov    %r12,%rcx
call   1080 <morse_put@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1070 <strcat@plt>
add    $0x1,%rbx
mov    %rbp,%rdi
call   1040 <strlen@plt>
add    $0xffffffff,%eax
cltq
cmp    %rax,%rbx
jb     13e0 <morse_encode+0x280>
movsbl 0x0(%rbp,%rbx,1),%esi
mov    %r15,%rbp
mov    %r15,%rdi
mov    %r13,%rdx
mov    %r12,%rcx
call   1080 <morse_put@plt>
mov    0x40(%rsp),%rax
lea    0x1(%rax),%r14
mov    0x30(%rsp),%r12
testb  $0xdf,0x1(%r12,%rax,1)
jne    1448 <morse_encode+0x2e8>
mov    %rbp,%r15
jmp    1374 <morse_encode+0x214>
mov    %rbp,%r15
mov    %rbp,%rdi
mov    0x20(%rsp),%rsi
call   1070 <strcat@plt>
jmp    1374 <morse_encode+0x214>
mov    0xc(%rsp),%ebx
test   %ebx,%ebx
jle    1480 <morse_encode+0x320>
lea    0xb96(%rip),%rbp
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %rbp,%rsi
call   1070 <strcat@plt>
add    $0xffffffff,%ebx
jne    1470 <morse_encode+0x310>
mov    0x28(%rsp),%rdi
call   1030 <free@plt>
mov    0x18(%rsp),%rdi
call   1030 <free@plt>
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
mov    0x20(%rsp),%rdi
call   1030 <free@plt>
mov    0x38(%rsp),%rdi
call   1030 <free@plt>
mov    %r15,%rax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"1\00"
@.str.1 = [2 x i8] c"0\00"
define i8* @morse_encode(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i64
%22 = alloca i8*
%23 = alloca i64
%24 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%25 = load i8*, i8** %5
store i8* %25, i8** %9
%26 = load i32, i32* %7
%27 = add nsw i32 %26, 1
%28 = call i8* @malloc(i32 %27)
store i8* %28, i8** %10
%29 = load i32, i32* %7
%30 = mul nsw i32 %29, 3
%31 = add nsw i32 %30, 1
%32 = call i8* @malloc(i32 %31)
store i8* %32, i8** %11
%33 = load i32, i32* %7
%34 = add nsw i32 %33, 1
%35 = call i8* @malloc(i32 %34)
store i8* %35, i8** %12
%36 = load i32, i32* %7
%37 = mul nsw i32 %36, 3
%38 = add nsw i32 %37, 1
%39 = call i8* @malloc(i32 %38)
store i8* %39, i8** %13
%40 = load i32, i32* %7
%41 = mul nsw i32 %40, 7
%42 = add nsw i32 %41, 1
%43 = call i8* @malloc(i32 %42)
store i8* %43, i8** %14
%44 = load i8*, i8** %9
%45 = getelementptr inbounds i8, i8* %44, i64 0
store i8 0, i8* %45
%46 = load i8*, i8** %10
%47 = getelementptr inbounds i8, i8* %46, i64 0
store i8 0, i8* %47
%48 = load i8*, i8** %11
%49 = getelementptr inbounds i8, i8* %48, i64 0
store i8 0, i8* %49
%50 = load i8*, i8** %12
%51 = getelementptr inbounds i8, i8* %50, i64 0
store i8 0, i8* %51
%52 = load i8*, i8** %13
%53 = getelementptr inbounds i8, i8* %52, i64 0
store i8 0, i8* %53
%54 = load i8*, i8** %14
%55 = getelementptr inbounds i8, i8* %54, i64 0
store i8 0, i8* %55
store i32 0, i32* %15
br label %56
56: ; preds = %63, %4
%57 = load i32, i32* %15
%58 = load i32, i32* %7
%59 = icmp slt i32 %57, %58
br i1 %59, label %60, label %66
60: ; preds = %56
%61 = load i8*, i8** %10
%62 = call i32 @strcat(i8* %61, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %63
63: ; preds = %60
%64 = load i32, i32* %15
%65 = add nsw i32 %64, 1
store i32 %65, i32* %15
br label %56
66: ; preds = %56
store i32 0, i32* %16
br label %67
67: ; preds = %74, %66
%68 = load i32, i32* %16
%69 = icmp slt i32 %68, 3
br i1 %69, label %70, label %77
70: ; preds = %67
%71 = load i8*, i8** %11
%72 = load i8*, i8** %10
%73 = call i32 @strcat(i8* %71, i8* %72)
br label %74
74: ; preds = %70
%75 = load i32, i32* %16
%76 = add nsw i32 %75, 1
store i32 %76, i32* %16
br label %67
77: ; preds = %67
store i32 0, i32* %17
br label %78
78: ; preds = %85, %77
%79 = load i32, i32* %17
%80 = load i32, i32* %7
%81 = icmp slt i32 %79, %80
br i1 %81, label %82, label %88
82: ; preds = %78
%83 = load i8*, i8** %12
%84 = call i32 @strcat(i8* %83, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %85
85: ; preds = %82
%86 = load i32, i32* %17
%87 = add nsw i32 %86, 1
store i32 %87, i32* %17
br label %78
88: ; preds = %78
store i32 0, i32* %18
br label %89
89: ; preds = %96, %88
%90 = load i32, i32* %18
%91 = icmp slt i32 %90, 3
br i1 %91, label %92, label %99
92: ; preds = %89
%93 = load i8*, i8** %13
%94 = load i8*, i8** %12
%95 = call i32 @strcat(i8* %93, i8* %94)
br label %96
96: ; preds = %92
%97 = load i32, i32* %18
%98 = add nsw i32 %97, 1
store i32 %98, i32* %18
br label %89
99: ; preds = %89
store i32 0, i32* %19
br label %100
100: ; preds = %107, %99
%101 = load i32, i32* %19
%102 = icmp slt i32 %101, 7
br i1 %102, label %103, label %110
103: ; preds = %100
%104 = load i8*, i8** %14
%105 = load i8*, i8** %12
%106 = call i32 @strcat(i8* %104, i8* %105)
br label %107
107: ; preds = %103
%108 = load i32, i32* %19
%109 = add nsw i32 %108, 1
store i32 %109, i32* %19
br label %100
110: ; preds = %100
store i32 0, i32* %20
br label %111
111: ; preds = %118, %110
%112 = load i32, i32* %20
%113 = load i32, i32* %8
%114 = icmp slt i32 %112, %113
br i1 %114, label %115, label %121
115: ; preds = %111
%116 = load i8*, i8** %9
%117 = call i32 @strcat(i8* %116, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %118
118: ; preds = %115
%119 = load i32, i32* %20
%120 = add nsw i32 %119, 1
store i32 %120, i32* %20
br label %111
121: ; preds = %111
store i64 0, i64* %21
br label %122
122: ; preds = %196, %121
%123 = load i64, i64* %21
%124 = load i8*, i8** %6
%125 = call i32 @strlen(i8* %124)
%126 = sext i32 %125 to i64
%127 = icmp ult i64 %123, %126
br i1 %127, label %128, label %199
128: ; preds = %122
%129 = load i8*, i8** %6
%130 = load i64, i64* %21
%131 = getelementptr inbounds i8, i8* %129, i64 %130
%132 = load i8, i8* %131
%133 = sext i8 %132 to i32
%134 = icmp eq i32 %133, 32
br i1 %134, label %135, label %139
135: ; preds = %128
%136 = load i8*, i8** %9
%137 = load i8*, i8** %14
%138 = call i32 @strcat(i8* %136, i8* %137)
br label %196
139: ; preds = %128
%140 = load i8*, i8** %6
%141 = load i64, i64* %21
%142 = getelementptr inbounds i8, i8* %140, i64 %141
%143 = load i8, i8* %142
%144 = call i8* @morse_str(i8 signext %143)
store i8* %144, i8** %22
store i64 0, i64* %23
br label %145
145: ; preds = %164, %139
%146 = load i64, i64* %23
%147 = load i8*, i8** %22
%148 = call i32 @strlen(i8* %147)
%149 = sub nsw i32 %148, 1
%150 = sext i32 %149 to i64
%151 = icmp ult i64 %146, %150
br i1 %151, label %152, label %167
152: ; preds = %145
%153 = load i8*, i8** %9
%154 = load i8*, i8** %22
%155 = load i64, i64* %23
%156 = getelementptr inbounds i8, i8* %154, i64 %155
%157 = load i8, i8* %156
%158 = load i8*, i8** %10
%159 = load i8*, i8** %11
%160 = call i32 @morse_put(i8* %153, i8 signext %157, i8* %158, i8* %159)
%161 = load i8*, i8** %9
%162 = load i8*, i8** %12
%163 = call i32 @strcat(i8* %161, i8* %162)
br label %164
164: ; preds = %152
%165 = load i64, i64* %23
%166 = add i64 %165, 1
store i64 %166, i64* %23
br label %145
167: ; preds = %145
%168 = load i8*, i8** %9
%169 = load i8*, i8** %22
%170 = load i64, i64* %23
%171 = getelementptr inbounds i8, i8* %169, i64 %170
%172 = load i8, i8* %171
%173 = load i8*, i8** %10
%174 = load i8*, i8** %11
%175 = call i32 @morse_put(i8* %168, i8 signext %172, i8* %173, i8* %174)
%176 = load i8*, i8** %6
%177 = load i64, i64* %21
%178 = add i64 %177, 1
%179 = getelementptr inbounds i8, i8* %176, i64 %178
%180 = load i8, i8* %179
%181 = sext i8 %180 to i32
%182 = icmp ne i32 %181, 32
br i1 %182, label %183, label %195
183: ; preds = %167
%184 = load i8*, i8** %6
%185 = load i64, i64* %21
%186 = add i64 %185, 1
%187 = getelementptr inbounds i8, i8* %184, i64 %186
%188 = load i8, i8* %187
%189 = sext i8 %188 to i32
%190 = icmp ne i32 %189, 0
br i1 %190, label %191, label %195
191: ; preds = %183
%192 = load i8*, i8** %9
%193 = load i8*, i8** %13
%194 = call i32 @strcat(i8* %192, i8* %193)
br label %195
195: ; preds = %191, %183, %167
br label %196
196: ; preds = %195, %135
%197 = load i64, i64* %21
%198 = add i64 %197, 1
store i64 %198, i64* %21
br label %122
199: ; preds = %122
store i32 0, i32* %24
br label %200
200: ; preds = %207, %199
%201 = load i32, i32* %24
%202 = load i32, i32* %8
%203 = icmp slt i32 %201, %202
br i1 %203, label %204, label %210
204: ; preds = %200
%205 = load i8*, i8** %9
%206 = call i32 @strcat(i8* %205, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %207
207: ; preds = %204
%208 = load i32, i32* %24
%209 = add nsw i32 %208, 1
store i32 %209, i32* %24
br label %200
210: ; preds = %200
%211 = load i8*, i8** %10
%212 = call i32 @free(i8* %211)
%213 = load i8*, i8** %11
%214 = call i32 @free(i8* %213)
%215 = load i8*, i8** %12
%216 = call i32 @free(i8* %215)
%217 = load i8*, i8** %13
%218 = call i32 @free(i8* %217)
%219 = load i8*, i8** %14
%220 = call i32 @free(i8* %219)
%221 = load i8*, i8** %9
ret i8* %221
}

LLVM IR (-O2):
@.str = [2 x i8] c"1\00"
@.str.1 = [2 x i8] c"0\00"
define i8* @morse_encode(i8* returned %0, i8* %1, i32 %2, i32 %3) {
%5 = add nsw i32 %2, 1
%6 = tail call i8* @malloc(i32 %5)
%7 = mul nsw i32 %2, 3
%8 = add nsw i32 %7, 1
%9 = tail call i8* @malloc(i32 %8)
%10 = tail call i8* @malloc(i32 %5)
%11 = tail call i8* @malloc(i32 %8)
%12 = mul nsw i32 %2, 7
%13 = add nsw i32 %12, 1
%14 = tail call i8* @malloc(i32 %13)
store i8 0, i8* %0
store i8 0, i8* %6
store i8 0, i8* %9
store i8 0, i8* %10
store i8 0, i8* %11
store i8 0, i8* %14
%15 = icmp sgt i32 %2, 0
br i1 %15, label %20, label %25
16: ; preds = %20
%17 = tail call i32 @strcat(i8* %9, i8* %6)
%18 = tail call i32 @strcat(i8* %9, i8* %6)
%19 = tail call i32 @strcat(i8* %9, i8* %6)
br i1 %15, label %41, label %29
20: ; preds = %4, %20
%21 = phi i32 [ %23, %20 ], [ 0, %4 ]
%22 = tail call i32 @strcat(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%23 = add nuw nsw i32 %21, 1
%24 = icmp eq i32 %23, %2
br i1 %24, label %16, label %20
25: ; preds = %4
%26 = tail call i32 @strcat(i8* %9, i8* %6)
%27 = tail call i32 @strcat(i8* %9, i8* %6)
%28 = tail call i32 @strcat(i8* %9, i8* %6)
br label %29
29: ; preds = %41, %25, %16
%30 = tail call i32 @strcat(i8* %11, i8* %10)
%31 = tail call i32 @strcat(i8* %11, i8* %10)
%32 = tail call i32 @strcat(i8* %11, i8* %10)
%33 = tail call i32 @strcat(i8* %14, i8* %10)
%34 = tail call i32 @strcat(i8* %14, i8* %10)
%35 = tail call i32 @strcat(i8* %14, i8* %10)
%36 = tail call i32 @strcat(i8* %14, i8* %10)
%37 = tail call i32 @strcat(i8* %14, i8* %10)
%38 = tail call i32 @strcat(i8* %14, i8* %10)
%39 = tail call i32 @strcat(i8* %14, i8* %10)
%40 = icmp sgt i32 %3, 0
br i1 %40, label %49, label %46
41: ; preds = %16, %41
%42 = phi i32 [ %44, %41 ], [ 0, %16 ]
%43 = tail call i32 @strcat(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%44 = add nuw nsw i32 %42, 1
%45 = icmp eq i32 %44, %2
br i1 %45, label %29, label %41
46: ; preds = %49, %29
%47 = tail call i32 @strlen(i8* %1)
%48 = icmp eq i32 %47, 0
br i1 %48, label %54, label %55
49: ; preds = %29, %49
%50 = phi i32 [ %52, %49 ], [ 0, %29 ]
%51 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%52 = add nuw nsw i32 %50, 1
%53 = icmp eq i32 %52, %3
br i1 %53, label %46, label %49
54: ; preds = %88, %46
br i1 %40, label %99, label %93
55: ; preds = %46, %88
%56 = phi i64 [ %89, %88 ], [ 0, %46 ]
%57 = getelementptr inbounds i8, i8* %1, i64 %56
%58 = load i8, i8* %57
%59 = icmp eq i8 %58, 32
br i1 %59, label %60, label %63
60: ; preds = %55
%61 = tail call i32 @strcat(i8* %0, i8* %14)
%62 = add nuw i64 %56, 1
br label %88
63: ; preds = %55
%64 = tail call i8* @morse_str(i8 signext %58)
%65 = tail call i32 @strlen(i8* %64)
%66 = icmp eq i32 %65, 1
br i1 %66, label %78, label %67
67: ; preds = %63, %67
%68 = phi i64 [ %73, %67 ], [ 0, %63 ]
%69 = getelementptr inbounds i8, i8* %64, i64 %68
%70 = load i8, i8* %69
%71 = tail call i32 @morse_put(i8* %0, i8 signext %70, i8* %6, i8* %9)
%72 = tail call i32 @strcat(i8* %0, i8* %10)
%73 = add nuw i64 %68, 1
%74 = tail call i32 @strlen(i8* %64)
%75 = add nsw i32 %74, -1
%76 = sext i32 %75 to i64
%77 = icmp ult i64 %73, %76
br i1 %77, label %67, label %78
78: ; preds = %67, %63
%79 = phi i64 [ 0, %63 ], [ %73, %67 ]
%80 = getelementptr inbounds i8, i8* %64, i64 %79
%81 = load i8, i8* %80
%82 = tail call i32 @morse_put(i8* %0, i8 signext %81, i8* %6, i8* %9)
%83 = add nuw i64 %56, 1
%84 = getelementptr inbounds i8, i8* %1, i64 %83
%85 = load i8, i8* %84
switch i8 %85, label %86 [
i8 32, label %88
i8 0, label %88
]
86: ; preds = %78
%87 = tail call i32 @strcat(i8* %0, i8* %11)
br label %88
88: ; preds = %86, %78, %78, %60
%89 = phi i64 [ %83, %86 ], [ %83, %78 ], [ %83, %78 ], [ %62, %60 ]
%90 = tail call i32 @strlen(i8* %1)
%91 = sext i32 %90 to i64
%92 = icmp ult i64 %89, %91
br i1 %92, label %55, label %54
93: ; preds = %99, %54
%94 = tail call i32 @free(i8* %6)
%95 = tail call i32 @free(i8* %9)
%96 = tail call i32 @free(i8* %10)
%97 = tail call i32 @free(i8* %11)
%98 = tail call i32 @free(i8* %14)
ret i8* %0
99: ; preds = %54, %99
%100 = phi i32 [ %102, %99 ], [ 0, %54 ]
%101 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%102 = add nuw nsw i32 %100, 1
%103 = icmp eq i32 %102, %3
br i1 %103, label %93, label %99
}