#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*/ perror(char *);
int sendBinary(char *, int);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int sendConnect(char *login, char *password) {
  int length;
  char msg[64 + 1];
  strcpy(msg, "CONNECT");
  length = strlen("CONNECT");
  msg[length++] = ' ';
  strncpy(&msg[length], login, 27);
  length += (strlen(login) < 27) ? strlen(login) : 27;
  msg[length++] = ';';
  strncpy(&msg[length], password, 26);
  length += (strlen(password) < 26) ? strlen(password) : 26;
  msg[length++] = ';';
  msg[length++] = '\n';
  msg[length] = '\0';
  if (sendBinary(msg, length) == -1) {
    perror("sendGet error.");
    return -20;
  }
  return -10;
}


x86 assembly (clang, -O0):
<sendConnect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xe95(%rip),%rsi
call   1040 <strcpy@plt>
lea    0xe89(%rip),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x1c(%rbp)
cltq
movb   $0x20,-0x60(%rbp,%rax,1)
movslq -0x1c(%rbp),%rax
lea    -0x60(%rbp),%rdi
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
mov    $0x1b,%edx
call   1030 <strncpy@plt>
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x1b,%eax
jge    11cd <sendConnect+0x7d>
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x64(%rbp)
jmp    11da <sendConnect+0x8a>
mov    $0x1b,%eax
mov    %eax,-0x64(%rbp)
jmp    11da <sendConnect+0x8a>
mov    -0x64(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x1c(%rbp)
cltq
movb   $0x3b,-0x60(%rbp,%rax,1)
movslq -0x1c(%rbp),%rax
lea    -0x60(%rbp),%rdi
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
mov    $0x1a,%edx
call   1030 <strncpy@plt>
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x1a,%eax
jge    1231 <sendConnect+0xe1>
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x68(%rbp)
jmp    123e <sendConnect+0xee>
mov    $0x1a,%eax
mov    %eax,-0x68(%rbp)
jmp    123e <sendConnect+0xee>
mov    -0x68(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x1c(%rbp)
cltq
movb   $0x3b,-0x60(%rbp,%rax,1)
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x1c(%rbp)
cltq
movb   $0xa,-0x60(%rbp,%rax,1)
movslq -0x1c(%rbp),%rax
movb   $0x0,-0x60(%rbp,%rax,1)
lea    -0x60(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1070 <sendBinary@plt>
cmp    $0xffffffff,%eax
jne    12a1 <sendConnect+0x151>
lea    0xd78(%rip),%rdi
call   1060 <perror@plt>
movl   $0xffffffec,-0x4(%rbp)
jmp    12a8 <sendConnect+0x158>
movl   $0xfffffff6,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sendConnect>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x50,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xe97(%rip),%rbx
mov    %rsp,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebx
cltq
add    $0x1,%ebx
movb   $0x20,(%rsp,%rax,1)
lea    (%rsp,%rax,1),%rdi
add    $0x1,%rdi
mov    $0x1b,%r12d
mov    %r15,%rsi
mov    $0x1b,%edx
call   1030 <strncpy@plt>
mov    %r15,%rdi
call   1050 <strlen@plt>
cmp    $0x1a,%eax
jg     11ba <sendConnect+0x6a>
mov    %r15,%rdi
call   1050 <strlen@plt>
mov    %eax,%r12d
lea    (%r12,%rbx,1),%eax
lea    (%r12,%rbx,1),%ebp
add    $0x1,%ebp
cltq
movb   $0x3b,(%rsp,%rax,1)
lea    0x1(%rsp,%rax,1),%rdi
mov    $0x1a,%ebx
mov    %r14,%rsi
mov    $0x1a,%edx
call   1030 <strncpy@plt>
mov    %r14,%rdi
call   1050 <strlen@plt>
cmp    $0x19,%eax
jg     11f9 <sendConnect+0xa9>
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebx
add    %ebp,%ebx
movslq %ebx,%rsi
movw   $0xa3b,(%rsp,%rsi,1)
movb   $0x0,0x2(%rsp,%rsi,1)
add    $0x2,%rsi
mov    %rsp,%rdi
call   1070 <sendBinary@plt>
mov    %eax,%ecx
mov    $0xfffffff6,%eax
cmp    $0xffffffff,%ecx
je     122e <sendConnect+0xde>
add    $0x50,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdd3(%rip),%rdi
call   1060 <perror@plt>
mov    $0xffffffec,%eax
jmp    1221 <sendConnect+0xd1>

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

LLVM IR (-O2):
@.str = [8 x i8] c"CONNECT\00"
@.str.1 = [15 x i8] c"sendGet error.\00"
define i32 @sendConnect(i8* %0, i8* %1) {
%3 = alloca [65 x i8]
%4 = getelementptr inbounds [65 x i8], [65 x i8]* %3, i64 0, i64 0
%5 = call i32 @strcpy(i8* %4, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @strlen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%7 = add nsw i32 %6, 1
%8 = sext i32 %6 to i64
%9 = getelementptr inbounds [65 x i8], [65 x i8]* %3, i64 0, i64 %8
store i8 32, i8* %9
%10 = sext i32 %7 to i64
%11 = getelementptr inbounds [65 x i8], [65 x i8]* %3, i64 0, i64 %10
%12 = call i32 @strncpy(i8* %11, i8* %0, i32 27)
%13 = call i32 @strlen(i8* %0)
%14 = icmp slt i32 %13, 27
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = call i32 @strlen(i8* %0)
br label %17
17: ; preds = %2, %15
%18 = phi i32 [ %16, %15 ], [ 27, %2 ]
%19 = add nsw i32 %18, %7
%20 = add nsw i32 %19, 1
%21 = sext i32 %19 to i64
%22 = getelementptr inbounds [65 x i8], [65 x i8]* %3, i64 0, i64 %21
store i8 59, i8* %22
%23 = sext i32 %20 to i64
%24 = getelementptr inbounds [65 x i8], [65 x i8]* %3, i64 0, i64 %23
%25 = call i32 @strncpy(i8* %24, i8* %1, i32 26)
%26 = call i32 @strlen(i8* %1)
%27 = icmp slt i32 %26, 26
br i1 %27, label %28, label %30
28: ; preds = %17
%29 = call i32 @strlen(i8* %1)
br label %30
30: ; preds = %17, %28
%31 = phi i32 [ %29, %28 ], [ 26, %17 ]
%32 = add nsw i32 %31, %20
%33 = add nsw i32 %32, 1
%34 = sext i32 %32 to i64
%35 = getelementptr inbounds [65 x i8], [65 x i8]* %3, i64 0, i64 %34
store i8 59, i8* %35
%36 = add nsw i32 %32, 2
%37 = sext i32 %33 to i64
%38 = getelementptr inbounds [65 x i8], [65 x i8]* %3, i64 0, i64 %37
store i8 10, i8* %38
%39 = sext i32 %36 to i64
%40 = getelementptr inbounds [65 x i8], [65 x i8]* %3, i64 0, i64 %39
store i8 0, i8* %40
%41 = call i32 @sendBinary(i8* %4, i32 %36)
%42 = icmp eq i32 %41, -1
br i1 %42, label %43, label %45
43: ; preds = %30
%44 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %45
45: ; preds = %30, %43
%46 = phi i32 [ -20, %43 ], [ -10, %30 ]
ret i32 %46
}