#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*/ printf(char *, char *);
int /*<<< orphan*/ puts(char *);
scalar_t__ recv(int, char *, int, int /*<<< orphan*/);
int do_serv_pwd(int sock_fd) {
  char dir[1024] = {0};
  if (sock_fd <= 0) {
    puts("the connection not established...");
    return -1;
  }
  if (recv(sock_fd, dir, 1024, 0) <= 0) {
    puts("cant get current dir...");
    return -1;
  }
  printf("current server dir:%s\n", dir);
  return 0;
}


x86 assembly (clang, -O0):
<do_serv_pwd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
mov    %edi,-0x8(%rbp)
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1060 <memset@plt>
cmpl   $0x0,-0x8(%rbp)
jg     1183 <do_serv_pwd+0x43>
lea    0xe8e(%rip),%rdi
call   1040 <puts@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d5 <do_serv_pwd+0x95>
mov    -0x8(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
cmp    $0x0,%rax
jg     11bb <do_serv_pwd+0x7b>
lea    0xe78(%rip),%rdi
call   1040 <puts@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d5 <do_serv_pwd+0x95>
lea    -0x410(%rbp),%rsi
lea    0xe71(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_serv_pwd>:
push   %rbp
push   %rbx
sub    $0x408,%rsp
mov    %edi,%ebp
mov    %rsp,%rdi
mov    $0x400,%edx
xor    %esi,%esi
call   1060 <memset@plt>
test   %ebp,%ebp
jle    1187 <do_serv_pwd+0x47>
mov    %rsp,%rsi
xor    %ebx,%ebx
mov    %ebp,%edi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
test   %rax,%rax
jle    1190 <do_serv_pwd+0x50>
lea    0xebd(%rip),%rdi
mov    %rsp,%rsi
call   1050 <printf@plt>
jmp    11a1 <do_serv_pwd+0x61>
lea    0xe72(%rip),%rdi
jmp    1197 <do_serv_pwd+0x57>
lea    0xe8b(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x408,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [34 x i8] c"the connection not established...\00"
@.str.1 = [24 x i8] c"cant get current dir...\00"
@.str.2 = [23 x i8] c"current server dir:%s\0A\00"
define i32 @do_serv_pwd(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [1024 x i8]
store i32 %0, i32* %3
%5 = bitcast [1024 x i8]* %4 to i8*
%6 = load i32, i32* %3
%7 = icmp sle i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = call i32 @puts(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %2
br label %20
10: ; preds = %1
%11 = load i32, i32* %3
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%13 = call i64 @recv(i32 %11, i8* %12, i32 1024, i32 0)
%14 = icmp sle i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %10
%16 = call i32 @puts(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %2
br label %20
17: ; preds = %10
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%19 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %18)
store i32 0, i32* %2
br label %20
20: ; preds = %17, %15, %8
%21 = load i32, i32* %2
ret i32 %21
}

LLVM IR (-O2):
@.str = [34 x i8] c"the connection not established...\00"
@.str.1 = [24 x i8] c"cant get current dir...\00"
@.str.2 = [23 x i8] c"current server dir:%s\0A\00"
define i32 @do_serv_pwd(i32 %0) {
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%4 = icmp slt i32 %0, 1
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %14
7: ; preds = %1
%8 = call i64 @recv(i32 %0, i8* %3, i32 1024, i32 0)
%9 = icmp slt i64 %8, 1
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
br label %14
12: ; preds = %7
%13 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %3)
br label %14
14: ; preds = %12, %10, %5
%15 = phi i32 [ -1, %5 ], [ -1, %10 ], [ 0, %12 ]
ret i32 %15
}