#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 */
struct avfs_out_message {
  int dummy;
};
struct avfs_in_message {
  int dummy;
};

/* Variables and functions */
int __av_read_message(int, struct avfs_in_message *);
int __av_write_message(int, struct avfs_out_message *);
int connect_server(int);
int sock_send_message(int sock, struct avfs_out_message *out,
                      struct avfs_in_message *in) {
  int res;
  res = connect_server(sock);
  if (res == -1)
    return -1;
  res = __av_write_message(sock, out);
  if (res == -1)
    return -1;
  res = __av_read_message(sock, in);
  if (res == -1)
    return -1;
  return 0;
}


x86 assembly (clang, -O0):
<sock_send_message>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <connect_server@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    1164 <sock_send_message+0x34>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b5 <sock_send_message+0x85>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <__av_write_message@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    1189 <sock_send_message+0x59>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b5 <sock_send_message+0x85>
mov    -0x8(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1040 <__av_read_message@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    11ae <sock_send_message+0x7e>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b5 <sock_send_message+0x85>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sock_send_message>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %edi,%ebp
call   1030 <connect_server@plt>
mov    $0xffffffff,%ebx
cmp    $0xffffffff,%eax
je     1171 <sock_send_message+0x41>
mov    %ebp,%edi
mov    %r15,%rsi
call   1050 <__av_write_message@plt>
cmp    $0xffffffff,%eax
je     1171 <sock_send_message+0x41>
mov    %ebp,%edi
mov    %r14,%rsi
call   1040 <__av_read_message@plt>
xor    %ebx,%ebx
cmp    $0xffffffff,%eax
sete   %bl
neg    %ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.avfs_out_message = type { i32 }
%struct.avfs_in_message = type { i32 }
define i32 @sock_send_message(i32 %0, %struct.avfs_out_message* %1, %struct.avfs_in_message* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.avfs_out_message*
%7 = alloca %struct.avfs_in_message*
%8 = alloca i32
store i32 %0, i32* %5
store %struct.avfs_out_message* %1, %struct.avfs_out_message** %6
store %struct.avfs_in_message* %2, %struct.avfs_in_message** %7
%9 = load i32, i32* %5
%10 = call i32 @connect_server(i32 %9)
store i32 %10, i32* %8
%11 = load i32, i32* %8
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %14
13: ; preds = %3
store i32 -1, i32* %4
br label %29
14: ; preds = %3
%15 = load i32, i32* %5
%16 = load %struct.avfs_out_message*, %struct.avfs_out_message** %6
%17 = call i32 @__av_write_message(i32 %15, %struct.avfs_out_message* %16)
store i32 %17, i32* %8
%18 = load i32, i32* %8
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %21
20: ; preds = %14
store i32 -1, i32* %4
br label %29
21: ; preds = %14
%22 = load i32, i32* %5
%23 = load %struct.avfs_in_message*, %struct.avfs_in_message** %7
%24 = call i32 @__av_read_message(i32 %22, %struct.avfs_in_message* %23)
store i32 %24, i32* %8
%25 = load i32, i32* %8
%26 = icmp eq i32 %25, -1
br i1 %26, label %27, label %28
27: ; preds = %21
store i32 -1, i32* %4
br label %29
28: ; preds = %21
store i32 0, i32* %4
br label %29
29: ; preds = %28, %27, %20, %13
%30 = load i32, i32* %4
ret i32 %30
}

LLVM IR (-O2):
%struct.avfs_out_message = type { i32 }
%struct.avfs_in_message = type { i32 }
define i32 @sock_send_message(i32 %0, %struct.avfs_out_message* %1, %struct.avfs_in_message* %2) {
%4 = tail call i32 @connect_server(i32 %0)
%5 = icmp eq i32 %4, -1
br i1 %5, label %13, label %6
6: ; preds = %3
%7 = tail call i32 @__av_write_message(i32 %0, %struct.avfs_out_message* %1)
%8 = icmp eq i32 %7, -1
br i1 %8, label %13, label %9
9: ; preds = %6
%10 = tail call i32 @__av_read_message(i32 %0, %struct.avfs_in_message* %2)
%11 = icmp eq i32 %10, -1
%12 = sext i1 %11 to i32
br label %13
13: ; preds = %9, %6, %3
%14 = phi i32 [ -1, %3 ], [ -1, %6 ], [ %12, %9 ]
ret i32 %14
}