#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 setmultiopt(char *multistring) {
  char *dispatch[100];
  int i = 0;
  char *pch;
  dispatch[i] = strtok(multistring, "&");
  while (dispatch[i] != NULL)
    dispatch[++i] = strtok(NULL, "&");
  int amount = i;
  for (i = 0; i < amount; i++)
    setsingleopt(dispatch[i]);
}


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

x86 assembly (clang, -O2):
<setmultiopt>:
push   %r14
push   %rbx
sub    $0x328,%rsp
lea    0xecf(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,(%rsp)
test   %rax,%rax
je     1192 <setmultiopt+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 <setmultiopt+0x30>
test   %ebx,%ebx
je     1192 <setmultiopt+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 <setmultiopt+0x60>
add    $0x328,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c"&\00"
define void @setmultiopt(i8* %0) {
%2 = alloca [100 x i8*]
%3 = bitcast [100 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 [100 x i8*], [100 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 [100 x i8*], [100 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 [100 x i8*], [100 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
}