#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 play_random(void) {
  int sock;
  if ((sock = mpd_connect()) == -1)
    return -1;
  if (mpd_command(sock, "random 1\n") == -1) {
    inet_close(sock);
    return -1;
  }
  if (mpd_command(sock, "next\n") == -1) {
    inet_close(sock);
    return -1;
  }
  mpd_close(sock);
  return 0;
}


x86 assembly (clang, -O0):
<play_random>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <mpd_connect@plt>
mov    %eax,-0x8(%rbp)
cmp    $0xffffffff,%eax
jne    1167 <play_random+0x27>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ce <play_random+0x8e>
mov    -0x8(%rbp),%edi
lea    0xe8f(%rip),%rsi
call   1040 <mpd_command@plt>
cmp    $0xffffffff,%eax
jne    1193 <play_random+0x53>
mov    -0x8(%rbp),%edi
call   1050 <inet_close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ce <play_random+0x8e>
mov    -0x8(%rbp),%edi
lea    0xe6d(%rip),%rsi
call   1040 <mpd_command@plt>
cmp    $0xffffffff,%eax
jne    11bf <play_random+0x7f>
mov    -0x8(%rbp),%edi
call   1050 <inet_close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ce <play_random+0x8e>
mov    -0x8(%rbp),%edi
call   1060 <mpd_close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<play_random>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1030 <mpd_connect@plt>
mov    $0xffffffff,%ebx
cmp    $0xffffffff,%eax
je     118e <play_random+0x4e>
mov    %eax,%ebp
lea    0xea3(%rip),%rsi
mov    %eax,%edi
call   1040 <mpd_command@plt>
cmp    $0xffffffff,%eax
je     1187 <play_random+0x47>
lea    0xe9a(%rip),%rsi
mov    %ebp,%edi
call   1040 <mpd_command@plt>
cmp    $0xffffffff,%eax
je     1187 <play_random+0x47>
mov    %ebp,%edi
call   1060 <mpd_close@plt>
xor    %ebx,%ebx
jmp    118e <play_random+0x4e>
mov    %ebp,%edi
call   1050 <inet_close@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"random 1\0A\00"
@.str.1 = [6 x i8] c"next\0A\00"
define i32 @play_random() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 (...) @mpd_connect()
store i32 %3, i32* %2
%4 = icmp eq i32 %3, -1
br i1 %4, label %5, label %6
5: ; preds = %0
store i32 -1, i32* %1
br label %23
6: ; preds = %0
%7 = load i32, i32* %2
%8 = call i32 @mpd_command(i32 %7, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %13
10: ; preds = %6
%11 = load i32, i32* %2
%12 = call i32 @inet_close(i32 %11)
store i32 -1, i32* %1
br label %23
13: ; preds = %6
%14 = load i32, i32* %2
%15 = call i32 @mpd_command(i32 %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %20
17: ; preds = %13
%18 = load i32, i32* %2
%19 = call i32 @inet_close(i32 %18)
store i32 -1, i32* %1
br label %23
20: ; preds = %13
%21 = load i32, i32* %2
%22 = call i32 @mpd_close(i32 %21)
store i32 0, i32* %1
br label %23
23: ; preds = %20, %17, %10, %5
%24 = load i32, i32* %1
ret i32 %24
}

LLVM IR (-O2):
@.str = [10 x i8] c"random 1\0A\00"
@.str.1 = [6 x i8] c"next\0A\00"
define i32 @play_random() {
%1 = tail call i32 (...) @mpd_connect()
%2 = icmp eq i32 %1, -1
br i1 %2, label %15, label %3
3: ; preds = %0
%4 = tail call i32 @mpd_command(i32 %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call i32 @inet_close(i32 %1)
br label %15
8: ; preds = %3
%9 = tail call i32 @mpd_command(i32 %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = tail call i32 @inet_close(i32 %1)
br label %15
13: ; preds = %8
%14 = tail call i32 @mpd_close(i32 %1)
br label %15
15: ; preds = %0, %13, %11, %6
%16 = phi i32 [ -1, %6 ], [ -1, %11 ], [ 0, %13 ], [ -1, %0 ]
ret i32 %16
}