#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*/ execl(char const *, char const *, char const *, char *);
scalar_t__ simple_fork();
scalar_t__ strcmp(char const *, char *);
int strlen(char const *);
void present_file(const char *path) {
  const char *command = NULL;
  const char *extension = path + strlen(path) - 4;
  if (strcmp(extension, ".mp3") == 0 || strcmp(extension, ".ogg") == 0 ||
      strcmp(extension, ".avi") == 0)
    command = "/usr/bin/mplayer";
  if (command) {
    if (simple_fork())
      execl(command, command, path, (char *)NULL);
  }
}


x86 assembly (clang, -O0):
<present_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0xfffffffffffffffc,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe7c(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     11c7 <present_file+0x87>
mov    -0x18(%rbp),%rdi
lea    0xe67(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     11c7 <present_file+0x87>
mov    -0x18(%rbp),%rdi
lea    0xe52(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11d2 <present_file+0x92>
lea    0xe41(%rip),%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1208 <present_file+0xc8>
mov    $0x0,%al
call   1040 <simple_fork@plt>
cmp    $0x0,%rax
je     1203 <present_file+0xc3>
mov    -0x10(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x8(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
call   1060 <execl@plt>
jmp    1208 <present_file+0xc8>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<present_file>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1030 <strlen@plt>
cltq
lea    (%r14,%rax,1),%rbx
add    $0xfffffffffffffffc,%rbx
lea    0xea3(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1192 <present_file+0x52>
lea    0xe94(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1192 <present_file+0x52>
lea    0xe85(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    11b9 <present_file+0x79>
xor    %eax,%eax
call   1040 <simple_fork@plt>
test   %rax,%rax
je     11b9 <present_file+0x79>
lea    0xe6a(%rip),%rdi
mov    %rdi,%rsi
mov    %r14,%rdx
xor    %ecx,%ecx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1060 <execl@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [5 x i8] c".mp3\00"
@.str.1 = [5 x i8] c".ogg\00"
@.str.2 = [5 x i8] c".avi\00"
@.str.3 = [17 x i8] c"/usr/bin/mplayer\00"
define void @present_file(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %2
store i8* null, i8** %3
%5 = load i8*, i8** %2
%6 = load i8*, i8** %2
%7 = call i32 @strlen(i8* %6)
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %5, i64 %8
%10 = getelementptr inbounds i8, i8* %9, i64 -4
store i8* %10, i8** %4
%11 = load i8*, i8** %4
%12 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %22, label %14
14: ; preds = %1
%15 = load i8*, i8** %4
%16 = call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %22, label %18
18: ; preds = %14
%19 = load i8*, i8** %4
%20 = call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %18, %14, %1
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8** %3
br label %23
23: ; preds = %22, %18
%24 = load i8*, i8** %3
%25 = icmp ne i8* %24, null
br i1 %25, label %26, label %35
26: ; preds = %23
%27 = call i64 (...) @simple_fork()
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %34
29: ; preds = %26
%30 = load i8*, i8** %3
%31 = load i8*, i8** %3
%32 = load i8*, i8** %2
%33 = call i32 @execl(i8* %30, i8* %31, i8* %32, i8* null)
br label %34
34: ; preds = %29, %26
br label %35
35: ; preds = %34, %23
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c".mp3\00"
@.str.1 = [5 x i8] c".ogg\00"
@.str.2 = [5 x i8] c".avi\00"
@.str.3 = [17 x i8] c"/usr/bin/mplayer\00"
define void @present_file(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = sext i32 %2 to i64
%4 = getelementptr inbounds i8, i8* %0, i64 %3
%5 = getelementptr inbounds i8, i8* %4, i64 -4
%6 = tail call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %14, label %8
8: ; preds = %1
%9 = tail call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %8
%12 = tail call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %11, %8, %1
%15 = tail call i64 (...) @simple_fork()
%16 = icmp eq i64 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %14
%18 = tail call i32 @execl(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* %0, i8* null)
br label %19
19: ; preds = %11, %14, %17
ret void
}