#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*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void compile_send_string(char *array[], char string[], int length) {
  for (int i = 0; i < length; i++) {
    if (!i)
      strcpy(string, array[i]);
    else {
      strcat(string, ";");
      strcat(string, array[i]);
    }
  }
  strcat(string, ";");
}


x86 assembly (clang, -O0):
<compile_send_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11a2 <compile_send_string+0x82>
cmpl   $0x0,-0x18(%rbp)
jne    116a <compile_send_string+0x4a>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <strcpy@plt>
jmp    118f <compile_send_string+0x6f>
mov    -0x10(%rbp),%rdi
lea    0xe8b(%rip),%rsi
call   1040 <strcat@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1040 <strcat@plt>
jmp    1194 <compile_send_string+0x74>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    113a <compile_send_string+0x1a>
mov    -0x10(%rbp),%rdi
lea    0xe53(%rip),%rsi
call   1040 <strcat@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compile_send_string>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%rbx
test   %edx,%edx
jle    1180 <compile_send_string+0x60>
mov    %edx,%ebp
mov    %rdi,%r14
mov    (%rdi),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
cmp    $0x1,%ebp
je     1180 <compile_send_string+0x60>
mov    %ebp,%r12d
mov    $0x1,%ebp
lea    0xead(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcat@plt>
mov    (%r14,%rbp,8),%rsi
mov    %rbx,%rdi
call   1040 <strcat@plt>
add    $0x1,%rbp
cmp    %rbp,%r12
jne    1160 <compile_send_string+0x40>
lea    0xe79(%rip),%rsi
mov    %rbx,%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <strcat@plt>

LLVM IR (-O0):
@.str = [2 x i8] c";\00"
define void @compile_send_string(i8** %0, i8* %1, i32 %2) {
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i8** %0, i8*** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %8
8: ; preds = %34, %3
%9 = load i32, i32* %7
%10 = load i32, i32* %6
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %37
12: ; preds = %8
%13 = load i32, i32* %7
%14 = icmp ne i32 %13, 0
br i1 %14, label %23, label %15
15: ; preds = %12
%16 = load i8*, i8** %5
%17 = load i8**, i8*** %4
%18 = load i32, i32* %7
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8*, i8** %17, i64 %19
%21 = load i8*, i8** %20
%22 = call i32 @strcpy(i8* %16, i8* %21)
br label %33
23: ; preds = %12
%24 = load i8*, i8** %5
%25 = call i32 @strcat(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%26 = load i8*, i8** %5
%27 = load i8**, i8*** %4
%28 = load i32, i32* %7
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %27, i64 %29
%31 = load i8*, i8** %30
%32 = call i32 @strcat(i8* %26, i8* %31)
br label %33
33: ; preds = %23, %15
br label %34
34: ; preds = %33
%35 = load i32, i32* %7
%36 = add nsw i32 %35, 1
store i32 %36, i32* %7
br label %8
37: ; preds = %8
%38 = load i8*, i8** %5
%39 = call i32 @strcat(i8* %38, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c";\00"
define void @compile_send_string(i8** nocapture %0, i8* %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %10
5: ; preds = %3
%6 = zext i32 %2 to i64
%7 = load i8*, i8** %0
%8 = tail call i32 @strcpy(i8* %1, i8* %7)
%9 = icmp eq i32 %2, 1
br i1 %9, label %10, label %12
10: ; preds = %12, %5, %3
%11 = tail call i32 @strcat(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
ret void
12: ; preds = %5, %12
%13 = phi i64 [ %18, %12 ], [ 1, %5 ]
%14 = tail call i32 @strcat(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%15 = getelementptr inbounds i8*, i8** %0, i64 %13
%16 = load i8*, i8** %15
%17 = tail call i32 @strcat(i8* %1, i8* %16)
%18 = add nuw nsw i64 %13, 1
%19 = icmp eq i64 %18, %6
br i1 %19, label %10, label %12
}