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

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *, ...);
int /*<<< orphan*/ puts(char *);
char *strtok(char *, char *);
char *strtok_r(char *, char *, char **);
int main(int argc, char **argv) {
  char *url = argv[1];
  char *data_part = strtok(url, "?");
  char *saveptr, *saveptr2, *str1;
  int i;
  printf("%s\n", data_part);
  data_part = strtok(NULL, "?");
  printf("%s\n", data_part);
  char *pair;
  char *k, *v;
  for (i = 1, str1 = data_part;; i++, str1 = NULL) {
    pair = strtok_r(str1, "&", &saveptr);
    if (pair == NULL)
      break;
    k = strtok_r(pair, "=", &saveptr2);
    v = strtok_r(NULL, "=", &saveptr2);
    printf("K:%s;V:%s\n", k, v);
  }
  puts(url);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe93(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe6d(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x3c(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
lea    0xe3a(%rip),%rsi
lea    -0x28(%rbp),%rdx
call   1050 <strtok_r@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    11e5 <main+0xa5>
jmp    1241 <main+0x101>
mov    -0x48(%rbp),%rdi
lea    0xe14(%rip),%rsi
lea    -0x30(%rbp),%rdx
call   1050 <strtok_r@plt>
mov    %rax,-0x50(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xdfc(%rip),%rsi
lea    -0x30(%rbp),%rdx
call   1050 <strtok_r@plt>
mov    %rax,-0x58(%rbp)
mov    -0x50(%rbp),%rsi
mov    -0x58(%rbp),%rdx
lea    0xde2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
movq   $0x0,-0x38(%rbp)
jmp    11bd <main+0x7d>
mov    -0x18(%rbp),%rdi
call   1030 <puts@plt>
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    0x8(%rsi),%rdi
lea    0xea7(%rip),%rbx
mov    %rdi,(%rsp)
mov    %rbx,%rsi
call   1060 <strtok@plt>
lea    0xea1(%rip),%rbp
mov    %rbp,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1060 <strtok@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe68(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %rbx,%rdi
call   1050 <strtok_r@plt>
test   %rax,%rax
je     1210 <main+0xd0>
lea    0xe51(%rip),%r15
lea    0x10(%rsp),%rbx
lea    0xe47(%rip),%r12
lea    0xe3c(%rip),%r13
lea    0x8(%rsp),%rbp
nopl   0x0(%rax,%rax,1)
mov    %rax,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1050 <strtok_r@plt>
mov    %rax,%r14
xor    %edi,%edi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1050 <strtok_r@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
mov    %r13,%rsi
mov    %rbp,%rdx
call   1050 <strtok_r@plt>
test   %rax,%rax
jne    11d0 <main+0x90>
mov    (%rsp),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"?\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [2 x i8] c"&\00"
@.str.3 = [2 x i8] c"=\00"
@.str.4 = [11 x i8] c"K:%s;V:%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
store i8* %17, i8** %6
%18 = load i8*, i8** %6
%19 = call i8* @strtok(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %19, i8** %7
%20 = load i8*, i8** %7
%21 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %22, i8** %7
%23 = load i8*, i8** %7
%24 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %23)
store i32 1, i32* %11
%25 = load i8*, i8** %7
store i8* %25, i8** %10
br label %26
26: ; preds = %39, %2
%27 = load i8*, i8** %10
%28 = call i8* @strtok_r(i8* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8** %8)
store i8* %28, i8** %12
%29 = load i8*, i8** %12
%30 = icmp eq i8* %29, null
br i1 %30, label %31, label %32
31: ; preds = %26
br label %42
32: ; preds = %26
%33 = load i8*, i8** %12
%34 = call i8* @strtok_r(i8* %33, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8** %9)
store i8* %34, i8** %13
%35 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8** %9)
store i8* %35, i8** %14
%36 = load i8*, i8** %13
%37 = load i8*, i8** %14
%38 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %36, i8* %37)
br label %39
39: ; preds = %32
%40 = load i32, i32* %11
%41 = add nsw i32 %40, 1
store i32 %41, i32* %11
store i8* null, i8** %10
br label %26
42: ; preds = %31
%43 = load i8*, i8** %6
%44 = call i32 @puts(i8* %43)
%45 = load i32, i32* %3
ret i32 %45
}

LLVM IR (-O2):
@.str = [2 x i8] c"?\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [2 x i8] c"&\00"
@.str.3 = [2 x i8] c"=\00"
@.str.4 = [11 x i8] c"K:%s;V:%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i8* @strtok(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = bitcast i8** %3 to i8*
%9 = bitcast i8** %4 to i8*
%10 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%11 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = call i8* @strtok_r(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8** %3)
%14 = icmp eq i8* %13, null
br i1 %14, label %22, label %15
15: ; preds = %2, %15
%16 = phi i8* [ %20, %15 ], [ %13, %2 ]
%17 = call i8* @strtok_r(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8** %4)
%18 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8** %4)
%19 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %17, i8* %18)
%20 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8** %3)
%21 = icmp eq i8* %20, null
br i1 %21, label %22, label %15
22: ; preds = %15, %2
%23 = call i32 @puts(i8* dereferenceable(1) %6)
ret i32 0
}