#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 */
typedef int /*<<< orphan*/ path;

/* Variables and functions */
int /*<<< orphan*/ find_dirlist(char *);
int /*<<< orphan*/ mpd_close(int);
int mpd_connect();
int /*<<< orphan*/ mpd_current_album(int, char *, int);
int /*<<< orphan*/ mpd_listdir(int);
int /*<<< orphan*/ read_mpdconf();
int init_mpd(void) {
  int sock;
  char path[1024];
  read_mpdconf();
  if ((sock = mpd_connect()) == -1)
    return -1;
  mpd_listdir(sock);
  mpd_current_album(sock, path, sizeof(path));
  mpd_close(sock);
  find_dirlist(path);
  return 0;
}


x86 assembly (clang, -O0):
<init_mpd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
mov    $0x0,%al
call   1060 <read_mpdconf@plt>
mov    $0x0,%al
call   1030 <mpd_connect@plt>
mov    %eax,-0x8(%rbp)
cmp    $0xffffffff,%eax
jne    1191 <init_mpd+0x31>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c8 <init_mpd+0x68>
mov    -0x8(%rbp),%edi
call   1080 <mpd_listdir@plt>
mov    -0x8(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    $0x400,%edx
call   1070 <mpd_current_album@plt>
mov    -0x8(%rbp),%edi
call   1040 <mpd_close@plt>
lea    -0x410(%rbp),%rdi
call   1050 <find_dirlist@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_mpd>:
push   %rbp
push   %r14
push   %rbx
sub    $0x400,%rsp
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <read_mpdconf@plt>
xor    %eax,%eax
call   1030 <mpd_connect@plt>
cmp    $0xffffffff,%eax
je     11ac <init_mpd+0x4c>
mov    %eax,%ebp
mov    %eax,%edi
call   1080 <mpd_listdir@plt>
mov    %rsp,%r14
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0x400,%edx
call   1070 <mpd_current_album@plt>
mov    %ebp,%edi
call   1040 <mpd_close@plt>
mov    %r14,%rdi
call   1050 <find_dirlist@plt>
jmp    11b1 <init_mpd+0x51>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @init_mpd() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [1024 x i8]
%4 = call i32 (...) @read_mpdconf()
%5 = call i32 (...) @mpd_connect()
store i32 %5, i32* %2
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %8
7: ; preds = %0
store i32 -1, i32* %1
br label %18
8: ; preds = %0
%9 = load i32, i32* %2
%10 = call i32 @mpd_listdir(i32 %9)
%11 = load i32, i32* %2
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%13 = call i32 @mpd_current_album(i32 %11, i8* %12, i32 1024)
%14 = load i32, i32* %2
%15 = call i32 @mpd_close(i32 %14)
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%17 = call i32 @find_dirlist(i8* %16)
store i32 0, i32* %1
br label %18
18: ; preds = %8, %7
%19 = load i32, i32* %1
ret i32 %19
}

LLVM IR (-O2):
define i32 @init_mpd() {
%1 = alloca [1024 x i8]
%2 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (...) @read_mpdconf()
%4 = tail call i32 (...) @mpd_connect()
%5 = icmp eq i32 %4, -1
br i1 %5, label %11, label %6
6: ; preds = %0
%7 = tail call i32 @mpd_listdir(i32 %4)
%8 = call i32 @mpd_current_album(i32 %4, i8* %2, i32 1024)
%9 = call i32 @mpd_close(i32 %4)
%10 = call i32 @find_dirlist(i8* %2)
br label %11
11: ; preds = %0, %6
%12 = phi i32 [ 0, %6 ], [ -1, %0 ]
ret i32 %12
}