#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 */
struct pollfd {
  int fd;
  int events;
  int revents;
};

/* Variables and functions */
int /*<<< orphan*/ AUDIO_SOURCE_MEMORY;
int POLLIN;
int POLLOUT;
int STDIN_FILENO;
int /*<<< orphan*/ VIDEO_SOURCE_MEMORY;
int /*<<< orphan*/ audioPlay(int);
int /*<<< orphan*/ audioSelectSource(int, int /*<<< orphan*/);
int /*<<< orphan*/ audioSetAVSync(int, int);
int /*<<< orphan*/ audioSetMute(int, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int getchar();
scalar_t__ poll(struct pollfd *, int, int);
int /*<<< orphan*/ printf(char *);
int read(int, char *, int);
int /*<<< orphan*/ videoContinue(int);
int /*<<< orphan*/ videoFastForward(int, int /*<<< orphan*/);
int /*<<< orphan*/ videoFreeze(int);
int /*<<< orphan*/ videoPlay(int);
int /*<<< orphan*/ videoSelectSource(int, int /*<<< orphan*/);
int /*<<< orphan*/ videoSlowMotion(int, int);
int /*<<< orphan*/ videoStop(int);
scalar_t__ write(int, char *, int);
void play_file_av(int filefd, int vfd, int afd) {
  char buf[32768];
  int count;
  int written;
  struct pollfd pfd[2];
  int stopped = 0;
  pfd[0].fd = STDIN_FILENO;
  pfd[0].events = POLLIN;
  pfd[1].fd = vfd;
  pfd[1].events = POLLOUT;
  pfd[2].fd = afd;
  pfd[2].events = POLLOUT;
  videoSelectSource(vfd, VIDEO_SOURCE_MEMORY);
  audioSelectSource(afd, AUDIO_SOURCE_MEMORY);
  audioPlay(afd);
  videoPlay(vfd);
  count = read(filefd, buf, 32768);
  write(vfd, buf, count);
  while ((count = read(filefd, buf, 32768)) >= 0) {
    written = 0;
    while (written < count) {
      if (poll(pfd, 2, 1)) {
        if (pfd[1].revents & POLLOUT) {
          written += write(vfd, buf + written, count - written);
        }
        if (pfd[0].revents & POLLIN) {
          int c = getchar();
          switch (c) {
          case 'z':
            videoFreeze(vfd);
            printf("playback frozen\n");
            stopped = 1;
            break;
          case 's':
            videoStop(vfd);
            printf("playback stopped\n");
            stopped = 1;
            break;
          case 'c':
            videoContinue(vfd);
            printf("playback continued\n");
            stopped = 0;
            break;
          case 'p':
            videoPlay(vfd);
            audioPlay(afd);
            audioSetAVSync(afd, 1);
            audioSetMute(afd, 0);
            printf("playback started\n");
            stopped = 0;
            break;
          case 'f':
            audioSetAVSync(afd, 0);
            audioSetMute(afd, 1);
            videoFastForward(vfd, 0);
            printf("fastforward\n");
            stopped = 0;
            break;
          case 'm':
            audioSetAVSync(afd, 0);
            audioSetMute(afd, 1);
            videoSlowMotion(vfd, 2);
            printf("slowmotion\n");
            stopped = 0;
            break;
          case 'q':
            videoContinue(vfd);
            exit(0);
            break;
          }
        }
      }
    }
  }
}


x86 assembly (clang, -O0):
<play_file_av>:
push   %rbp
mov    %rsp,%rbp
sub    $0x8040,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movl   $0x0,-0x8034(%rbp)
mov    0x2d8b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8030(%rbp)
mov    0x2d9c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x802c(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x8024(%rbp)
mov    0x2d9c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8020(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x8018(%rbp)
mov    0x2d84(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8014(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2d4a(%rip),%rax
mov    (%rax),%esi
call   1110 <videoSelectSource@plt>
mov    -0xc(%rbp),%edi
mov    0x2d31(%rip),%rax
mov    (%rax),%esi
call   10e0 <audioSelectSource@plt>
mov    -0xc(%rbp),%edi
call   1050 <audioPlay@plt>
mov    -0x8(%rbp),%edi
call   10d0 <videoPlay@plt>
mov    -0x4(%rbp),%edi
lea    -0x8010(%rbp),%rsi
mov    $0x8000,%edx
call   1090 <read@plt>
mov    %eax,-0x8014(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x8010(%rbp),%rsi
mov    -0x8014(%rbp),%edx
call   1060 <write@plt>
mov    -0x4(%rbp),%edi
lea    -0x8010(%rbp),%rsi
mov    $0x8000,%edx
call   1090 <read@plt>
mov    %eax,-0x8014(%rbp)
cmp    $0x0,%eax
jl     152c <play_file_av+0x31c>
movl   $0x0,-0x8018(%rbp)
mov    -0x8018(%rbp),%eax
cmp    -0x8014(%rbp),%eax
jge    1527 <play_file_av+0x317>
lea    -0x8030(%rbp),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
call   1100 <poll@plt>
cmp    $0x0,%rax
je     1522 <play_file_av+0x312>
mov    -0x801c(%rbp),%eax
mov    0x2caf(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     138c <play_file_av+0x17c>
mov    -0x8(%rbp),%edi
lea    -0x8010(%rbp),%rsi
movslq -0x8018(%rbp),%rax
add    %rax,%rsi
mov    -0x8014(%rbp),%edx
sub    -0x8018(%rbp),%edx
call   1060 <write@plt>
mov    %rax,%rcx
movslq -0x8018(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x8018(%rbp)
mov    -0x8028(%rbp),%eax
mov    0x2c47(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     151d <play_file_av+0x30d>
xor    %eax,%eax
call   10b0 <getchar@plt>
mov    %eax,-0x8038(%rbp)
mov    -0x8038(%rbp),%eax
add    $0xffffff9d,%eax
mov    %eax,%ecx
mov    %rcx,-0x8040(%rbp)
sub    $0x17,%eax
ja     1518 <play_file_av+0x308>
mov    -0x8040(%rbp),%rax
lea    0xc26(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%edi
call   10f0 <videoFreeze@plt>
lea    0xc6e(%rip),%rdi
call   1070 <printf@plt>
movl   $0x1,-0x8034(%rbp)
jmp    1518 <play_file_av+0x308>
mov    -0x8(%rbp),%edi
call   10a0 <videoStop@plt>
lea    0xc5c(%rip),%rdi
call   1070 <printf@plt>
movl   $0x1,-0x8034(%rbp)
jmp    1518 <play_file_av+0x308>
mov    -0x8(%rbp),%edi
call   1040 <videoContinue@plt>
lea    0xc4b(%rip),%rdi
call   1070 <printf@plt>
movl   $0x0,-0x8034(%rbp)
jmp    1518 <play_file_av+0x308>
mov    -0x8(%rbp),%edi
call   10d0 <videoPlay@plt>
mov    -0xc(%rbp),%edi
call   1050 <audioPlay@plt>
mov    -0xc(%rbp),%edi
mov    $0x1,%esi
call   10c0 <audioSetAVSync@plt>
mov    -0xc(%rbp),%edi
xor    %esi,%esi
call   1030 <audioSetMute@plt>
lea    0xc1d(%rip),%rdi
call   1070 <printf@plt>
movl   $0x0,-0x8034(%rbp)
jmp    1518 <play_file_av+0x308>
mov    -0xc(%rbp),%edi
xor    %esi,%esi
call   10c0 <audioSetAVSync@plt>
mov    -0xc(%rbp),%edi
mov    $0x1,%esi
call   1030 <audioSetMute@plt>
mov    -0x8(%rbp),%edi
xor    %esi,%esi
call   1080 <videoFastForward@plt>
lea    0xbf3(%rip),%rdi
call   1070 <printf@plt>
movl   $0x0,-0x8034(%rbp)
jmp    1518 <play_file_av+0x308>
mov    -0xc(%rbp),%edi
xor    %esi,%esi
call   10c0 <audioSetAVSync@plt>
mov    -0xc(%rbp),%edi
mov    $0x1,%esi
call   1030 <audioSetMute@plt>
mov    -0x8(%rbp),%edi
mov    $0x2,%esi
call   1130 <videoSlowMotion@plt>
lea    0xbc1(%rip),%rdi
call   1070 <printf@plt>
movl   $0x0,-0x8034(%rbp)
jmp    1518 <play_file_av+0x308>
mov    -0x8(%rbp),%edi
call   1040 <videoContinue@plt>
xor    %edi,%edi
call   1120 <exit@plt>
jmp    151d <play_file_av+0x30d>
jmp    1522 <play_file_av+0x312>
jmp    130a <play_file_av+0xfa>
jmp    12dd <play_file_av+0xcd>
add    $0x8040,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<play_file_av>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x8038,%rsp
mov    %edx,%ebp
mov    %esi,%r14d
mov    %edi,%ebx
mov    0x2d91(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x10(%rsp)
mov    0x2da4(%rip),%r15
mov    (%r15),%eax
mov    %eax,0x14(%rsp)
mov    %esi,0x1c(%rsp)
mov    0x2daa(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x20(%rsp)
mov    %edx,0x28(%rsp)
mov    %eax,0x2c(%rsp)
mov    0x2d6d(%rip),%rax
mov    (%rax),%esi
mov    %r14d,%edi
call   1110 <videoSelectSource@plt>
mov    0x2d54(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
call   10e0 <audioSelectSource@plt>
mov    %ebp,0x8(%rsp)
mov    %ebp,%edi
call   1050 <audioPlay@plt>
mov    %r14d,%edi
call   10d0 <videoPlay@plt>
lea    0x30(%rsp),%rbp
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x8000,%edx
call   1090 <read@plt>
mov    %r14d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1070 <write@plt>
mov    %ebx,0xc(%rsp)
mov    %ebx,%edi
mov    %r15,%rbx
mov    %rbp,%rsi
mov    $0x8000,%edx
call   1090 <read@plt>
test   %eax,%eax
js     1467 <play_file_av+0x257>
mov    %eax,%ebp
lea    0x10(%rsp),%r13
jmp    12fd <play_file_av+0xed>
nopl   0x0(%rax,%rax,1)
mov    0xc(%rsp),%edi
lea    0x30(%rsp),%rsi
mov    $0x8000,%edx
call   1090 <read@plt>
mov    %eax,%ebp
test   %eax,%eax
js     1467 <play_file_av+0x257>
test   %ebp,%ebp
je     12e0 <play_file_av+0xd0>
xor    %r15d,%r15d
jmp    132a <play_file_av+0x11a>
mov    %r14d,%edi
call   10f0 <videoFreeze@plt>
lea    0xd97(%rip),%rdi
cs nopw 0x0(%rax,%rax,1)
nop
call   1060 <puts@plt>
cmp    %r15d,%ebp
jle    12e0 <play_file_av+0xd0>
mov    %r13,%rdi
mov    $0x2,%esi
mov    $0x1,%edx
call   1100 <poll@plt>
test   %rax,%rax
je     1325 <play_file_av+0x115>
mov    0x2cb0(%rip),%rax
mov    (%rax),%eax
test   %eax,0x24(%rsp)
je     136e <play_file_av+0x15e>
movslq %r15d,%r12
lea    (%rsp,%r12,1),%rsi
add    $0x30,%rsi
mov    %ebp,%edx
sub    %r12d,%edx
mov    %r14d,%edi
call   1070 <write@plt>
mov    %rax,%r15
add    %r12d,%r15d
mov    (%rbx),%eax
test   %eax,0x18(%rsp)
je     1325 <play_file_av+0x115>
xor    %eax,%eax
call   10b0 <getchar@plt>
add    $0xffffff9d,%eax
cmp    $0x17,%eax
ja     1325 <play_file_av+0x115>
lea    0xc74(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    %r14d,%edi
call   1040 <videoContinue@plt>
lea    0xce4(%rip),%rdi
jmp    1320 <play_file_av+0x110>
mov    0x8(%rsp),%ebx
mov    %ebx,%edi
xor    %esi,%esi
call   10c0 <audioSetAVSync@plt>
mov    %ebx,%edi
mov    0x2c21(%rip),%rbx
mov    $0x1,%esi
call   1030 <audioSetMute@plt>
mov    %r14d,%edi
xor    %esi,%esi
call   1080 <videoFastForward@plt>
lea    0xc91(%rip),%rdi
jmp    1320 <play_file_av+0x110>
mov    0x8(%rsp),%ebx
mov    %ebx,%edi
xor    %esi,%esi
call   10c0 <audioSetAVSync@plt>
mov    %ebx,%edi
mov    0x2beb(%rip),%rbx
mov    $0x1,%esi
call   1030 <audioSetMute@plt>
mov    %r14d,%edi
mov    $0x2,%esi
call   1130 <videoSlowMotion@plt>
lea    0xc4d(%rip),%rdi
jmp    1320 <play_file_av+0x110>
mov    %r14d,%edi
call   10d0 <videoPlay@plt>
mov    0x8(%rsp),%ebx
mov    %ebx,%edi
call   1050 <audioPlay@plt>
mov    %ebx,%edi
mov    $0x1,%esi
call   10c0 <audioSetAVSync@plt>
mov    %ebx,%edi
mov    0x2ba0(%rip),%rbx
xor    %esi,%esi
call   1030 <audioSetMute@plt>
lea    0xc29(%rip),%rdi
jmp    1320 <play_file_av+0x110>
mov    %r14d,%edi
call   10a0 <videoStop@plt>
lea    0xc39(%rip),%rdi
jmp    1320 <play_file_av+0x110>
add    $0x8038,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r14d,%edi
call   1040 <videoContinue@plt>
xor    %edi,%edi
call   1120 <exit@plt>

LLVM IR (-O0):
%struct.pollfd = type { i32, i32, i32 }
@STDIN_FILENO = global i32 0
@POLLIN = global i32 0
@POLLOUT = global i32 0
@VIDEO_SOURCE_MEMORY = global i32 0
@AUDIO_SOURCE_MEMORY = global i32 0
@.str = [17 x i8] c"playback frozen\0A\00"
@.str.1 = [18 x i8] c"playback stopped\0A\00"
@.str.2 = [20 x i8] c"playback continued\0A\00"
@.str.3 = [18 x i8] c"playback started\0A\00"
@.str.4 = [13 x i8] c"fastforward\0A\00"
@.str.5 = [12 x i8] c"slowmotion\0A\00"
define void @play_file_av(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [32768 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = alloca [2 x %struct.pollfd]
%11 = alloca i32
%12 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 0, i32* %11
%13 = load i32, i32* @STDIN_FILENO
%14 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %10, i64 0, i64 0
%15 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %14, i32 0, i32 0
store i32 %13, i32* %15
%16 = load i32, i32* @POLLIN
%17 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %10, i64 0, i64 0
%18 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %17, i32 0, i32 1
store i32 %16, i32* %18
%19 = load i32, i32* %5
%20 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %10, i64 0, i64 1
%21 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %20, i32 0, i32 0
store i32 %19, i32* %21
%22 = load i32, i32* @POLLOUT
%23 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %10, i64 0, i64 1
%24 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %23, i32 0, i32 1
store i32 %22, i32* %24
%25 = load i32, i32* %6
%26 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %10, i64 0, i64 2
%27 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %26, i32 0, i32 0
store i32 %25, i32* %27
%28 = load i32, i32* @POLLOUT
%29 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %10, i64 0, i64 2
%30 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %29, i32 0, i32 1
store i32 %28, i32* %30
%31 = load i32, i32* %5
%32 = load i32, i32* @VIDEO_SOURCE_MEMORY
%33 = call i32 @videoSelectSource(i32 %31, i32 %32)
%34 = load i32, i32* %6
%35 = load i32, i32* @AUDIO_SOURCE_MEMORY
%36 = call i32 @audioSelectSource(i32 %34, i32 %35)
%37 = load i32, i32* %6
%38 = call i32 @audioPlay(i32 %37)
%39 = load i32, i32* %5
%40 = call i32 @videoPlay(i32 %39)
%41 = load i32, i32* %4
%42 = getelementptr inbounds [32768 x i8], [32768 x i8]* %7, i64 0, i64 0
%43 = call i32 @read(i32 %41, i8* %42, i32 32768)
store i32 %43, i32* %8
%44 = load i32, i32* %5
%45 = getelementptr inbounds [32768 x i8], [32768 x i8]* %7, i64 0, i64 0
%46 = load i32, i32* %8
%47 = call i64 @write(i32 %44, i8* %45, i32 %46)
br label %48
48: ; preds = %138, %3
%49 = load i32, i32* %4
%50 = getelementptr inbounds [32768 x i8], [32768 x i8]* %7, i64 0, i64 0
%51 = call i32 @read(i32 %49, i8* %50, i32 32768)
store i32 %51, i32* %8
%52 = icmp sge i32 %51, 0
br i1 %52, label %53, label %139
53: ; preds = %48
store i32 0, i32* %9
br label %54
54: ; preds = %137, %53
%55 = load i32, i32* %9
%56 = load i32, i32* %8
%57 = icmp slt i32 %55, %56
br i1 %57, label %58, label %138
58: ; preds = %54
%59 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %10, i64 0, i64 0
%60 = call i64 @poll(%struct.pollfd* %59, i32 2, i32 1)
%61 = icmp ne i64 %60, 0
br i1 %61, label %62, label %137
62: ; preds = %58
%63 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %10, i64 0, i64 1
%64 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %63, i32 0, i32 2
%65 = load i32, i32* %64
%66 = load i32, i32* @POLLOUT
%67 = and i32 %65, %66
%68 = icmp ne i32 %67, 0
br i1 %68, label %69, label %83
69: ; preds = %62
%70 = load i32, i32* %5
%71 = getelementptr inbounds [32768 x i8], [32768 x i8]* %7, i64 0, i64 0
%72 = load i32, i32* %9
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i8, i8* %71, i64 %73
%75 = load i32, i32* %8
%76 = load i32, i32* %9
%77 = sub nsw i32 %75, %76
%78 = call i64 @write(i32 %70, i8* %74, i32 %77)
%79 = load i32, i32* %9
%80 = sext i32 %79 to i64
%81 = add nsw i64 %80, %78
%82 = trunc i64 %81 to i32
store i32 %82, i32* %9
br label %83
83: ; preds = %69, %62
%84 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %10, i64 0, i64 0
%85 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %84, i32 0, i32 2
%86 = load i32, i32* %85
%87 = load i32, i32* @POLLIN
%88 = and i32 %86, %87
%89 = icmp ne i32 %88, 0
br i1 %89, label %90, label %136
90: ; preds = %83
%91 = call i32 (...) @getchar()
store i32 %91, i32* %12
%92 = load i32, i32* %12
switch i32 %92, label %135 [
i32 122, label %93
i32 115, label %97
i32 99, label %101
i32 112, label %105
i32 102, label %115
i32 109, label %123
i32 113, label %131
]
93: ; preds = %90
%94 = load i32, i32* %5
%95 = call i32 @videoFreeze(i32 %94)
%96 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %11
br label %135
97: ; preds = %90
%98 = load i32, i32* %5
%99 = call i32 @videoStop(i32 %98)
%100 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %11
br label %135
101: ; preds = %90
%102 = load i32, i32* %5
%103 = call i32 @videoContinue(i32 %102)
%104 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %11
br label %135
105: ; preds = %90
%106 = load i32, i32* %5
%107 = call i32 @videoPlay(i32 %106)
%108 = load i32, i32* %6
%109 = call i32 @audioPlay(i32 %108)
%110 = load i32, i32* %6
%111 = call i32 @audioSetAVSync(i32 %110, i32 1)
%112 = load i32, i32* %6
%113 = call i32 @audioSetMute(i32 %112, i32 0)
%114 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %11
br label %135
115: ; preds = %90
%116 = load i32, i32* %6
%117 = call i32 @audioSetAVSync(i32 %116, i32 0)
%118 = load i32, i32* %6
%119 = call i32 @audioSetMute(i32 %118, i32 1)
%120 = load i32, i32* %5
%121 = call i32 @videoFastForward(i32 %120, i32 0)
%122 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %11
br label %135
123: ; preds = %90
%124 = load i32, i32* %6
%125 = call i32 @audioSetAVSync(i32 %124, i32 0)
%126 = load i32, i32* %6
%127 = call i32 @audioSetMute(i32 %126, i32 1)
%128 = load i32, i32* %5
%129 = call i32 @videoSlowMotion(i32 %128, i32 2)
%130 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %11
br label %135
131: ; preds = %90
%132 = load i32, i32* %5
%133 = call i32 @videoContinue(i32 %132)
%134 = call i32 @exit(i32 0)
unreachable
135: ; preds = %90, %123, %115, %105, %101, %97, %93
br label %136
136: ; preds = %135, %83
br label %137
137: ; preds = %136, %58
br label %54
138: ; preds = %54
br label %48
139: ; preds = %48
ret void
}

LLVM IR (-O2):
%struct.pollfd = type { i32, i32, i32 }
@STDIN_FILENO = global i32 0
@POLLIN = global i32 0
@POLLOUT = global i32 0
@VIDEO_SOURCE_MEMORY = global i32 0
@AUDIO_SOURCE_MEMORY = global i32 0
@str = [11 x i8] c"slowmotion\00"
@str.6 = [12 x i8] c"fastforward\00"
@str.7 = [17 x i8] c"playback started\00"
@str.8 = [19 x i8] c"playback continued\00"
@str.9 = [17 x i8] c"playback stopped\00"
@str.10 = [16 x i8] c"playback frozen\00"
define void @play_file_av(i32 %0, i32 %1, i32 %2) {
%4 = alloca [32768 x i8]
%5 = alloca [2 x %struct.pollfd]
%6 = getelementptr inbounds [32768 x i8], [32768 x i8]* %4, i64 0, i64 0
%7 = bitcast [2 x %struct.pollfd]* %5 to i8*
%8 = load i32, i32* @STDIN_FILENO
%9 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %5, i64 0, i64 0
%10 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %5, i64 0, i64 0, i32 0
store i32 %8, i32* %10
%11 = load i32, i32* @POLLIN
%12 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %5, i64 0, i64 0, i32 1
store i32 %11, i32* %12
%13 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %5, i64 0, i64 1, i32 0
store i32 %1, i32* %13
%14 = load i32, i32* @POLLOUT
%15 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %5, i64 0, i64 1, i32 1
store i32 %14, i32* %15
%16 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %5, i64 0, i64 2, i32 0
store i32 %2, i32* %16
%17 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %5, i64 0, i64 2, i32 1
store i32 %14, i32* %17
%18 = load i32, i32* @VIDEO_SOURCE_MEMORY
%19 = tail call i32 @videoSelectSource(i32 %1, i32 %18)
%20 = load i32, i32* @AUDIO_SOURCE_MEMORY
%21 = tail call i32 @audioSelectSource(i32 %2, i32 %20)
%22 = tail call i32 @audioPlay(i32 %2)
%23 = tail call i32 @videoPlay(i32 %1)
%24 = call i32 @read(i32 %0, i8* %6, i32 32768)
%25 = call i64 @write(i32 %1, i8* %6, i32 %24)
%26 = call i32 @read(i32 %0, i8* %6, i32 32768)
%27 = icmp sgt i32 %26, -1
br i1 %27, label %28, label %89
28: ; preds = %3
%29 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %5, i64 0, i64 1, i32 2
%30 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %5, i64 0, i64 0, i32 2
br label %34
31: ; preds = %86, %34
%32 = call i32 @read(i32 %0, i8* %6, i32 32768)
%33 = icmp sgt i32 %32, -1
br i1 %33, label %34, label %89
34: ; preds = %28, %31
%35 = phi i32 [ %26, %28 ], [ %32, %31 ]
%36 = icmp eq i32 %35, 0
br i1 %36, label %31, label %37
37: ; preds = %34, %86
%38 = phi i32 [ %87, %86 ], [ 0, %34 ]
%39 = call i64 @poll(%struct.pollfd* %9, i32 2, i32 1)
%40 = icmp eq i64 %39, 0
br i1 %40, label %86, label %41
41: ; preds = %37
%42 = load i32, i32* %29
%43 = load i32, i32* @POLLOUT
%44 = and i32 %43, %42
%45 = icmp eq i32 %44, 0
br i1 %45, label %53, label %46
46: ; preds = %41
%47 = sext i32 %38 to i64
%48 = getelementptr inbounds [32768 x i8], [32768 x i8]* %4, i64 0, i64 %47
%49 = sub nsw i32 %35, %38
%50 = call i64 @write(i32 %1, i8* %48, i32 %49)
%51 = trunc i64 %50 to i32
%52 = add i32 %38, %51
br label %53
53: ; preds = %46, %41
%54 = phi i32 [ %52, %46 ], [ %38, %41 ]
%55 = load i32, i32* %30
%56 = load i32, i32* @POLLIN
%57 = and i32 %56, %55
%58 = icmp eq i32 %57, 0
br i1 %58, label %86, label %59
59: ; preds = %53
%60 = call i32 (...) @getchar()
switch i32 %60, label %86 [
i32 122, label %61
i32 115, label %63
i32 99, label %65
i32 112, label %67
i32 102, label %72
i32 109, label %76
i32 113, label %80
]
61: ; preds = %59
%62 = call i32 @videoFreeze(i32 %1)
br label %83
63: ; preds = %59
%64 = call i32 @videoStop(i32 %1)
br label %83
65: ; preds = %59
%66 = call i32 @videoContinue(i32 %1)
br label %83
67: ; preds = %59
%68 = call i32 @videoPlay(i32 %1)
%69 = call i32 @audioPlay(i32 %2)
%70 = call i32 @audioSetAVSync(i32 %2, i32 1)
%71 = call i32 @audioSetMute(i32 %2, i32 0)
br label %83
72: ; preds = %59
%73 = call i32 @audioSetAVSync(i32 %2, i32 0)
%74 = call i32 @audioSetMute(i32 %2, i32 1)
%75 = call i32 @videoFastForward(i32 %1, i32 0)
br label %83
76: ; preds = %59
%77 = call i32 @audioSetAVSync(i32 %2, i32 0)
%78 = call i32 @audioSetMute(i32 %2, i32 1)
%79 = call i32 @videoSlowMotion(i32 %1, i32 2)
br label %83
80: ; preds = %59
%81 = call i32 @videoContinue(i32 %1)
%82 = call i32 @exit(i32 0)
unreachable
83: ; preds = %76, %72, %67, %65, %63, %61
%84 = phi i8* [ getelementptr inbounds ([16 x i8], [16 x i8]* @str.10, i64 0, i64 0), %61 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @str.9, i64 0, i64 0), %63 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @str.8, i64 0, i64 0), %65 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @str.7, i64 0, i64 0), %67 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @str.6, i64 0, i64 0), %72 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0), %76 ]
%85 = call i32 @puts(i8* dereferenceable(1) %84)
br label %86
86: ; preds = %83, %59, %53, %37
%87 = phi i32 [ %54, %53 ], [ %38, %37 ], [ %54, %59 ], [ %54, %83 ]
%88 = icmp sgt i32 %35, %87
br i1 %88, label %37, label %31
89: ; preds = %31, %3
ret void
}