#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 /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *strstr(char *, char *);
int divide_media_token(char *input, char output[5][30]) {
  char media_command[100];
  char *media, *p, *pp;
  int i;
  p = strstr(input, "media=");
  if (p) {
    strcpy(media_command, p + strlen("media="));
  } 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;
    strcpy(output[i], p);
    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,-0x90(%rbp)
cmpq   $0x0,-0x90(%rbp)
je     11ba <divide_media_token+0x7a>
lea    -0x80(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x90(%rbp),%rax
mov    %rax,-0xb0(%rbp)
lea    0xe68(%rip),%rdi
call   1040 <strlen@plt>
mov    -0xb0(%rbp),%rsi
mov    -0xa8(%rbp),%rdi
cltq
add    %rax,%rsi
call   1030 <strcpy@plt>
jmp    11c6 <divide_media_token+0x86>
movl   $0x0,-0x4(%rbp)
jmp    1323 <divide_media_token+0x1e3>
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,-0x90(%rbp)
cmpq   $0x0,-0x90(%rbp)
je     11ff <divide_media_token+0xbf>
mov    -0x90(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x80(%rbp),%rdi
mov    $0x9,%esi
call   1050 <strchr@plt>
mov    %rax,-0x90(%rbp)
cmpq   $0x0,-0x90(%rbp)
je     122c <divide_media_token+0xec>
mov    -0x90(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x80(%rbp),%rdi
mov    $0xa,%esi
call   1050 <strchr@plt>
mov    %rax,-0x90(%rbp)
cmpq   $0x0,-0x90(%rbp)
je     1259 <divide_media_token+0x119>
mov    -0x90(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x80(%rbp),%rax
mov    %rax,-0x90(%rbp)
movl   $0x0,-0x9c(%rbp)
cmpl   $0x5,-0x9c(%rbp)
jge    131a <divide_media_token+0x1da>
mov    -0x90(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1293 <divide_media_token+0x153>
jmp    131a <divide_media_token+0x1da>
mov    -0x90(%rbp),%rdi
mov    $0x2c,%esi
call   1050 <strchr@plt>
mov    %rax,-0x98(%rbp)
cmpq   $0x0,-0x98(%rbp)
je     12c3 <divide_media_token+0x183>
mov    -0x98(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rdi
movslq -0x9c(%rbp),%rax
imul   $0x1e,%rax,%rax
add    %rax,%rdi
mov    -0x90(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x9c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x9c(%rbp)
cmpq   $0x0,-0x98(%rbp)
jne    1303 <divide_media_token+0x1c3>
jmp    131a <divide_media_token+0x1da>
mov    -0x98(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x90(%rbp)
jmp    126e <divide_media_token+0x12e>
mov    -0x9c(%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   %r12
push   %rbx
sub    $0x70,%rsp
mov    %rsi,%r14
lea    0xeaa(%rip),%rsi
call   1060 <strstr@plt>
xor    %r12d,%r12d
test   %rax,%rax
je     1349 <divide_media_token+0x209>
mov    %rax,%rbx
lea    0xe8f(%rip),%rdi
call   1040 <strlen@plt>
cltq
add    %rax,%rbx
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
movb   $0x0,0x63(%rsp)
movw   $0x0,0x61(%rsp)
mov    %rbp,%rdi
mov    $0x20,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     11aa <divide_media_token+0x6a>
movb   $0x0,(%rax)
mov    %rsp,%rdi
mov    $0x9,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     11bf <divide_media_token+0x7f>
movb   $0x0,(%rax)
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0xa,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     11d7 <divide_media_token+0x97>
movb   $0x0,(%rax)
cmpb   $0x0,(%rsp)
je     1349 <divide_media_token+0x209>
mov    %r15,%rdi
mov    $0x2c,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     12de <divide_media_token+0x19e>
mov    %rax,%rbx
movb   $0x0,(%rax)
mov    %rsp,%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
cmpb   $0x0,0x1(%rbx)
je     12e3 <divide_media_token+0x1a3>
add    $0x1,%rbx
mov    %rbx,%rdi
mov    $0x2c,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     12eb <divide_media_token+0x1ab>
mov    %rax,%r15
movb   $0x0,(%rax)
lea    0x1e(%r14),%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
cmpb   $0x0,0x1(%r15)
je     12f6 <divide_media_token+0x1b6>
add    $0x1,%r15
mov    %r15,%rdi
mov    $0x2c,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     12fe <divide_media_token+0x1be>
mov    %rax,%rbx
movb   $0x0,(%rax)
lea    0x3c(%r14),%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
cmpb   $0x0,0x1(%rbx)
je     1306 <divide_media_token+0x1c6>
add    $0x1,%rbx
mov    %rbx,%rdi
mov    $0x2c,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     130e <divide_media_token+0x1ce>
mov    %rax,%r15
movb   $0x0,(%rax)
lea    0x5a(%r14),%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
cmpb   $0x0,0x1(%r15)
je     1319 <divide_media_token+0x1d9>
add    $0x1,%r15
mov    %r15,%rdi
mov    $0x2c,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     1321 <divide_media_token+0x1e1>
movb   $0x0,(%rax)
add    $0x78,%r14
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
mov    $0x5,%r12d
jmp    1349 <divide_media_token+0x209>
xor    %r12d,%r12d
jmp    1327 <divide_media_token+0x1e7>
mov    $0x1,%r12d
jmp    1349 <divide_media_token+0x209>
mov    $0x1,%r12d
mov    %rbx,%r15
jmp    1327 <divide_media_token+0x1e7>
mov    $0x2,%r12d
jmp    1349 <divide_media_token+0x209>
mov    $0x2,%r12d
jmp    1327 <divide_media_token+0x1e7>
mov    $0x3,%r12d
jmp    1349 <divide_media_token+0x209>
mov    $0x3,%r12d
mov    %rbx,%r15
jmp    1327 <divide_media_token+0x1e7>
mov    $0x4,%r12d
jmp    1349 <divide_media_token+0x209>
mov    $0x4,%r12d
mov    %r12d,%eax
mov    %rax,%rcx
shl    $0x5,%rcx
sub    %rax,%rcx
sub    %rax,%rcx
add    %rcx,%r14
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
add    $0x1,%r12d
mov    %r12d,%eax
add    $0x70,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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 i8*
%10 = alloca i32
store i8* %0, i8** %4
store [30 x i8]* %1, [30 x i8]** %5
%11 = load i8*, i8** %4
%12 = call i8* @strstr(i8* %11, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i8* %12, i8** %8
%13 = load i8*, i8** %8
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %22
15: ; preds = %2
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%17 = load i8*, i8** %8
%18 = call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = call i32 @strcpy(i8* %16, i8* %20)
br label %23
22: ; preds = %2
store i32 0, i32* %3
br label %83
23: ; preds = %15
%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** %8
%29 = load i8*, i8** %8
%30 = icmp ne i8* %29, null
br i1 %30, label %31, label %33
31: ; preds = %23
%32 = load i8*, i8** %8
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** %8
%36 = load i8*, i8** %8
%37 = icmp ne i8* %36, null
br i1 %37, label %38, label %40
38: ; preds = %33
%39 = load i8*, i8** %8
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** %8
%43 = load i8*, i8** %8
%44 = icmp ne i8* %43, null
br i1 %44, label %45, label %47
45: ; preds = %40
%46 = load i8*, i8** %8
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** %8
store i32 0, i32* %10
br label %49
49: ; preds = %78, %47
%50 = load i32, i32* %10
%51 = icmp slt i32 %50, 5
br i1 %51, label %52, label %81
52: ; preds = %49
%53 = load i8*, i8** %8
%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 %81
58: ; preds = %52
%59 = load i8*, i8** %8
%60 = call i8* @strchr(i8* %59, i8 signext 44)
store i8* %60, i8** %9
%61 = load i8*, i8** %9
%62 = icmp ne i8* %61, null
br i1 %62, label %63, label %65
63: ; preds = %58
%64 = load i8*, i8** %9
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* %10
%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** %8
%72 = call i32 @strcpy(i8* %70, i8* %71)
%73 = load i32, i32* %10
%74 = add nsw i32 %73, 1
store i32 %74, i32* %10
%75 = load i8*, i8** %9
%76 = icmp eq i8* %75, null
br i1 %76, label %77, label %78
77: ; preds = %65
br label %81
78: ; preds = %65
%79 = load i8*, i8** %9
%80 = getelementptr inbounds i8, i8* %79, i64 1
store i8* %80, i8** %8
br label %49
81: ; preds = %77, %57, %49
%82 = load i32, i32* %10
store i32 %82, i32* %3
br label %83
83: ; preds = %81, %22
%84 = load i32, i32* %3
ret i32 %84
}

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 %78, 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 @strcpy(i8* %4, i8* %10)
%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 %78, label %29
29: ; preds = %26
%30 = call i8* @strchr(i8* %4, i8 signext 44)
%31 = icmp eq i8* %30, null
br i1 %31, label %32, label %39
32: ; preds = %72, %63, %54, %45, %29
%33 = phi i32 [ 0, %29 ], [ 1, %45 ], [ 2, %54 ], [ 3, %63 ], [ 4, %72 ]
%34 = phi i8* [ %4, %29 ], [ %42, %45 ], [ %51, %54 ], [ %60, %63 ], [ %69, %72 ]
%35 = zext i32 %33 to i64
%36 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 %35, i64 0
%37 = call i32 @strcpy(i8* %36, i8* %34)
%38 = add nuw nsw i32 %33, 1
br label %78
39: ; preds = %29
store i8 0, i8* %30
%40 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 0
%41 = call i32 @strcpy(i8* %40, i8* %4)
%42 = getelementptr inbounds i8, i8* %30, i64 1
%43 = load i8, i8* %42
%44 = icmp eq i8 %43, 0
br i1 %44, label %78, label %45
45: ; preds = %39
%46 = call i8* @strchr(i8* %42, i8 signext 44)
%47 = icmp eq i8* %46, null
br i1 %47, label %32, label %48
48: ; preds = %45
store i8 0, i8* %46
%49 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 1, i64 0
%50 = call i32 @strcpy(i8* %49, i8* %42)
%51 = getelementptr inbounds i8, i8* %46, i64 1
%52 = load i8, i8* %51
%53 = icmp eq i8 %52, 0
br i1 %53, label %78, label %54
54: ; preds = %48
%55 = call i8* @strchr(i8* %51, i8 signext 44)
%56 = icmp eq i8* %55, null
br i1 %56, label %32, label %57
57: ; preds = %54
store i8 0, i8* %55
%58 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 2, i64 0
%59 = call i32 @strcpy(i8* %58, i8* %51)
%60 = getelementptr inbounds i8, i8* %55, i64 1
%61 = load i8, i8* %60
%62 = icmp eq i8 %61, 0
br i1 %62, label %78, label %63
63: ; preds = %57
%64 = call i8* @strchr(i8* %60, i8 signext 44)
%65 = icmp eq i8* %64, null
br i1 %65, label %32, label %66
66: ; preds = %63
store i8 0, i8* %64
%67 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 3, i64 0
%68 = call i32 @strcpy(i8* %67, i8* %60)
%69 = getelementptr inbounds i8, i8* %64, i64 1
%70 = load i8, i8* %69
%71 = icmp eq i8 %70, 0
br i1 %71, label %78, label %72
72: ; preds = %66
%73 = call i8* @strchr(i8* %69, i8 signext 44)
%74 = icmp eq i8* %73, null
br i1 %74, label %32, label %75
75: ; preds = %72
store i8 0, i8* %73
%76 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 4, i64 0
%77 = call i32 @strcpy(i8* %76, i8* %69)
br label %78
78: ; preds = %26, %39, %48, %57, %66, %75, %32, %2
%79 = phi i32 [ 0, %2 ], [ %38, %32 ], [ 0, %26 ], [ 1, %39 ], [ 2, %48 ], [ 3, %57 ], [ 4, %66 ], [ 5, %75 ]
ret i32 %79
}