#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 */
char *strchr(char *, char);
int /*<<< orphan*/ swf_cgienv(unsigned char *);
void swf_scanquery(char *q) {
  char *next = q;
  if (!q)
    return;
  while (next) {
    next = strchr(q, '&');
    if (next)
      next[0] = 0;
    swf_cgienv((unsigned char *)q);
    if (next) {
      next[0] = '&';
      q = next + 1;
    }
  }
}


x86 assembly (clang, -O0):
<swf_scanquery>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1144 <swf_scanquery+0x24>
jmp    11a4 <swf_scanquery+0x84>
jmp    1149 <swf_scanquery+0x29>
cmpq   $0x0,-0x10(%rbp)
je     11a4 <swf_scanquery+0x84>
mov    -0x8(%rbp),%rdi
mov    $0x26,%esi
call   1030 <strchr@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1178 <swf_scanquery+0x58>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
call   1040 <swf_cgienv@plt>
cmpq   $0x0,-0x10(%rbp)
je     119f <swf_scanquery+0x7f>
mov    -0x10(%rbp),%rax
movb   $0x26,(%rax)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1149 <swf_scanquery+0x29>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<swf_scanquery>:
test   %rdi,%rdi
je     117b <swf_scanquery+0x5b>
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    $0x26,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     116c <swf_scanquery+0x4c>
mov    %rax,%r14
xchg   %ax,%ax
movb   $0x0,(%r14)
mov    %rbx,%rdi
call   1040 <swf_cgienv@plt>
movb   $0x26,(%r14)
mov    %r14,%rbx
add    $0x1,%rbx
mov    %rbx,%rdi
mov    $0x26,%esi
call   1030 <strchr@plt>
mov    %rax,%r14
test   %rax,%rax
jne    1140 <swf_scanquery+0x20>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <swf_cgienv@plt>
ret

LLVM IR (-O0):
define void @swf_scanquery(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
store i8* %4, i8** %3
%5 = load i8*, i8** %2
%6 = icmp ne i8* %5, null
br i1 %6, label %8, label %7
7: ; preds = %1
br label %31
8: ; preds = %1
br label %9
9: ; preds = %30, %8
%10 = load i8*, i8** %3
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %31
12: ; preds = %9
%13 = load i8*, i8** %2
%14 = call i8* @strchr(i8* %13, i8 signext 38)
store i8* %14, i8** %3
%15 = load i8*, i8** %3
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %20
17: ; preds = %12
%18 = load i8*, i8** %3
%19 = getelementptr inbounds i8, i8* %18, i64 0
store i8 0, i8* %19
br label %20
20: ; preds = %17, %12
%21 = load i8*, i8** %2
%22 = call i32 @swf_cgienv(i8* %21)
%23 = load i8*, i8** %3
%24 = icmp ne i8* %23, null
br i1 %24, label %25, label %30
25: ; preds = %20
%26 = load i8*, i8** %3
%27 = getelementptr inbounds i8, i8* %26, i64 0
store i8 38, i8* %27
%28 = load i8*, i8** %3
%29 = getelementptr inbounds i8, i8* %28, i64 1
store i8* %29, i8** %2
br label %30
30: ; preds = %25, %20
br label %9
31: ; preds = %7, %9
ret void
}

LLVM IR (-O2):
define void @swf_scanquery(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %16, label %3
3: ; preds = %1
%4 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 38)
%5 = icmp eq i8* %4, null
br i1 %5, label %13, label %6
6: ; preds = %3, %6
%7 = phi i8* [ %11, %6 ], [ %4, %3 ]
%8 = phi i8* [ %10, %6 ], [ %0, %3 ]
store i8 0, i8* %7
%9 = tail call i32 @swf_cgienv(i8* %8)
store i8 38, i8* %7
%10 = getelementptr inbounds i8, i8* %7, i64 1
%11 = tail call i8* @strchr(i8* dereferenceable(1) %10, i8 signext 38)
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %6
13: ; preds = %6, %3
%14 = phi i8* [ %0, %3 ], [ %10, %6 ]
%15 = tail call i32 @swf_cgienv(i8* %14)
br label %16
16: ; preds = %13, %1
ret void
}