#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 recv(int, char *, int, int /*<<< orphan*/);
int send(int, char *, scalar_t__, int /*<<< orphan*/);
scalar_t__ strlen(char *);
int do_proxy_cmd(int sock, char *cmd, char *buf, int buflen) {
  int n;
  n = send(sock, cmd, strlen(cmd), 0);
  if (n < 0) {
  } else if (n == (int)strlen(cmd)) {
  } else {
  }
  n = recv(sock, buf, buflen, 0);
  buf[n] = '\0';
  return n;
}


x86 assembly (clang, -O0):
<do_proxy_cmd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    %rax,%rdx
xor    %ecx,%ecx
call   1050 <send@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jge    1180 <do_proxy_cmd+0x50>
jmp    11ac <do_proxy_cmd+0x7c>
mov    -0x20(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%eax
cmp    %ecx,%eax
jne    11a2 <do_proxy_cmd+0x72>
jmp    11a7 <do_proxy_cmd+0x77>
jmp    11a7 <do_proxy_cmd+0x77>
jmp    11ac <do_proxy_cmd+0x7c>
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_proxy_cmd>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %rdx,%r15
mov    %rsi,%rbp
mov    %edi,%ebx
mov    %rsi,%rdi
call   1040 <strlen@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %rax,%rdx
xor    %ecx,%ecx
call   1050 <send@plt>
mov    %ebx,%edi
mov    %r15,%rsi
mov    %r14d,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
cltq
movb   $0x0,(%r15,%rax,1)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @do_proxy_cmd(i32 %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%10 = load i32, i32* %5
%11 = load i8*, i8** %6
%12 = load i8*, i8** %6
%13 = call i64 @strlen(i8* %12)
%14 = call i32 @send(i32 %10, i8* %11, i64 %13, i32 0)
store i32 %14, i32* %9
%15 = load i32, i32* %9
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %4
br label %27
18: ; preds = %4
%19 = load i32, i32* %9
%20 = load i8*, i8** %6
%21 = call i64 @strlen(i8* %20)
%22 = trunc i64 %21 to i32
%23 = icmp eq i32 %19, %22
br i1 %23, label %24, label %25
24: ; preds = %18
br label %26
25: ; preds = %18
br label %26
26: ; preds = %25, %24
br label %27
27: ; preds = %26, %17
%28 = load i32, i32* %5
%29 = load i8*, i8** %7
%30 = load i32, i32* %8
%31 = call i32 @recv(i32 %28, i8* %29, i32 %30, i32 0)
store i32 %31, i32* %9
%32 = load i8*, i8** %7
%33 = load i32, i32* %9
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
store i8 0, i8* %35
%36 = load i32, i32* %9
ret i32 %36
}

LLVM IR (-O2):
define i32 @do_proxy_cmd(i32 %0, i8* %1, i8* %2, i32 %3) {
%5 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%6 = tail call i32 @send(i32 %0, i8* %1, i64 %5, i32 0)
%7 = tail call i32 @recv(i32 %0, i8* %2, i32 %3, i32 0)
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %2, i64 %8
store i8 0, i8* %9
ret i32 %7
}