#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 *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,-0x88(%rbp)
cmpq   $0x0,-0x88(%rbp)
je     11ba <divide_media_token+0x7a>
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
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,-0x88(%rbp)
cmpq   $0x0,-0x88(%rbp)
je     11ff <divide_media_token+0xbf>
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     122c <divide_media_token+0xec>
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     1259 <divide_media_token+0x119>
mov    -0x88(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x80(%rbp),%rax
mov    %rax,-0x88(%rbp)
movl   $0x0,-0x94(%rbp)
cmpl   $0x5,-0x94(%rbp)
jge    131a <divide_media_token+0x1da>
mov    -0x88(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1293 <divide_media_token+0x153>
jmp    131a <divide_media_token+0x1da>
mov    -0x88(%rbp),%rdi
mov    $0x2c,%esi
call   1050 <strchr@plt>
mov    %rax,-0x90(%rbp)
cmpq   $0x0,-0x90(%rbp)
je     12c3 <divide_media_token+0x183>
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
call   1030 <strcpy@plt>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
cmpq   $0x0,-0x90(%rbp)
jne    1303 <divide_media_token+0x1c3>
jmp    131a <divide_media_token+0x1da>
mov    -0x90(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x88(%rbp)
jmp    126e <divide_media_token+0x12e>
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   %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 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 %21
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 @strcpy(i8* %15, i8* %19)
br label %22
21: ; preds = %2
store i32 0, i32* %3
br label %82
22: ; preds = %14
%23 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 99
store i8 0, i8* %23
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 98
store i8 0, i8* %24
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 97
store i8 0, i8* %25
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%27 = call i8* @strchr(i8* %26, i8 signext 32)
store i8* %27, i8** %7
%28 = load i8*, i8** %7
%29 = icmp ne i8* %28, null
br i1 %29, label %30, label %32
30: ; preds = %22
%31 = load i8*, i8** %7
store i8 0, i8* %31
br label %32
32: ; preds = %30, %22
%33 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%34 = call i8* @strchr(i8* %33, i8 signext 9)
store i8* %34, i8** %7
%35 = load i8*, i8** %7
%36 = icmp ne i8* %35, null
br i1 %36, label %37, label %39
37: ; preds = %32
%38 = load i8*, i8** %7
store i8 0, i8* %38
br label %39
39: ; preds = %37, %32
%40 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%41 = call i8* @strchr(i8* %40, i8 signext 10)
store i8* %41, i8** %7
%42 = load i8*, i8** %7
%43 = icmp ne i8* %42, null
br i1 %43, label %44, label %46
44: ; preds = %39
%45 = load i8*, i8** %7
store i8 0, i8* %45
br label %46
46: ; preds = %44, %39
%47 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
store i8* %47, i8** %7
store i32 0, i32* %9
br label %48
48: ; preds = %77, %46
%49 = load i32, i32* %9
%50 = icmp slt i32 %49, 5
br i1 %50, label %51, label %80
51: ; preds = %48
%52 = load i8*, i8** %7
%53 = load i8, i8* %52
%54 = sext i8 %53 to i32
%55 = icmp eq i32 %54, 0
br i1 %55, label %56, label %57
56: ; preds = %51
br label %80
57: ; preds = %51
%58 = load i8*, i8** %7
%59 = call i8* @strchr(i8* %58, i8 signext 44)
store i8* %59, i8** %8
%60 = load i8*, i8** %8
%61 = icmp ne i8* %60, null
br i1 %61, label %62, label %64
62: ; preds = %57
%63 = load i8*, i8** %8
store i8 0, i8* %63
br label %64
64: ; preds = %62, %57
%65 = load [30 x i8]*, [30 x i8]** %5
%66 = load i32, i32* %9
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds [30 x i8], [30 x i8]* %65, i64 %67
%69 = getelementptr inbounds [30 x i8], [30 x i8]* %68, i64 0, i64 0
%70 = load i8*, i8** %7
%71 = call i32 @strcpy(i8* %69, i8* %70)
%72 = load i32, i32* %9
%73 = add nsw i32 %72, 1
store i32 %73, i32* %9
%74 = load i8*, i8** %8
%75 = icmp eq i8* %74, null
br i1 %75, label %76, label %77
76: ; preds = %64
br label %80
77: ; preds = %64
%78 = load i8*, i8** %8
%79 = getelementptr inbounds i8, i8* %78, i64 1
store i8* %79, i8** %7
br label %48
80: ; preds = %76, %56, %48
%81 = load i32, i32* %9
store i32 %81, i32* %3
br label %82
82: ; preds = %80, %21
%83 = load i32, i32* %3
ret i32 %83
}

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
}