#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 *malloc(size_t);
int send_bytes(int, char *, size_t);
int /*<<< orphan*/ strcpy(char *, char const *);
scalar_t__ strlen(char const *);
int send_user_list_reply(int fd, const char *names[], size_t len) {
  char *msg = 0;
  size_t mlen = 2;
  size_t i = 0;
  size_t offset = 0;
  for (; i < len; ++i) {
    mlen += strlen(names[i]) + 1;
  }
  msg = malloc(mlen * sizeof(char));
  strcpy(msg, "7.");
  offset = 2;
  for (i = 0; i < len; ++i) {
    strcpy(msg + offset, names[i]);
    offset += strlen(names[i]);
    if (i < (len - 1)) {
      msg[offset] = '.';
      ++offset;
    }
  }
  return send_bytes(fd, msg, mlen);
}


x86 assembly (clang, -O0):
<send_user_list_reply>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x2,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11af <send_user_list_reply+0x6f>
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <strlen@plt>
add    $0x1,%rax
add    -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1173 <send_user_list_reply+0x33>
mov    -0x28(%rbp),%rdi
shl    $0x0,%rdi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe35(%rip),%rsi
call   1030 <strcpy@plt>
movq   $0x2,-0x38(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1263 <send_user_list_reply+0x123>
mov    -0x20(%rbp),%rdi
add    -0x38(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <strlen@plt>
add    -0x38(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    $0x1,%rcx
cmp    %rcx,%rax
jae    124d <send_user_list_reply+0x10d>
mov    -0x20(%rbp),%rax
mov    -0x38(%rbp),%rcx
movb   $0x2e,(%rax,%rcx,1)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    1252 <send_user_list_reply+0x112>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    11e0 <send_user_list_reply+0xa0>
mov    -0x4(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1060 <send_bytes@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_user_list_reply>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r15
mov    %edi,0xc(%rsp)
mov    %rdx,%r14
mov    $0x2,%ebx
test   %rdx,%rdx
je     1189 <send_user_list_reply+0x49>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r15,%rbp,8),%rdi
call   1040 <strlen@plt>
add    %rax,%rbx
add    $0x1,%rbx
add    $0x1,%rbp
cmp    %rbp,%r14
jne    1170 <send_user_list_reply+0x30>
mov    %rbx,%rdi
call   1050 <malloc@plt>
mov    %rax,%r12
lea    0xe65(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
test   %r14,%r14
je     11f7 <send_user_list_reply+0xb7>
mov    %r14,%rbp
lea    -0x1(%r14),%rax
mov    %rax,0x10(%rsp)
mov    $0x2,%r13d
xor    %r14d,%r14d
jmp    11cc <send_user_list_reply+0x8c>
nop
add    $0x1,%r14
mov    %rax,%r13
cmp    %r14,%rbp
je     11f7 <send_user_list_reply+0xb7>
lea    (%r12,%r13,1),%rdi
mov    (%r15,%r14,8),%rsi
call   1030 <strcpy@plt>
mov    (%r15,%r14,8),%rdi
call   1040 <strlen@plt>
add    %r13,%rax
cmp    0x10(%rsp),%r14
jae    11c0 <send_user_list_reply+0x80>
movb   $0x2e,(%r12,%rax,1)
add    $0x1,%rax
jmp    11c0 <send_user_list_reply+0x80>
mov    0xc(%rsp),%edi
mov    %r12,%rsi
mov    %rbx,%rdx
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <send_bytes@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"7.\00"
define i32 @send_user_list_reply(i32 %0, i8** %1, i64 %2) {
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 %2, i64* %6
store i8* null, i8** %7
store i64 2, i64* %8
store i64 0, i64* %9
store i64 0, i64* %10
br label %11
11: ; preds = %24, %3
%12 = load i64, i64* %9
%13 = load i64, i64* %6
%14 = icmp ult i64 %12, %13
br i1 %14, label %15, label %27
15: ; preds = %11
%16 = load i8**, i8*** %5
%17 = load i64, i64* %9
%18 = getelementptr inbounds i8*, i8** %16, i64 %17
%19 = load i8*, i8** %18
%20 = call i64 @strlen(i8* %19)
%21 = add nsw i64 %20, 1
%22 = load i64, i64* %8
%23 = add i64 %22, %21
store i64 %23, i64* %8
br label %24
24: ; preds = %15
%25 = load i64, i64* %9
%26 = add i64 %25, 1
store i64 %26, i64* %9
br label %11
27: ; preds = %11
%28 = load i64, i64* %8
%29 = mul i64 %28, 1
%30 = call i8* @malloc(i64 %29)
store i8* %30, i8** %7
%31 = load i8*, i8** %7
%32 = call i32 @strcpy(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i64 2, i64* %10
store i64 0, i64* %9
br label %33
33: ; preds = %64, %27
%34 = load i64, i64* %9
%35 = load i64, i64* %6
%36 = icmp ult i64 %34, %35
br i1 %36, label %37, label %67
37: ; preds = %33
%38 = load i8*, i8** %7
%39 = load i64, i64* %10
%40 = getelementptr inbounds i8, i8* %38, i64 %39
%41 = load i8**, i8*** %5
%42 = load i64, i64* %9
%43 = getelementptr inbounds i8*, i8** %41, i64 %42
%44 = load i8*, i8** %43
%45 = call i32 @strcpy(i8* %40, i8* %44)
%46 = load i8**, i8*** %5
%47 = load i64, i64* %9
%48 = getelementptr inbounds i8*, i8** %46, i64 %47
%49 = load i8*, i8** %48
%50 = call i64 @strlen(i8* %49)
%51 = load i64, i64* %10
%52 = add i64 %51, %50
store i64 %52, i64* %10
%53 = load i64, i64* %9
%54 = load i64, i64* %6
%55 = sub i64 %54, 1
%56 = icmp ult i64 %53, %55
br i1 %56, label %57, label %63
57: ; preds = %37
%58 = load i8*, i8** %7
%59 = load i64, i64* %10
%60 = getelementptr inbounds i8, i8* %58, i64 %59
store i8 46, i8* %60
%61 = load i64, i64* %10
%62 = add i64 %61, 1
store i64 %62, i64* %10
br label %63
63: ; preds = %57, %37
br label %64
64: ; preds = %63
%65 = load i64, i64* %9
%66 = add i64 %65, 1
store i64 %66, i64* %9
br label %33
67: ; preds = %33
%68 = load i32, i32* %4
%69 = load i8*, i8** %7
%70 = load i64, i64* %8
%71 = call i32 @send_bytes(i32 %68, i8* %69, i64 %70)
ret i32 %71
}

LLVM IR (-O2):
@.str = [3 x i8] c"7.\00"
define i32 @send_user_list_reply(i32 %0, i8** nocapture %1, i64 %2) {
%4 = icmp eq i64 %2, 0
br i1 %4, label %15, label %5
5: ; preds = %3, %5
%6 = phi i64 [ %13, %5 ], [ 0, %3 ]
%7 = phi i64 [ %12, %5 ], [ 2, %3 ]
%8 = getelementptr inbounds i8*, i8** %1, i64 %6
%9 = load i8*, i8** %8
%10 = tail call i64 @strlen(i8* dereferenceable(1) %9)
%11 = add i64 %7, 1
%12 = add i64 %11, %10
%13 = add nuw i64 %6, 1
%14 = icmp eq i64 %13, %2
br i1 %14, label %15, label %5
15: ; preds = %5, %3
%16 = phi i64 [ 2, %3 ], [ %12, %5 ]
%17 = tail call i8* @malloc(i64 %16)
%18 = tail call i32 @strcpy(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br i1 %4, label %39, label %19
19: ; preds = %15
%20 = add i64 %2, -1
br label %21
21: ; preds = %19, %35
%22 = phi i64 [ 2, %19 ], [ %36, %35 ]
%23 = phi i64 [ 0, %19 ], [ %37, %35 ]
%24 = getelementptr inbounds i8, i8* %17, i64 %22
%25 = getelementptr inbounds i8*, i8** %1, i64 %23
%26 = load i8*, i8** %25
%27 = tail call i32 @strcpy(i8* %24, i8* %26)
%28 = load i8*, i8** %25
%29 = tail call i64 @strlen(i8* dereferenceable(1) %28)
%30 = add i64 %29, %22
%31 = icmp ult i64 %23, %20
br i1 %31, label %32, label %35
32: ; preds = %21
%33 = getelementptr inbounds i8, i8* %17, i64 %30
store i8 46, i8* %33
%34 = add i64 %30, 1
br label %35
35: ; preds = %21, %32
%36 = phi i64 [ %34, %32 ], [ %30, %21 ]
%37 = add nuw i64 %23, 1
%38 = icmp eq i64 %37, %2
br i1 %38, label %39, label %21
39: ; preds = %35, %15
%40 = tail call i32 @send_bytes(i32 %0, i8* %17, i64 %16)
ret i32 %40
}