#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*/ db_get_error(char **, int);
int /*<<< orphan*/ db_sql_exec_fn(char **, int /*<<< orphan*/, char *, int);
int db_sql_fetch_int(char **, int *, char *, int);
int /*<<< orphan*/ free(char *);
int db_sql_delete_playlist(char **pe, int playlistid) {
  int type;
  int result;
  result = db_sql_fetch_int(pe, &type, "select type from playlists where id=%d",
                            playlistid);
  if (result != 0x00) {
    if (result == 0x05) {
      if (pe) {
        free(*pe);
      };
      db_get_error(pe, 0x06);
      return 0x06;
    }
    return result;
  }
  db_sql_exec_fn(pe, 0, "delete from playlists where id=%d", playlistid);
  db_sql_exec_fn(pe, 0, "delete from playlistitems where playlistid=%d",
                 playlistid);
  return 0x00;
}


x86 assembly (clang, -O0):
<db_sql_delete_playlist>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%ecx
lea    -0x18(%rbp),%rsi
lea    0xe9f(%rip),%rdx
call   1050 <db_sql_fetch_int@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     11b9 <db_sql_delete_playlist+0x79>
cmpl   $0x5,-0x1c(%rbp)
jne    11ae <db_sql_delete_playlist+0x6e>
cmpq   $0x0,-0x10(%rbp)
je     1194 <db_sql_delete_playlist+0x54>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rdi
mov    $0x6,%esi
call   1060 <db_get_error@plt>
movl   $0x6,-0x4(%rbp)
jmp    11ea <db_sql_delete_playlist+0xaa>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11ea <db_sql_delete_playlist+0xaa>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%ecx
xor    %esi,%esi
lea    0xe5e(%rip),%rdx
call   1040 <db_sql_exec_fn@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%ecx
xor    %esi,%esi
lea    0xe6b(%rip),%rdx
call   1040 <db_sql_exec_fn@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<db_sql_delete_playlist>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%r14d
mov    %rdi,%rbx
lea    0xeab(%rip),%rdx
lea    0xc(%rsp),%rsi
mov    %r14d,%ecx
call   1050 <db_sql_fetch_int@plt>
test   %eax,%eax
je     118e <db_sql_delete_playlist+0x4e>
mov    %eax,%ebp
cmp    $0x5,%eax
jne    11b8 <db_sql_delete_playlist+0x78>
test   %rbx,%rbx
je     117a <db_sql_delete_playlist+0x3a>
mov    (%rbx),%rdi
call   1030 <free@plt>
mov    $0x6,%ebp
mov    %rbx,%rdi
mov    $0x6,%esi
call   1060 <db_get_error@plt>
jmp    11b8 <db_sql_delete_playlist+0x78>
lea    0xe92(%rip),%rdx
xor    %ebp,%ebp
mov    %rbx,%rdi
xor    %esi,%esi
mov    %r14d,%ecx
call   1040 <db_sql_exec_fn@plt>
lea    0xe9e(%rip),%rdx
mov    %rbx,%rdi
xor    %esi,%esi
mov    %r14d,%ecx
call   1040 <db_sql_exec_fn@plt>
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [39 x i8] c"select type from playlists where id=%d\00"
@.str.1 = [34 x i8] c"delete from playlists where id=%d\00"
@.str.2 = [46 x i8] c"delete from playlistitems where playlistid=%d\00"
define i32 @db_sql_delete_playlist(i8** %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8** %0, i8*** %4
store i32 %1, i32* %5
%8 = load i8**, i8*** %4
%9 = load i32, i32* %5
%10 = call i32 @db_sql_fetch_int(i8** %8, i32* %6, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %9)
store i32 %10, i32* %7
%11 = load i32, i32* %7
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %28
13: ; preds = %2
%14 = load i32, i32* %7
%15 = icmp eq i32 %14, 5
br i1 %15, label %16, label %26
16: ; preds = %13
%17 = load i8**, i8*** %4
%18 = icmp ne i8** %17, null
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = load i8**, i8*** %4
%21 = load i8*, i8** %20
%22 = call i32 @free(i8* %21)
br label %23
23: ; preds = %19, %16
%24 = load i8**, i8*** %4
%25 = call i32 @db_get_error(i8** %24, i32 6)
store i32 6, i32* %3
br label %35
26: ; preds = %13
%27 = load i32, i32* %7
store i32 %27, i32* %3
br label %35
28: ; preds = %2
%29 = load i8**, i8*** %4
%30 = load i32, i32* %5
%31 = call i32 @db_sql_exec_fn(i8** %29, i32 0, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 %30)
%32 = load i8**, i8*** %4
%33 = load i32, i32* %5
%34 = call i32 @db_sql_exec_fn(i8** %32, i32 0, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0), i32 %33)
store i32 0, i32* %3
br label %35
35: ; preds = %28, %26, %23
%36 = load i32, i32* %3
ret i32 %36
}

LLVM IR (-O2):
@.str = [39 x i8] c"select type from playlists where id=%d\00"
@.str.1 = [34 x i8] c"delete from playlists where id=%d\00"
@.str.2 = [46 x i8] c"delete from playlistitems where playlistid=%d\00"
define i32 @db_sql_delete_playlist(i8** %0, i32 %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = call i32 @db_sql_fetch_int(i8** %0, i32* %3, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %1)
switch i32 %5, label %16 [
i32 0, label %13
i32 5, label %6
]
6: ; preds = %2
%7 = icmp eq i8** %0, null
br i1 %7, label %11, label %8
8: ; preds = %6
%9 = load i8*, i8** %0
%10 = call i32 @free(i8* %9)
br label %11
11: ; preds = %8, %6
%12 = call i32 @db_get_error(i8** %0, i32 6)
br label %16
13: ; preds = %2
%14 = call i32 @db_sql_exec_fn(i8** %0, i32 0, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 %1)
%15 = call i32 @db_sql_exec_fn(i8** %0, i32 0, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0), i32 %1)
br label %16
16: ; preds = %2, %13, %11
%17 = phi i32 [ 6, %11 ], [ 0, %13 ], [ %5, %2 ]
ret i32 %17
}