#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*/ _my_log(char *, int, char *, char *);
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;
  do {
    _my_log("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/zhongliangkang/twemproxy41/refs/heads/"
            "master/transfer/org_fix.c",
            71, "do_proxy_cmd: %s\n", cmd);
  } while (0);
  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    -0x10(%rbp),%rcx
lea    0xe9f(%rip),%rdi
mov    $0x47,%esi
lea    0xf2d(%rip),%rdx
call   1040 <_my_log@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    %rax,%rdx
xor    %ecx,%ecx
call   1060 <send@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jge    11ac <do_proxy_cmd+0x6c>
jmp    11d8 <do_proxy_cmd+0x98>
mov    -0x20(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%eax
cmp    %ecx,%eax
jne    11ce <do_proxy_cmd+0x8e>
jmp    11d3 <do_proxy_cmd+0x93>
jmp    11d3 <do_proxy_cmd+0x93>
jmp    11d8 <do_proxy_cmd+0x98>
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
lea    0xea7(%rip),%rdi
lea    0xf3a(%rip),%rdx
mov    $0x47,%esi
mov    %rbp,%rcx
call   1040 <_my_log@plt>
mov    %rbp,%rdi
call   1050 <strlen@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %rax,%rdx
xor    %ecx,%ecx
call   1060 <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):
@.str = [154 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/zhongliangkang/twemproxy41/refs/heads/master/transfer/org_fix.c\00"
@.str.1 = [18 x i8] c"do_proxy_cmd: %s\0A\00"
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
br label %10
10: ; preds = %4
%11 = load i8*, i8** %6
%12 = call i32 @_my_log(i8* getelementptr inbounds ([154 x i8], [154 x i8]* @.str, i64 0, i64 0), i32 71, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %11)
br label %13
13: ; preds = %10
%14 = load i32, i32* %5
%15 = load i8*, i8** %6
%16 = load i8*, i8** %6
%17 = call i64 @strlen(i8* %16)
%18 = call i32 @send(i32 %14, i8* %15, i64 %17, i32 0)
store i32 %18, i32* %9
%19 = load i32, i32* %9
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %13
br label %31
22: ; preds = %13
%23 = load i32, i32* %9
%24 = load i8*, i8** %6
%25 = call i64 @strlen(i8* %24)
%26 = trunc i64 %25 to i32
%27 = icmp eq i32 %23, %26
br i1 %27, label %28, label %29
28: ; preds = %22
br label %30
29: ; preds = %22
br label %30
30: ; preds = %29, %28
br label %31
31: ; preds = %30, %21
%32 = load i32, i32* %5
%33 = load i8*, i8** %7
%34 = load i32, i32* %8
%35 = call i32 @recv(i32 %32, i8* %33, i32 %34, i32 0)
store i32 %35, i32* %9
%36 = load i8*, i8** %7
%37 = load i32, i32* %9
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %36, i64 %38
store i8 0, i8* %39
%40 = load i32, i32* %9
ret i32 %40
}

LLVM IR (-O2):
@.str = [154 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/zhongliangkang/twemproxy41/refs/heads/master/transfer/org_fix.c\00"
@.str.1 = [18 x i8] c"do_proxy_cmd: %s\0A\00"
define i32 @do_proxy_cmd(i32 %0, i8* %1, i8* %2, i32 %3) {
%5 = tail call i32 @_my_log(i8* getelementptr inbounds ([154 x i8], [154 x i8]* @.str, i64 0, i64 0), i32 71, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%6 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%7 = tail call i32 @send(i32 %0, i8* %1, i64 %6, i32 0)
%8 = tail call i32 @recv(i32 %0, i8* %2, i32 %3, i32 0)
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %2, i64 %9
store i8 0, i8* %10
ret i32 %8
}