#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;
  if ((p = strstr(input, "media=")) != NULL) {
    strcpy(media_command, p + strlen("media="));
  } else if ((p = strstr(input, "PageSize=")) != NULL) {
    strcpy(media_command, p + strlen("PageSize="));
  } 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    $0xc0,%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)
cmp    $0x0,%rax
je     11b6 <divide_media_token+0x76>
lea    -0x80(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x90(%rbp),%rax
mov    %rax,-0xb0(%rbp)
lea    0xe6c(%rip),%rdi
call   1040 <strlen@plt>
mov    -0xb0(%rbp),%rsi
mov    -0xa8(%rbp),%rdi
cltq
add    %rax,%rsi
call   1030 <strcpy@plt>
jmp    122a <divide_media_token+0xea>
mov    -0x10(%rbp),%rdi
lea    0xe46(%rip),%rsi
call   1060 <strstr@plt>
mov    %rax,-0x90(%rbp)
cmp    $0x0,%rax
je     1219 <divide_media_token+0xd9>
lea    -0x80(%rbp),%rax
mov    %rax,-0xb8(%rbp)
mov    -0x90(%rbp),%rax
mov    %rax,-0xc0(%rbp)
lea    0xe10(%rip),%rdi
call   1040 <strlen@plt>
mov    -0xc0(%rbp),%rsi
mov    -0xb8(%rbp),%rdi
cltq
add    %rax,%rsi
call   1030 <strcpy@plt>
jmp    1225 <divide_media_token+0xe5>
movl   $0x0,-0x4(%rbp)
jmp    1387 <divide_media_token+0x247>
jmp    122a <divide_media_token+0xea>
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     1263 <divide_media_token+0x123>
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     1290 <divide_media_token+0x150>
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     12bd <divide_media_token+0x17d>
mov    -0x90(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x80(%rbp),%rax
mov    %rax,-0x90(%rbp)
movl   $0x0,-0x9c(%rbp)
cmpl   $0x5,-0x9c(%rbp)
jge    137e <divide_media_token+0x23e>
mov    -0x90(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    12f7 <divide_media_token+0x1b7>
jmp    137e <divide_media_token+0x23e>
mov    -0x90(%rbp),%rdi
mov    $0x2c,%esi
call   1050 <strchr@plt>
mov    %rax,-0x98(%rbp)
cmpq   $0x0,-0x98(%rbp)
je     1327 <divide_media_token+0x1e7>
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    1367 <divide_media_token+0x227>
jmp    137e <divide_media_token+0x23e>
mov    -0x98(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x90(%rbp)
jmp    12d2 <divide_media_token+0x192>
mov    -0x9c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xc0,%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
mov    %rdi,%r15
lea    0xea9(%rip),%rbx
mov    %rbx,%rsi
call   1060 <strstr@plt>
mov    %rax,%rbp
test   %rax,%rax
jne    1185 <divide_media_token+0x45>
lea    0xe99(%rip),%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <strstr@plt>
mov    %rax,%rbp
test   %rax,%rax
je     12f2 <divide_media_token+0x1b2>
mov    %rbx,%rdi
call   1040 <strlen@plt>
movslq %eax,%rsi
add    %rbp,%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
movb   $0x0,0x63(%rsp)
movw   $0x0,0x61(%rsp)
mov    %rbx,%rdi
mov    $0x20,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     11bf <divide_media_token+0x7f>
movb   $0x0,(%rax)
mov    %rsp,%rdi
mov    $0x9,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     11d4 <divide_media_token+0x94>
movb   $0x0,(%rax)
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0xa,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     11ec <divide_media_token+0xac>
movb   $0x0,(%rax)
cmpb   $0x0,(%rsp)
je     12f2 <divide_media_token+0x1b2>
mov    %r15,%rdi
mov    $0x2c,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     12f6 <divide_media_token+0x1b6>
mov    %rax,%rbx
movb   $0x0,(%rax)
mov    %rsp,%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
cmpb   $0x0,0x1(%rbx)
je     12fa <divide_media_token+0x1ba>
add    $0x1,%rbx
mov    %rbx,%rdi
mov    $0x2c,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     1301 <divide_media_token+0x1c1>
mov    %rax,%r15
movb   $0x0,(%rax)
lea    0x1e(%r14),%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
cmpb   $0x0,0x1(%r15)
je     130b <divide_media_token+0x1cb>
add    $0x1,%r15
mov    %r15,%rdi
mov    $0x2c,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     1312 <divide_media_token+0x1d2>
mov    %rax,%rbx
movb   $0x0,(%rax)
lea    0x3c(%r14),%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
cmpb   $0x0,0x1(%rbx)
je     1319 <divide_media_token+0x1d9>
add    $0x1,%rbx
mov    %rbx,%rdi
mov    $0x2c,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     1320 <divide_media_token+0x1e0>
mov    %rax,%r15
movb   $0x0,(%rax)
lea    0x5a(%r14),%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
cmpb   $0x0,0x1(%r15)
je     132a <divide_media_token+0x1ea>
add    $0x1,%r15
mov    %r15,%rdi
mov    $0x2c,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     1331 <divide_media_token+0x1f1>
movb   $0x0,(%rax)
add    $0x78,%r14
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
mov    $0x5,%ebp
jmp    1356 <divide_media_token+0x216>
xor    %ebp,%ebp
jmp    1356 <divide_media_token+0x216>
xor    %ebp,%ebp
jmp    1336 <divide_media_token+0x1f6>
mov    $0x1,%ebp
jmp    1356 <divide_media_token+0x216>
mov    $0x1,%ebp
mov    %rbx,%r15
jmp    1336 <divide_media_token+0x1f6>
mov    $0x2,%ebp
jmp    1356 <divide_media_token+0x216>
mov    $0x2,%ebp
jmp    1336 <divide_media_token+0x1f6>
mov    $0x3,%ebp
jmp    1356 <divide_media_token+0x216>
mov    $0x3,%ebp
mov    %rbx,%r15
jmp    1336 <divide_media_token+0x1f6>
mov    $0x4,%ebp
jmp    1356 <divide_media_token+0x216>
mov    $0x4,%ebp
mov    %ebp,%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,%ebp
mov    %ebp,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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