#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*/ close(int);
int open_client_socket(char *, int);
int read(int, char *, int);
int strlen(char *);
int /*<<< orphan*/ write(int, char *, int);
int sendCommand(char *host, int port, char *command, char *user, char *password,
                char *args, char *response) {
  int sock = open_client_socket(host, port);
  write(sock, command, strlen(command));
  write(sock, " ", 1);
  write(sock, user, strlen(user));
  write(sock, " ", 1);
  write(sock, password, strlen(password));
  write(sock, " ", 1);
  write(sock, args, strlen(args));
  write(sock, "\r\n", 2);
  int n = 0;
  int len = 0;
  while ((n = read(sock, response + len, (20 * 1024) - len)) > 0) {
    len += n;
  }
  close(sock);
}


x86 assembly (clang, -O0):
<sendCommand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1070 <open_client_socket@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    %eax,-0x84(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x84(%rbp),%edi
mov    -0x80(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    -0x3c(%rbp),%edi
lea    0xe46(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x74(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x74(%rbp),%edi
mov    -0x70(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    -0x3c(%rbp),%edi
lea    0xe0d(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x64(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x30(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x64(%rbp),%edi
mov    -0x60(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    -0x3c(%rbp),%edi
lea    0xdd4(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x38(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x54(%rbp),%edi
mov    -0x50(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    -0x3c(%rbp),%edi
lea    0xd9d(%rip),%rsi
mov    $0x2,%edx
call   1030 <write@plt>
movl   $0x0,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
mov    -0x3c(%rbp),%edi
mov    0x10(%rbp),%rsi
movslq -0x44(%rbp),%rax
add    %rax,%rsi
mov    $0x5000,%edx
sub    -0x44(%rbp),%edx
call   1060 <read@plt>
mov    %eax,-0x40(%rbp)
cmp    $0x0,%eax
jle    12b2 <sendCommand+0x162>
mov    -0x40(%rbp),%eax
add    -0x44(%rbp),%eax
mov    %eax,-0x44(%rbp)
jmp    127d <sendCommand+0x12d>
mov    -0x3c(%rbp),%edi
call   1050 <close@plt>
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sendCommand>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9,%rbp
mov    %r8,%r15
mov    %rcx,%r12
mov    %rdx,%r13
mov    0x40(%rsp),%r14
call   1070 <open_client_socket@plt>
mov    %eax,%ebx
mov    %r13,%rdi
call   1040 <strlen@plt>
mov    %ebx,%edi
mov    %r13,%rsi
mov    %eax,%edx
call   1030 <write@plt>
lea    0xe72(%rip),%r13
mov    %ebx,%edi
mov    %r13,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    %r12,%rdi
call   1040 <strlen@plt>
mov    %ebx,%edi
mov    %r12,%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    %ebx,%edi
mov    %r13,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %ebx,%edi
mov    %r15,%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    %ebx,%edi
mov    %r13,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1030 <write@plt>
lea    0xe04(%rip),%rsi
mov    %ebx,%edi
mov    $0x2,%edx
call   1030 <write@plt>
xor    %ebp,%ebp
nopl   0x0(%rax)
movslq %ebp,%rbp
lea    (%r14,%rbp,1),%rsi
mov    $0x5000,%edx
sub    %ebp,%edx
mov    %ebx,%edi
call   1060 <read@plt>
add    %eax,%ebp
test   %eax,%eax
jg     1210 <sendCommand+0xc0>
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <close@plt>

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

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
@.str.1 = [3 x i8] c"\0D\0A\00"
define i32 @sendCommand(i8* %0, i32 %1, i8* %2, i8* %3, i8* %4, i8* %5, i8* nocapture %6) {
%8 = tail call i32 @open_client_socket(i8* %0, i32 %1)
%9 = tail call i32 @strlen(i8* %2)
%10 = tail call i32 @write(i32 %8, i8* %2, i32 %9)
%11 = tail call i32 @write(i32 %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%12 = tail call i32 @strlen(i8* %3)
%13 = tail call i32 @write(i32 %8, i8* %3, i32 %12)
%14 = tail call i32 @write(i32 %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%15 = tail call i32 @strlen(i8* %4)
%16 = tail call i32 @write(i32 %8, i8* %4, i32 %15)
%17 = tail call i32 @write(i32 %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%18 = tail call i32 @strlen(i8* %5)
%19 = tail call i32 @write(i32 %8, i8* %5, i32 %18)
%20 = tail call i32 @write(i32 %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
br label %21
21: ; preds = %21, %7
%22 = phi i32 [ 0, %7 ], [ %28, %21 ]
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %6, i64 %23
%25 = sub nsw i32 20480, %22
%26 = tail call i32 @read(i32 %8, i8* %24, i32 %25)
%27 = icmp sgt i32 %26, 0
%28 = add nsw i32 %26, %22
br i1 %27, label %21, label %29
29: ; preds = %21
%30 = tail call i32 @close(i32 %8)
ret i32 undef
}