#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;
  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,-0x88(%rbp)
cmp    $0x0,%rax
je     11b6 <divide_media_token+0x76>
lea    -0x80(%rbp),%rax
mov    %rax,-0xa0(%rbp)
mov    -0x88(%rbp),%rax
mov    %rax,-0xa8(%rbp)
lea    0xe6c(%rip),%rdi
call   1040 <strlen@plt>
mov    -0xa8(%rbp),%rsi
mov    -0xa0(%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,-0x88(%rbp)
cmp    $0x0,%rax
je     1219 <divide_media_token+0xd9>
lea    -0x80(%rbp),%rax
mov    %rax,-0xb0(%rbp)
mov    -0x88(%rbp),%rax
mov    %rax,-0xb8(%rbp)
lea    0xe10(%rip),%rdi
call   1040 <strlen@plt>
mov    -0xb8(%rbp),%rsi
mov    -0xb0(%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,-0x88(%rbp)
cmpq   $0x0,-0x88(%rbp)
je     1263 <divide_media_token+0x123>
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     1290 <divide_media_token+0x150>
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     12bd <divide_media_token+0x17d>
mov    -0x88(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x80(%rbp),%rax
mov    %rax,-0x88(%rbp)
movl   $0x0,-0x94(%rbp)
cmpl   $0x5,-0x94(%rbp)
jge    137e <divide_media_token+0x23e>
mov    -0x88(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    12f7 <divide_media_token+0x1b7>
jmp    137e <divide_media_token+0x23e>
mov    -0x88(%rbp),%rdi
mov    $0x2c,%esi
call   1050 <strchr@plt>
mov    %rax,-0x90(%rbp)
cmpq   $0x0,-0x90(%rbp)
je     1327 <divide_media_token+0x1e7>
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    1367 <divide_media_token+0x227>
jmp    137e <divide_media_token+0x23e>
mov    -0x90(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x88(%rbp)
jmp    12d2 <divide_media_token+0x192>
mov    -0x94(%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 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 = icmp ne i8* %11, null
br i1 %12, label %13, label %20
13: ; preds = %2
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%15 = load i8*, i8** %7
%16 = call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = call i32 @strcpy(i8* %14, i8* %18)
br label %33
20: ; preds = %2
%21 = load i8*, i8** %4
%22 = call i8* @strstr(i8* %21, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
store i8* %22, i8** %7
%23 = icmp ne i8* %22, null
br i1 %23, label %24, label %31
24: ; preds = %20
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%26 = load i8*, i8** %7
%27 = call i32 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
%30 = call i32 @strcpy(i8* %25, i8* %29)
br label %32
31: ; preds = %20
store i32 0, i32* %3
br label %93
32: ; preds = %24
br label %33
33: ; preds = %32, %13
%34 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 99
store i8 0, i8* %34
%35 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 98
store i8 0, i8* %35
%36 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 97
store i8 0, i8* %36
%37 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%38 = call i8* @strchr(i8* %37, i8 signext 32)
store i8* %38, i8** %7
%39 = load i8*, i8** %7
%40 = icmp ne i8* %39, null
br i1 %40, label %41, label %43
41: ; preds = %33
%42 = load i8*, i8** %7
store i8 0, i8* %42
br label %43
43: ; preds = %41, %33
%44 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%45 = call i8* @strchr(i8* %44, i8 signext 9)
store i8* %45, i8** %7
%46 = load i8*, i8** %7
%47 = icmp ne i8* %46, null
br i1 %47, label %48, label %50
48: ; preds = %43
%49 = load i8*, i8** %7
store i8 0, i8* %49
br label %50
50: ; preds = %48, %43
%51 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%52 = call i8* @strchr(i8* %51, i8 signext 10)
store i8* %52, i8** %7
%53 = load i8*, i8** %7
%54 = icmp ne i8* %53, null
br i1 %54, label %55, label %57
55: ; preds = %50
%56 = load i8*, i8** %7
store i8 0, i8* %56
br label %57
57: ; preds = %55, %50
%58 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
store i8* %58, i8** %7
store i32 0, i32* %9
br label %59
59: ; preds = %88, %57
%60 = load i32, i32* %9
%61 = icmp slt i32 %60, 5
br i1 %61, label %62, label %91
62: ; preds = %59
%63 = load i8*, i8** %7
%64 = load i8, i8* %63
%65 = sext i8 %64 to i32
%66 = icmp eq i32 %65, 0
br i1 %66, label %67, label %68
67: ; preds = %62
br label %91
68: ; preds = %62
%69 = load i8*, i8** %7
%70 = call i8* @strchr(i8* %69, i8 signext 44)
store i8* %70, i8** %8
%71 = load i8*, i8** %8
%72 = icmp ne i8* %71, null
br i1 %72, label %73, label %75
73: ; preds = %68
%74 = load i8*, i8** %8
store i8 0, i8* %74
br label %75
75: ; preds = %73, %68
%76 = load [30 x i8]*, [30 x i8]** %5
%77 = load i32, i32* %9
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds [30 x i8], [30 x i8]* %76, i64 %78
%80 = getelementptr inbounds [30 x i8], [30 x i8]* %79, i64 0, i64 0
%81 = load i8*, i8** %7
%82 = call i32 @strcpy(i8* %80, i8* %81)
%83 = load i32, i32* %9
%84 = add nsw i32 %83, 1
store i32 %84, i32* %9
%85 = load i8*, i8** %8
%86 = icmp eq i8* %85, null
br i1 %86, label %87, label %88
87: ; preds = %75
br label %91
88: ; preds = %75
%89 = load i8*, i8** %8
%90 = getelementptr inbounds i8, i8* %89, i64 1
store i8* %90, i8** %7
br label %59
91: ; preds = %87, %67, %59
%92 = load i32, i32* %9
store i32 %92, i32* %3
br label %93
93: ; preds = %91, %31
%94 = load i32, i32* %3
ret i32 %94
}

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
}