#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*/ parseNameValue(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int strpos(char *, char *);
void parsePostdata(char *formdata) {
  printf("Parse: %s\n", formdata);
  int pos;
  if ((pos = strpos(formdata, "&")) != -1) {
    formdata[pos] = '\0';
    parsePostdata(formdata);
    parsePostdata(&formdata[pos + 1]);
  } else {
    if ((pos = strpos(formdata, "=")) != -1) {
      formdata[pos] = '\0';
      parseNameValue(formdata, &formdata[pos + 1]);
    }
  }
}


x86 assembly (clang, -O0):
<parsePostdata>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xea9(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    0xea4(%rip),%rsi
call   1050 <strpos@plt>
mov    %eax,-0xc(%rbp)
cmp    $0xffffffff,%eax
je     11a6 <parsePostdata+0x66>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%rdi
call   1030 <parsePostdata@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%eax
add    $0x1,%eax
cltq
add    %rax,%rdi
call   1030 <parsePostdata@plt>
jmp    11eb <parsePostdata+0xab>
mov    -0x8(%rbp),%rdi
lea    0xe5c(%rip),%rsi
call   1050 <strpos@plt>
mov    %eax,-0xc(%rbp)
cmp    $0xffffffff,%eax
je     11e6 <parsePostdata+0xa6>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%eax
add    $0x1,%eax
cltq
add    %rax,%rsi
call   1060 <parseNameValue@plt>
jmp    11eb <parsePostdata+0xab>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parsePostdata>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xeae(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
lea    0xeaa(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strpos@plt>
cmp    $0xffffffff,%eax
je     11b2 <parsePostdata+0x72>
lea    0xe8b(%rip),%r14
lea    0xe8f(%rip),%r15
nopl   0x0(%rax)
movslq %eax,%r12
movb   $0x0,(%rbx,%r12,1)
mov    %rbx,%rdi
call   1030 <parsePostdata@plt>
add    %r12,%rbx
add    $0x1,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <strpos@plt>
cmp    $0xffffffff,%eax
jne    1180 <parsePostdata+0x40>
lea    0xe54(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strpos@plt>
cmp    $0xffffffff,%eax
je     11e7 <parsePostdata+0xa7>
cltq
movb   $0x0,(%rbx,%rax,1)
lea    (%rbx,%rax,1),%rsi
add    $0x1,%rsi
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1060 <parseNameValue@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [11 x i8] c"Parse: %s\0A\00"
@.str.1 = [2 x i8] c"&\00"
@.str.2 = [2 x i8] c"=\00"
define void @parsePostdata(i8* %0) {
%2 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %0)
%3 = tail call i32 @strpos(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32 %3, -1
br i1 %4, label %16, label %5
5: ; preds = %1, %5
%6 = phi i32 [ %14, %5 ], [ %3, %1 ]
%7 = phi i8* [ %12, %5 ], [ %0, %1 ]
%8 = sext i32 %6 to i64
%9 = getelementptr inbounds i8, i8* %7, i64 %8
store i8 0, i8* %9
tail call void @parsePostdata(i8* %7)
%10 = add nuw nsw i32 %6, 1
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %7, i64 %11
%13 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = tail call i32 @strpos(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %5
16: ; preds = %5, %1
%17 = phi i8* [ %0, %1 ], [ %12, %5 ]
%18 = tail call i32 @strpos(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i32 %18, -1
br i1 %19, label %27, label %20
20: ; preds = %16
%21 = sext i32 %18 to i64
%22 = getelementptr inbounds i8, i8* %17, i64 %21
store i8 0, i8* %22
%23 = add nuw nsw i32 %18, 1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %17, i64 %24
%26 = tail call i32 @parseNameValue(i8* %17, i8* %25)
br label %27
27: ; preds = %16, %20
ret void
}