#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*/ media_command;

/* Variables and functions */
char *strchr(char *, char);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *strstr(char *, char *);
int divide_media_token(char *input, char output[5][30]) {
  char media_command[100];
  char *p, *pp;
  int i;
  p = strstr(input, "media=");
  if (p) {
    {
      strncpy(media_command, p + strlen("media="), sizeof(media_command));
      media_command[sizeof(media_command) - 1] = 0;
    };
  } else {
    return 0;
  }
  media_command[sizeof(media_command) - 1] = 0;
  media_command[sizeof(media_command) - 2] = 0;
  media_command[sizeof(media_command) - 3] = 0;
  p = strchr(media_command, ' ');
  if (p)
    *p = 0;
  p = strchr(media_command, '\t');
  if (p)
    *p = 0;
  p = strchr(media_command, '\n');
  if (p)
    *p = 0;
  p = media_command;
  for (i = 0; i < 5;) {
    if (*p == 0)
      break;
    pp = strchr(p, ',');
    if (pp)
      *pp = 0;
    {
      strncpy(output[i], p, 30);
      output[i][30 - 1] = 0;
    };
    i++;
    if (pp == NULL)
      break;
    p = pp + 1;
  }
  return i;
}


x86 assembly (clang, -O0):
<divide_media_token>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea2(%rip),%rsi
call   1060 <strstr@plt>
mov    %rax,-0x88(%rbp)
cmpq   $0x0,-0x88(%rbp)
je     11c3 <divide_media_token+0x83>
lea    -0x80(%rbp),%rax
mov    %rax,-0xa0(%rbp)
mov    -0x88(%rbp),%rax
mov    %rax,-0xa8(%rbp)
lea    0xe68(%rip),%rdi
call   1040 <strlen@plt>
mov    -0xa8(%rbp),%rsi
mov    -0xa0(%rbp),%rdi
cltq
add    %rax,%rsi
mov    $0x64,%edx
call   1030 <strncpy@plt>
movb   $0x0,-0x1d(%rbp)
jmp    11cf <divide_media_token+0x8f>
movl   $0x0,-0x4(%rbp)
jmp    1347 <divide_media_token+0x207>
movb   $0x0,-0x1d(%rbp)
movb   $0x0,-0x1e(%rbp)
movb   $0x0,-0x1f(%rbp)
lea    -0x80(%rbp),%rdi
mov    $0x20,%esi
call   1050 <strchr@plt>
mov    %rax,-0x88(%rbp)
cmpq   $0x0,-0x88(%rbp)
je     1208 <divide_media_token+0xc8>
mov    -0x88(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x80(%rbp),%rdi
mov    $0x9,%esi
call   1050 <strchr@plt>
mov    %rax,-0x88(%rbp)
cmpq   $0x0,-0x88(%rbp)
je     1235 <divide_media_token+0xf5>
mov    -0x88(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x80(%rbp),%rdi
mov    $0xa,%esi
call   1050 <strchr@plt>
mov    %rax,-0x88(%rbp)
cmpq   $0x0,-0x88(%rbp)
je     1262 <divide_media_token+0x122>
mov    -0x88(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x80(%rbp),%rax
mov    %rax,-0x88(%rbp)
movl   $0x0,-0x94(%rbp)
cmpl   $0x5,-0x94(%rbp)
jge    133e <divide_media_token+0x1fe>
mov    -0x88(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    129c <divide_media_token+0x15c>
jmp    133e <divide_media_token+0x1fe>
mov    -0x88(%rbp),%rdi
mov    $0x2c,%esi
call   1050 <strchr@plt>
mov    %rax,-0x90(%rbp)
cmpq   $0x0,-0x90(%rbp)
je     12cc <divide_media_token+0x18c>
mov    -0x90(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rdi
movslq -0x94(%rbp),%rax
imul   $0x1e,%rax,%rax
add    %rax,%rdi
mov    -0x88(%rbp),%rsi
mov    $0x1e,%edx
call   1030 <strncpy@plt>
mov    -0x18(%rbp),%rax
movslq -0x94(%rbp),%rcx
imul   $0x1e,%rcx,%rcx
add    %rcx,%rax
movb   $0x0,0x1d(%rax)
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
cmpq   $0x0,-0x90(%rbp)
jne    1327 <divide_media_token+0x1e7>
jmp    133e <divide_media_token+0x1fe>
mov    -0x90(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x88(%rbp)
jmp    1277 <divide_media_token+0x137>
mov    -0x94(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<divide_media_token>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x68,%rsp
mov    %rsi,%r14
lea    0xeac(%rip),%rsi
call   1060 <strstr@plt>
xor    %r15d,%r15d
test   %rax,%rax
je     13b3 <divide_media_token+0x273>
mov    %rax,%rbx
lea    0xe91(%rip),%rdi
call   1040 <strlen@plt>
cltq
add    %rax,%rbx
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    $0x64,%edx
call   1030 <strncpy@plt>
movb   $0x0,0x63(%rsp)
movw   $0x0,0x61(%rsp)
mov    %rbp,%rdi
mov    $0x20,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     11ad <divide_media_token+0x6d>
movb   $0x0,(%rax)
mov    %rsp,%rdi
mov    $0x9,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     11c2 <divide_media_token+0x82>
movb   $0x0,(%rax)
mov    %rsp,%rdi
mov    $0xa,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     11d7 <divide_media_token+0x97>
movb   $0x0,(%rax)
cmpb   $0x0,(%rsp)
je     13b3 <divide_media_token+0x273>
mov    %rsp,%rdi
mov    $0x2c,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     1316 <divide_media_token+0x1d6>
mov    %rax,%rbp
movb   $0x0,(%rax)
mov    %rsp,%rsi
mov    %r14,%rdi
mov    $0x1e,%edx
call   1030 <strncpy@plt>
movb   $0x0,0x1d(%r14)
cmpb   $0x0,0x1(%rbp)
je     1330 <divide_media_token+0x1f0>
add    $0x1,%rbp
mov    %rbp,%rdi
mov    $0x2c,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     1338 <divide_media_token+0x1f8>
mov    %rax,%rbx
movb   $0x0,(%rax)
lea    0x1e(%r14),%rdi
mov    %rbp,%rsi
mov    $0x1e,%edx
call   1030 <strncpy@plt>
movb   $0x0,0x3b(%r14)
cmpb   $0x0,0x1(%rbx)
je     1356 <divide_media_token+0x216>
add    $0x1,%rbx
mov    %rbx,%rdi
mov    $0x2c,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     135e <divide_media_token+0x21e>
mov    %rax,%rbp
movb   $0x0,(%rax)
lea    0x3c(%r14),%rdi
mov    %rbx,%rsi
mov    $0x1e,%edx
call   1030 <strncpy@plt>
movb   $0x0,0x59(%r14)
cmpb   $0x0,0x1(%rbp)
je     137c <divide_media_token+0x23c>
add    $0x1,%rbp
mov    %rbp,%rdi
mov    $0x2c,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     1384 <divide_media_token+0x244>
mov    %rax,%rbx
movb   $0x0,(%rax)
lea    0x5a(%r14),%rdi
mov    %rbp,%rsi
mov    $0x1e,%edx
call   1030 <strncpy@plt>
movb   $0x0,0x77(%r14)
cmpb   $0x0,0x1(%rbx)
je     13c1 <divide_media_token+0x281>
add    $0x1,%rbx
mov    %rbx,%rdi
mov    $0x2c,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     12f5 <divide_media_token+0x1b5>
movb   $0x0,(%rax)
lea    0x78(%r14),%rdi
mov    %rbx,%rsi
mov    $0x1e,%edx
call   1030 <strncpy@plt>
mov    $0x5,%r15d
mov    $0x4,%eax
jmp    13a0 <divide_media_token+0x260>
mov    %rsp,%rsi
mov    %r14,%rdi
mov    $0x1e,%edx
call   1030 <strncpy@plt>
mov    $0x1,%r15d
xor    %eax,%eax
jmp    13a0 <divide_media_token+0x260>
mov    $0x1,%r15d
jmp    13b3 <divide_media_token+0x273>
lea    0x1e(%r14),%rdi
mov    %rbp,%rsi
mov    $0x1e,%edx
call   1030 <strncpy@plt>
mov    $0x2,%r15d
mov    $0x1,%eax
jmp    13a0 <divide_media_token+0x260>
mov    $0x2,%r15d
jmp    13b3 <divide_media_token+0x273>
lea    0x3c(%r14),%rdi
mov    %rbx,%rsi
mov    $0x1e,%edx
call   1030 <strncpy@plt>
mov    $0x3,%r15d
mov    $0x2,%eax
jmp    13a0 <divide_media_token+0x260>
mov    $0x3,%r15d
jmp    13b3 <divide_media_token+0x273>
lea    0x5a(%r14),%rdi
mov    %rbp,%rsi
mov    $0x1e,%edx
call   1030 <strncpy@plt>
mov    $0x4,%r15d
mov    $0x3,%eax
mov    %rax,%rcx
shl    $0x5,%rcx
sub    %rax,%rcx
sub    %rax,%rcx
movb   $0x0,0x1d(%r14,%rcx,1)
mov    %r15d,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x4,%r15d
jmp    13b3 <divide_media_token+0x273>

LLVM IR (-O0):
@.str = [7 x i8] c"media=\00"
define i32 @divide_media_token(i8* %0, [30 x i8]* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca [30 x i8]*
%6 = alloca [100 x i8]
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
store i8* %0, i8** %4
store [30 x i8]* %1, [30 x i8]** %5
%10 = load i8*, i8** %4
%11 = call i8* @strstr(i8* %10, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i8* %11, i8** %7
%12 = load i8*, i8** %7
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %22
14: ; preds = %2
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%16 = load i8*, i8** %7
%17 = call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = call i32 @strncpy(i8* %15, i8* %19, i32 100)
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 99
store i8 0, i8* %21
br label %23
22: ; preds = %2
store i32 0, i32* %3
br label %88
23: ; preds = %14
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 99
store i8 0, i8* %24
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 98
store i8 0, i8* %25
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 97
store i8 0, i8* %26
%27 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%28 = call i8* @strchr(i8* %27, i8 signext 32)
store i8* %28, i8** %7
%29 = load i8*, i8** %7
%30 = icmp ne i8* %29, null
br i1 %30, label %31, label %33
31: ; preds = %23
%32 = load i8*, i8** %7
store i8 0, i8* %32
br label %33
33: ; preds = %31, %23
%34 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%35 = call i8* @strchr(i8* %34, i8 signext 9)
store i8* %35, i8** %7
%36 = load i8*, i8** %7
%37 = icmp ne i8* %36, null
br i1 %37, label %38, label %40
38: ; preds = %33
%39 = load i8*, i8** %7
store i8 0, i8* %39
br label %40
40: ; preds = %38, %33
%41 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%42 = call i8* @strchr(i8* %41, i8 signext 10)
store i8* %42, i8** %7
%43 = load i8*, i8** %7
%44 = icmp ne i8* %43, null
br i1 %44, label %45, label %47
45: ; preds = %40
%46 = load i8*, i8** %7
store i8 0, i8* %46
br label %47
47: ; preds = %45, %40
%48 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
store i8* %48, i8** %7
store i32 0, i32* %9
br label %49
49: ; preds = %83, %47
%50 = load i32, i32* %9
%51 = icmp slt i32 %50, 5
br i1 %51, label %52, label %86
52: ; preds = %49
%53 = load i8*, i8** %7
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = icmp eq i32 %55, 0
br i1 %56, label %57, label %58
57: ; preds = %52
br label %86
58: ; preds = %52
%59 = load i8*, i8** %7
%60 = call i8* @strchr(i8* %59, i8 signext 44)
store i8* %60, i8** %8
%61 = load i8*, i8** %8
%62 = icmp ne i8* %61, null
br i1 %62, label %63, label %65
63: ; preds = %58
%64 = load i8*, i8** %8
store i8 0, i8* %64
br label %65
65: ; preds = %63, %58
%66 = load [30 x i8]*, [30 x i8]** %5
%67 = load i32, i32* %9
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [30 x i8], [30 x i8]* %66, i64 %68
%70 = getelementptr inbounds [30 x i8], [30 x i8]* %69, i64 0, i64 0
%71 = load i8*, i8** %7
%72 = call i32 @strncpy(i8* %70, i8* %71, i32 30)
%73 = load [30 x i8]*, [30 x i8]** %5
%74 = load i32, i32* %9
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds [30 x i8], [30 x i8]* %73, i64 %75
%77 = getelementptr inbounds [30 x i8], [30 x i8]* %76, i64 0, i64 29
store i8 0, i8* %77
%78 = load i32, i32* %9
%79 = add nsw i32 %78, 1
store i32 %79, i32* %9
%80 = load i8*, i8** %8
%81 = icmp eq i8* %80, null
br i1 %81, label %82, label %83
82: ; preds = %65
br label %86
83: ; preds = %65
%84 = load i8*, i8** %8
%85 = getelementptr inbounds i8, i8* %84, i64 1
store i8* %85, i8** %7
br label %49
86: ; preds = %82, %57, %49
%87 = load i32, i32* %9
store i32 %87, i32* %3
br label %88
88: ; preds = %86, %22
%89 = load i32, i32* %3
ret i32 %89
}

LLVM IR (-O2):
@.str = [7 x i8] c"media=\00"
define i32 @divide_media_token(i8* %0, [30 x i8]* %1) {
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%5 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i8* %5, null
br i1 %6, label %94, label %7
7: ; preds = %2
%8 = tail call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %5, i64 %9
%11 = call i32 @strncpy(i8* %4, i8* %10, i32 100)
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 99
store i8 0, i8* %12
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 98
store i8 0, i8* %13
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 97
store i8 0, i8* %14
%15 = call i8* @strchr(i8* %4, i8 signext 32)
%16 = icmp eq i8* %15, null
br i1 %16, label %18, label %17
17: ; preds = %7
store i8 0, i8* %15
br label %18
18: ; preds = %17, %7
%19 = call i8* @strchr(i8* %4, i8 signext 9)
%20 = icmp eq i8* %19, null
br i1 %20, label %22, label %21
21: ; preds = %18
store i8 0, i8* %19
br label %22
22: ; preds = %21, %18
%23 = call i8* @strchr(i8* %4, i8 signext 10)
%24 = icmp eq i8* %23, null
br i1 %24, label %26, label %25
25: ; preds = %22
store i8 0, i8* %23
br label %26
26: ; preds = %25, %22
%27 = load i8, i8* %4
%28 = icmp eq i8 %27, 0
br i1 %28, label %94, label %84
29: ; preds = %84
store i8 0, i8* %85
%30 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 0
%31 = call i32 @strncpy(i8* %30, i8* %4, i32 30)
%32 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 29
store i8 0, i8* %32
%33 = getelementptr inbounds i8, i8* %85, i64 1
%34 = load i8, i8* %33
%35 = icmp eq i8 %34, 0
br i1 %35, label %94, label %36
36: ; preds = %29
%37 = call i8* @strchr(i8* %33, i8 signext 44)
%38 = icmp eq i8* %37, null
br i1 %38, label %39, label %42
39: ; preds = %36
%40 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 1, i64 0
%41 = call i32 @strncpy(i8* %40, i8* %33, i32 30)
br label %90
42: ; preds = %36
store i8 0, i8* %37
%43 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 1, i64 0
%44 = call i32 @strncpy(i8* %43, i8* %33, i32 30)
%45 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 1, i64 29
store i8 0, i8* %45
%46 = getelementptr inbounds i8, i8* %37, i64 1
%47 = load i8, i8* %46
%48 = icmp eq i8 %47, 0
br i1 %48, label %94, label %49
49: ; preds = %42
%50 = call i8* @strchr(i8* %46, i8 signext 44)
%51 = icmp eq i8* %50, null
br i1 %51, label %52, label %55
52: ; preds = %49
%53 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 2, i64 0
%54 = call i32 @strncpy(i8* %53, i8* %46, i32 30)
br label %90
55: ; preds = %49
store i8 0, i8* %50
%56 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 2, i64 0
%57 = call i32 @strncpy(i8* %56, i8* %46, i32 30)
%58 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 2, i64 29
store i8 0, i8* %58
%59 = getelementptr inbounds i8, i8* %50, i64 1
%60 = load i8, i8* %59
%61 = icmp eq i8 %60, 0
br i1 %61, label %94, label %62
62: ; preds = %55
%63 = call i8* @strchr(i8* %59, i8 signext 44)
%64 = icmp eq i8* %63, null
br i1 %64, label %65, label %68
65: ; preds = %62
%66 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 3, i64 0
%67 = call i32 @strncpy(i8* %66, i8* %59, i32 30)
br label %90
68: ; preds = %62
store i8 0, i8* %63
%69 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 3, i64 0
%70 = call i32 @strncpy(i8* %69, i8* %59, i32 30)
%71 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 3, i64 29
store i8 0, i8* %71
%72 = getelementptr inbounds i8, i8* %63, i64 1
%73 = load i8, i8* %72
%74 = icmp eq i8 %73, 0
br i1 %74, label %94, label %75
75: ; preds = %68
%76 = call i8* @strchr(i8* %72, i8 signext 44)
%77 = icmp eq i8* %76, null
br i1 %77, label %78, label %81
78: ; preds = %75
%79 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 4, i64 0
%80 = call i32 @strncpy(i8* %79, i8* %72, i32 30)
br label %90
81: ; preds = %75
store i8 0, i8* %76
%82 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 4, i64 0
%83 = call i32 @strncpy(i8* %82, i8* %72, i32 30)
br label %90
84: ; preds = %26
%85 = call i8* @strchr(i8* %4, i8 signext 44)
%86 = icmp eq i8* %85, null
br i1 %86, label %87, label %29
87: ; preds = %84
%88 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 0
%89 = call i32 @strncpy(i8* %88, i8* %4, i32 30)
br label %90
90: ; preds = %87, %78, %65, %52, %39, %81
%91 = phi i64 [ 4, %81 ], [ 1, %39 ], [ 2, %52 ], [ 3, %65 ], [ 4, %78 ], [ 0, %87 ]
%92 = phi i32 [ 5, %81 ], [ 2, %39 ], [ 3, %52 ], [ 4, %65 ], [ 5, %78 ], [ 1, %87 ]
%93 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 %91, i64 29
store i8 0, i8* %93
br label %94
94: ; preds = %90, %26, %29, %42, %55, %68, %2
%95 = phi i32 [ 0, %2 ], [ 0, %26 ], [ 1, %29 ], [ 2, %42 ], [ 3, %55 ], [ 4, %68 ], [ %92, %90 ]
ret i32 %95
}