#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 */
scalar_t__ strncasecmp(char *, char *, int);
char *strrchr(char const *, char);
int is_playlist(const char *path) {
  char *ext;
  if (!path)
    return 0;
  ext = strrchr(path, '.');
  if (!ext)
    return 0;
  ext++;
  if (strncasecmp(ext, "pls", 3) == 0 || strncasecmp(ext, "m3u", 3) == 0) {
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<is_playlist>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1143 <is_playlist+0x23>
movl   $0x0,-0x4(%rbp)
jmp    11c9 <is_playlist+0xa9>
mov    -0x10(%rbp),%rdi
mov    $0x2e,%esi
call   1030 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    116c <is_playlist+0x4c>
movl   $0x0,-0x4(%rbp)
jmp    11c9 <is_playlist+0xa9>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe7d(%rip),%rsi
mov    $0x3,%edx
call   1040 <strncasecmp@plt>
cmp    $0x0,%rax
je     11b6 <is_playlist+0x96>
mov    -0x18(%rbp),%rdi
lea    0xe62(%rip),%rsi
mov    $0x3,%edx
call   1040 <strncasecmp@plt>
cmp    $0x0,%rax
jne    11c2 <is_playlist+0xa2>
movl   $0x1,-0x4(%rbp)
jmp    11c9 <is_playlist+0xa9>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_playlist>:
push   %rbp
push   %rbx
push   %rax
xor    %ebp,%ebp
test   %rdi,%rdi
je     117d <is_playlist+0x5d>
mov    $0x2e,%esi
call   1030 <strrchr@plt>
test   %rax,%rax
je     117d <is_playlist+0x5d>
mov    %rax,%rbx
add    $0x1,%rbx
lea    0xeb9(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1040 <strncasecmp@plt>
test   %rax,%rax
je     1178 <is_playlist+0x58>
lea    0xea4(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1040 <strncasecmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
sete   %bpl
jmp    117d <is_playlist+0x5d>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"pls\00"
@.str.1 = [4 x i8] c"m3u\00"
define i32 @is_playlist(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %8, label %7
7: ; preds = %1
store i32 0, i32* %2
br label %26
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i8* @strrchr(i8* %9, i8 signext 46)
store i8* %10, i8** %4
%11 = load i8*, i8** %4
%12 = icmp ne i8* %11, null
br i1 %12, label %14, label %13
13: ; preds = %8
store i32 0, i32* %2
br label %26
14: ; preds = %8
%15 = load i8*, i8** %4
%16 = getelementptr inbounds i8, i8* %15, i32 1
store i8* %16, i8** %4
%17 = load i8*, i8** %4
%18 = call i64 @strncasecmp(i8* %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%19 = icmp eq i64 %18, 0
br i1 %19, label %24, label %20
20: ; preds = %14
%21 = load i8*, i8** %4
%22 = call i64 @strncasecmp(i8* %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %20, %14
store i32 1, i32* %2
br label %26
25: ; preds = %20
store i32 0, i32* %2
br label %26
26: ; preds = %25, %24, %13, %7
%27 = load i32, i32* %2
ret i32 %27
}

LLVM IR (-O2):
@.str = [4 x i8] c"pls\00"
@.str.1 = [4 x i8] c"m3u\00"
define i32 @is_playlist(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %14, label %3
3: ; preds = %1
%4 = tail call i8* @strrchr(i8* %0, i8 signext 46)
%5 = icmp eq i8* %4, null
br i1 %5, label %14, label %6
6: ; preds = %3
%7 = getelementptr inbounds i8, i8* %4, i64 1
%8 = tail call i64 @strncasecmp(i8* %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%9 = icmp eq i64 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %6
%11 = tail call i64 @strncasecmp(i8* %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
%12 = icmp eq i64 %11, 0
%13 = zext i1 %12 to i32
br label %14
14: ; preds = %10, %6, %3, %1
%15 = phi i32 [ 0, %1 ], [ 0, %3 ], [ 1, %6 ], [ %13, %10 ]
ret i32 %15
}