#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);
scalar_t__ vs_connect_initiative(char *, int, int *);
scalar_t__ vs_send(int, char *, int);
int vs_send_initiative(char *buf, int len, char *ip, int port) {
  int socket_id;
  if (0 != vs_connect_initiative(ip, port, &socket_id))
    return -1;
  if (0 != vs_send(socket_id, buf, len))
    return -1;
  close(socket_id);
  return 0;
}


x86 assembly (clang, -O0):
<vs_send_initiative>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
lea    -0x28(%rbp),%rdx
call   1040 <vs_connect_initiative@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     1170 <vs_send_initiative+0x40>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a8 <vs_send_initiative+0x78>
mov    -0x28(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1050 <vs_send@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     1199 <vs_send_initiative+0x69>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a8 <vs_send_initiative+0x78>
mov    -0x28(%rbp),%edi
call   1030 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vs_send_initiative>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%rax
mov    %esi,%r14d
mov    %rdi,%rbp
lea    0xc(%rsp),%rdx
mov    %rax,%rdi
mov    %ecx,%esi
call   1040 <vs_connect_initiative@plt>
mov    $0xffffffff,%ebx
test   %rax,%rax
jne    1179 <vs_send_initiative+0x49>
mov    0xc(%rsp),%edi
mov    %rbp,%rsi
mov    %r14d,%edx
call   1050 <vs_send@plt>
test   %rax,%rax
jne    1179 <vs_send_initiative+0x49>
mov    0xc(%rsp),%edi
call   1030 <close@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @vs_send_initiative(i8* %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i32 %3, i32* %9
%11 = load i8*, i8** %8
%12 = load i32, i32* %9
%13 = call i64 @vs_connect_initiative(i8* %11, i32 %12, i32* %10)
%14 = icmp ne i64 0, %13
br i1 %14, label %15, label %16
15: ; preds = %4
store i32 -1, i32* %5
br label %26
16: ; preds = %4
%17 = load i32, i32* %10
%18 = load i8*, i8** %6
%19 = load i32, i32* %7
%20 = call i64 @vs_send(i32 %17, i8* %18, i32 %19)
%21 = icmp ne i64 0, %20
br i1 %21, label %22, label %23
22: ; preds = %16
store i32 -1, i32* %5
br label %26
23: ; preds = %16
%24 = load i32, i32* %10
%25 = call i32 @close(i32 %24)
store i32 0, i32* %5
br label %26
26: ; preds = %23, %22, %15
%27 = load i32, i32* %5
ret i32 %27
}

LLVM IR (-O2):
define i32 @vs_send_initiative(i8* %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = bitcast i32* %5 to i8*
%7 = call i64 @vs_connect_initiative(i8* %2, i32 %3, i32* %5)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %16
9: ; preds = %4
%10 = load i32, i32* %5
%11 = call i64 @vs_send(i32 %10, i8* %0, i32 %1)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %9
%14 = load i32, i32* %5
%15 = call i32 @close(i32 %14)
br label %16
16: ; preds = %9, %4, %13
%17 = phi i32 [ 0, %13 ], [ -1, %4 ], [ -1, %9 ]
ret i32 %17
}