#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*/ inet_close(int);
int /*<<< orphan*/ mpd_close(int);
int mpd_command(int, char *);
int mpd_connect();
int mpd_single_command(char *cmd) {
  int sock;
  if ((sock = mpd_connect()) == -1)
    return -1;
  if (mpd_command(sock, cmd) == -1) {
    inet_close(sock);
    return -1;
  }
  mpd_close(sock);
  return 0;
}


x86 assembly (clang, -O0):
<mpd_single_command>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x0,%al
call   1030 <mpd_connect@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
jne    116b <mpd_single_command+0x2b>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a3 <mpd_single_command+0x63>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1040 <mpd_command@plt>
cmp    $0xffffffff,%eax
jne    1194 <mpd_single_command+0x54>
mov    -0x14(%rbp),%edi
call   1050 <inet_close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a3 <mpd_single_command+0x63>
mov    -0x14(%rbp),%edi
call   1060 <mpd_close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mpd_single_command>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
xor    %eax,%eax
call   1030 <mpd_connect@plt>
mov    $0xffffffff,%ebx
cmp    $0xffffffff,%eax
je     1179 <mpd_single_command+0x39>
mov    %eax,%ebp
mov    %eax,%edi
mov    %r14,%rsi
call   1040 <mpd_command@plt>
mov    %ebp,%edi
cmp    $0xffffffff,%eax
je     1174 <mpd_single_command+0x34>
call   1060 <mpd_close@plt>
xor    %ebx,%ebx
jmp    1179 <mpd_single_command+0x39>
call   1050 <inet_close@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @mpd_single_command(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = call i32 (...) @mpd_connect()
store i32 %5, i32* %4
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %8
7: ; preds = %1
store i32 -1, i32* %2
br label %19
8: ; preds = %1
%9 = load i32, i32* %4
%10 = load i8*, i8** %3
%11 = call i32 @mpd_command(i32 %9, i8* %10)
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %16
13: ; preds = %8
%14 = load i32, i32* %4
%15 = call i32 @inet_close(i32 %14)
store i32 -1, i32* %2
br label %19
16: ; preds = %8
%17 = load i32, i32* %4
%18 = call i32 @mpd_close(i32 %17)
store i32 0, i32* %2
br label %19
19: ; preds = %16, %13, %7
%20 = load i32, i32* %2
ret i32 %20
}

LLVM IR (-O2):
define i32 @mpd_single_command(i8* %0) {
%2 = tail call i32 (...) @mpd_connect()
%3 = icmp eq i32 %2, -1
br i1 %3, label %11, label %4
4: ; preds = %1
%5 = tail call i32 @mpd_command(i32 %2, i8* %0)
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = tail call i32 @inet_close(i32 %2)
br label %11
9: ; preds = %4
%10 = tail call i32 @mpd_close(i32 %2)
br label %11
11: ; preds = %1, %9, %7
%12 = phi i32 [ -1, %7 ], [ 0, %9 ], [ -1, %1 ]
ret i32 %12
}