#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*/ setsingleopt(char *);
char *strtok(char *, char *);
void formdecode(char *formdata) {
  char *dispatch[1000];
  int i = 0;
  dispatch[i] = strtok(formdata, "&");
  while (dispatch[i] != NULL)
    dispatch[++i] = strtok(NULL, "&");
  int amount = i;
  for (i = 0; i < amount; i++)
    setsingleopt(dispatch[i]);
}


x86 assembly (clang, -O0):
<formdecode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1f60,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x1f54(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xebc(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,%rcx
movslq -0x1f54(%rbp),%rax
mov    %rcx,-0x1f50(%rbp,%rax,8)
ff
movslq -0x1f54(%rbp),%rax
cmpq   $0x0,-0x1f50(%rbp,%rax,8)
je     11a2 <formdecode+0x82>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe84(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,%rcx
mov    -0x1f54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1f54(%rbp)
cltq
mov    %rcx,-0x1f50(%rbp,%rax,8)
ff
jmp    115b <formdecode+0x3b>
mov    -0x1f54(%rbp),%eax
mov    %eax,-0x1f58(%rbp)
movl   $0x0,-0x1f54(%rbp)
mov    -0x1f54(%rbp),%eax
cmp    -0x1f58(%rbp),%eax
jge    11f2 <formdecode+0xd2>
movslq -0x1f54(%rbp),%rax
mov    -0x1f50(%rbp,%rax,8),%rdi
ff
call   1030 <setsingleopt@plt>
mov    -0x1f54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1f54(%rbp)
jmp    11b8 <formdecode+0x98>
add    $0x1f60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<formdecode>:
push   %r14
push   %rbx
sub    $0x1f48,%rsp
lea    0xecf(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,(%rsp)
test   %rax,%rax
je     1192 <formdecode+0x72>
xor    %ebx,%ebx
lea    0xeb8(%rip),%r14
nopl   0x0(%rax,%rax,1)
xor    %edi,%edi
mov    %r14,%rsi
call   1040 <strtok@plt>
mov    %rax,0x8(%rsp,%rbx,8)
add    $0x1,%rbx
test   %rax,%rax
jne    1150 <formdecode+0x30>
test   %ebx,%ebx
je     1192 <formdecode+0x72>
mov    %ebx,%r14d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%rsp,%rbx,8),%rdi
call   1030 <setsingleopt@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1180 <formdecode+0x60>
add    $0x1f48,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c"&\00"
define void @formdecode(i8* %0) {
%2 = alloca i8*
%3 = alloca [1000 x i8*]
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %4
%6 = load i8*, i8** %2
%7 = call i8* @strtok(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* %4
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %3, i64 0, i64 %9
store i8* %7, i8** %10
br label %11
11: ; preds = %17, %1
%12 = load i32, i32* %4
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %3, i64 0, i64 %13
%15 = load i8*, i8** %14
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %23
17: ; preds = %11
%18 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
store i32 %20, i32* %4
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %3, i64 0, i64 %21
store i8* %18, i8** %22
br label %11
23: ; preds = %11
%24 = load i32, i32* %4
store i32 %24, i32* %5
store i32 0, i32* %4
br label %25
25: ; preds = %35, %23
%26 = load i32, i32* %4
%27 = load i32, i32* %5
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %38
29: ; preds = %25
%30 = load i32, i32* %4
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %3, i64 0, i64 %31
%33 = load i8*, i8** %32
%34 = call i32 @setsingleopt(i8* %33)
br label %35
35: ; preds = %29
%36 = load i32, i32* %4
%37 = add nsw i32 %36, 1
store i32 %37, i32* %4
br label %25
38: ; preds = %25
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"&\00"
define void @formdecode(i8* %0) {
%2 = alloca [1000 x i8*]
%3 = bitcast [1000 x i8*]* %2 to i8*
%4 = tail call i8* @strtok(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %2, i64 0, i64 0
store i8* %4, i8** %5
%6 = icmp eq i8* %4, null
br i1 %6, label %25, label %12
7: ; preds = %12
%8 = trunc i64 %15 to i32
%9 = icmp eq i32 %8, 0
br i1 %9, label %25, label %10
10: ; preds = %7
%11 = and i64 %15, 4294967295
br label %18
12: ; preds = %1, %12
%13 = phi i64 [ %15, %12 ], [ 0, %1 ]
%14 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%15 = add nuw nsw i64 %13, 1
%16 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %2, i64 0, i64 %15
store i8* %14, i8** %16
%17 = icmp eq i8* %14, null
br i1 %17, label %7, label %12
18: ; preds = %10, %18
%19 = phi i64 [ 0, %10 ], [ %23, %18 ]
%20 = getelementptr inbounds [1000 x i8*], [1000 x i8*]* %2, i64 0, i64 %19
%21 = load i8*, i8** %20
%22 = tail call i32 @setsingleopt(i8* %21)
%23 = add nuw nsw i64 %19, 1
%24 = icmp eq i64 %23, %11
br i1 %24, label %25, label %18
25: ; preds = %18, %1, %7
ret void
}