#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*/ free(char *);
char *oauth_url_escape(char *);
int /*<<< orphan*/ strcat(char *, char *);
char *strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
scalar_t__ strstr(char *, char *);
scalar_t__ xmalloc(int);
scalar_t__ xrealloc(char *, int);
char *xstrdup(char *);
char *oauth_serialize_url_sep(int argc, int start, char **argv, char *sep,
                              int mod) {
  char *tmp, *t1;
  int i;
  int first = 0;
  int seplen = strlen(sep);
  char *query = (char *)xmalloc(sizeof(char));
  *query = '\0';
  for (i = start; i < argc; i++) {
    int len = 0;
    if ((mod & 1) == 1 && (strncmp(argv[i], "oauth_", 6) == 0 ||
                           strncmp(argv[i], "x_oauth_", 8) == 0))
      continue;
    if ((mod & 2) == 2 &&
        (strncmp(argv[i], "oauth_", 6) != 0 &&
         strncmp(argv[i], "x_oauth_", 8) != 0) &&
        i != 0)
      continue;
    if (query)
      len += strlen(query);
    if (i == start && i == 0 && strstr(argv[i], ":/")) {
      tmp = xstrdup(argv[i]);
      while ((t1 = strchr(tmp, ' '))) {
        size_t off = t1 - tmp;
        char *t2 = (char *)xmalloc(sizeof(char) * (3 + strlen(tmp)));
        strcpy(t2, tmp);
        strcpy(t2 + off + 2, tmp + off);
        *(t2 + off) = '%';
        *(t2 + off + 1) = '2';
        *(t2 + off + 2) = '0';
        free(tmp);
        tmp = t2;
      }
      len += strlen(tmp);
    } else if (!(t1 = strchr(argv[i], '='))) {
      tmp = xstrdup(argv[i]);
      tmp = (char *)xrealloc(tmp, (strlen(tmp) + 2) * sizeof(char));
      strcat(tmp, "=");
      len += strlen(tmp);
    } else {
      *t1 = 0;
      tmp = oauth_url_escape(argv[i]);
      *t1 = '=';
      t1 = oauth_url_escape((t1 + 1));
      tmp = (char *)xrealloc(
          tmp,
          (strlen(tmp) + strlen(t1) + 2 + (mod & 4 ? 2 : 0)) * sizeof(char));
      strcat(tmp, "=");
      if (mod & 4)
        strcat(tmp, "\"");
      strcat(tmp, t1);
      if (mod & 4)
        strcat(tmp, "\"");
      free(t1);
      len += strlen(tmp);
    }
    len += seplen + 1;
    query = (char *)xrealloc(query, len * sizeof(char));
    strcat(query, ((i == start || first) ? "" : sep));
    first = 0;
    strcat(query, tmp);
    if (i == start && i == 0 && strstr(tmp, ":/")) {
      strcat(query, "?");
      first = 1;
    }
    free(tmp);
  }
  return (query);
}


x86 assembly (clang, -O0):
<oauth_serialize_url_sep>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x3c(%rbp)
mov    $0x1,%edi
call   1090 <xmalloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1665 <oauth_serialize_url_sep+0x4b5>
movl   $0x0,-0x4c(%rbp)
mov    -0x1c(%rbp),%eax
and    $0x1,%eax
cmp    $0x1,%eax
jne    1270 <oauth_serialize_url_sep+0xc0>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xdd2(%rip),%rsi
mov    $0x6,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
je     126b <oauth_serialize_url_sep+0xbb>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xda9(%rip),%rsi
mov    $0x8,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    1270 <oauth_serialize_url_sep+0xc0>
jmp    1657 <oauth_serialize_url_sep+0x4a7>
mov    -0x1c(%rbp),%eax
and    $0x2,%eax
cmp    $0x2,%eax
jne    12dc <oauth_serialize_url_sep+0x12c>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd70(%rip),%rsi
mov    $0x6,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
je     12dc <oauth_serialize_url_sep+0x12c>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd47(%rip),%rsi
mov    $0x8,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
je     12dc <oauth_serialize_url_sep+0x12c>
cmpl   $0x0,-0x34(%rbp)
je     12dc <oauth_serialize_url_sep+0x12c>
jmp    1657 <oauth_serialize_url_sep+0x4a7>
cmpq   $0x0,-0x48(%rbp)
je     12f6 <oauth_serialize_url_sep+0x146>
mov    -0x48(%rbp),%rdi
call   1060 <strlen@plt>
add    -0x4c(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    1401 <oauth_serialize_url_sep+0x251>
cmpl   $0x0,-0x34(%rbp)
jne    1401 <oauth_serialize_url_sep+0x251>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xcea(%rip),%rsi
call   10d0 <strstr@plt>
cmp    $0x0,%rax
je     1401 <oauth_serialize_url_sep+0x251>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   10a0 <xstrdup@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    $0x20,%esi
call   1070 <strchr@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     13ed <oauth_serialize_url_sep+0x23d>
mov    -0x30(%rbp),%rax
mov    -0x28(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x58(%rbp)
mov    -0x28(%rbp),%rdi
call   1060 <strlen@plt>
add    $0x3,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1090 <xmalloc@plt>
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1050 <strcpy@plt>
mov    -0x60(%rbp),%rdi
add    -0x58(%rbp),%rdi
add    $0x2,%rdi
mov    -0x28(%rbp),%rsi
add    -0x58(%rbp),%rsi
call   1050 <strcpy@plt>
mov    -0x60(%rbp),%rax
mov    -0x58(%rbp),%rcx
movb   $0x25,(%rax,%rcx,1)
mov    -0x60(%rbp),%rax
mov    -0x58(%rbp),%rcx
movb   $0x32,0x1(%rax,%rcx,1)
mov    -0x60(%rbp),%rax
mov    -0x58(%rbp),%rcx
movb   $0x30,0x2(%rax,%rcx,1)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x60(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    1343 <oauth_serialize_url_sep+0x193>
mov    -0x28(%rbp),%rdi
call   1060 <strlen@plt>
add    -0x4c(%rbp),%eax
mov    %eax,-0x4c(%rbp)
jmp    1584 <oauth_serialize_url_sep+0x3d4>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    $0x3d,%esi
call   1070 <strchr@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    1487 <oauth_serialize_url_sep+0x2d7>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   10a0 <xstrdup@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x28(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x68(%rbp),%rdi
add    $0x2,%eax
cltq
shl    $0x0,%rax
mov    %eax,%esi
call   1080 <xrealloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xb9e(%rip),%rsi
call   10c0 <strcat@plt>
mov    -0x28(%rbp),%rdi
call   1060 <strlen@plt>
add    -0x4c(%rbp),%eax
mov    %eax,-0x4c(%rbp)
jmp    157f <oauth_serialize_url_sep+0x3cf>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   10b0 <oauth_url_escape@plt>
mov    %rax,-0x28(%rbp)
mov    -0x30(%rbp),%rax
movb   $0x3d,(%rax)
mov    -0x30(%rbp),%rdi
add    $0x1,%rdi
call   10b0 <oauth_url_escape@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x28(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x6c(%rbp)
mov    -0x30(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x78(%rbp),%rdi
mov    %eax,%ecx
mov    -0x6c(%rbp),%eax
add    %ecx,%eax
add    $0x2,%eax
mov    -0x1c(%rbp),%esi
and    $0x4,%esi
xor    %ecx,%ecx
mov    $0x2,%edx
cmp    $0x0,%esi
cmovne %edx,%ecx
add    %ecx,%eax
cltq
shl    $0x0,%rax
mov    %eax,%esi
call   1080 <xrealloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xaf5(%rip),%rsi
call   10c0 <strcat@plt>
mov    -0x1c(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     153b <oauth_serialize_url_sep+0x38b>
mov    -0x28(%rbp),%rdi
lea    0xad8(%rip),%rsi
call   10c0 <strcat@plt>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   10c0 <strcat@plt>
mov    -0x1c(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     1567 <oauth_serialize_url_sep+0x3b7>
mov    -0x28(%rbp),%rdi
lea    0xaac(%rip),%rsi
call   10c0 <strcat@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1060 <strlen@plt>
add    -0x4c(%rbp),%eax
mov    %eax,-0x4c(%rbp)
jmp    1584 <oauth_serialize_url_sep+0x3d4>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
add    -0x4c(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x48(%rbp),%rdi
movslq -0x4c(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%esi
call   1080 <xrealloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x8(%rbp),%eax
je     15c5 <oauth_serialize_url_sep+0x415>
cmpl   $0x0,-0x38(%rbp)
je     15d8 <oauth_serialize_url_sep+0x428>
lea    0xa43(%rip),%rax
mov    %rax,-0x88(%rbp)
jmp    15e3 <oauth_serialize_url_sep+0x433>
mov    -0x18(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x80(%rbp),%rdi
mov    -0x88(%rbp),%rsi
call   10c0 <strcat@plt>
movl   $0x0,-0x38(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   10c0 <strcat@plt>
mov    -0x34(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    164e <oauth_serialize_url_sep+0x49e>
cmpl   $0x0,-0x34(%rbp)
jne    164e <oauth_serialize_url_sep+0x49e>
mov    -0x28(%rbp),%rdi
lea    0x9e1(%rip),%rsi
call   10d0 <strstr@plt>
cmp    $0x0,%rax
je     164e <oauth_serialize_url_sep+0x49e>
mov    -0x48(%rbp),%rdi
lea    0x9ce(%rip),%rsi
call   10c0 <strcat@plt>
movl   $0x1,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11fb <oauth_serialize_url_sep+0x4b>
mov    -0x48(%rbp),%rax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<oauth_serialize_url_sep>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %r8d,%r15d
mov    %rdx,%r12
mov    %esi,%r14d
mov    %edi,%ebp
mov    %rcx,0x38(%rsp)
mov    %rcx,%rdi
call   1060 <strlen@plt>
mov    %eax,0x14(%rsp)
mov    $0x1,%edi
call   1090 <xmalloc@plt>
mov    %rax,%rbx
movb   $0x0,(%rax)
mov    %ebp,0x20(%rsp)
cmp    %ebp,%r14d
jge    1532 <oauth_serialize_url_sep+0x382>
mov    %r15d,%eax
and    $0x4,%eax
mov    %eax,0x1c(%rsp)
shr    %eax
add    $0x2,%eax
mov    %eax,0x18(%rsp)
addl   $0x1,0x14(%rsp)
movslq %r14d,%r13
xor    %ebp,%ebp
mov    %r13,0x28(%rsp)
mov    %r15d,0x10(%rsp)
mov    %r12,0x30(%rsp)
jmp    124c <oauth_serialize_url_sep+0x9c>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r12,%rdi
call   1030 <free@plt>
mov    0x30(%rsp),%r12
add    $0x1,%r13
cmp    0x20(%rsp),%r13d
je     1532 <oauth_serialize_url_sep+0x382>
test   $0x1,%r15b
je     1286 <oauth_serialize_url_sep+0xd6>
mov    (%r12,%r13,8),%rdi
lea    0xda5(%rip),%rsi
mov    $0x6,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     123d <oauth_serialize_url_sep+0x8d>
mov    (%r12,%r13,8),%rdi
lea    0xd89(%rip),%rsi
mov    $0x8,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     123d <oauth_serialize_url_sep+0x8d>
test   $0x2,%r15b
je     12d0 <oauth_serialize_url_sep+0x120>
mov    (%r12,%r13,8),%rdi
lea    0xd6b(%rip),%rsi
mov    $0x6,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     12d0 <oauth_serialize_url_sep+0x120>
mov    (%r12,%r13,8),%rdi
lea    0xd4f(%rip),%rsi
mov    $0x8,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     12d0 <oauth_serialize_url_sep+0x120>
test   %r13,%r13
jne    123d <oauth_serialize_url_sep+0x8d>
nopl   0x0(%rax)
test   %rbx,%rbx
mov    %rbx,0x40(%rsp)
mov    %ebp,0x24(%rsp)
je     12f0 <oauth_serialize_url_sep+0x140>
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %eax,%r14d
jmp    12f3 <oauth_serialize_url_sep+0x143>
nopl   0x0(%rax,%rax,1)
xor    %r14d,%r14d
mov    %r13,%rax
xor    0x28(%rsp),%rax
or     %r13,%rax
sete   %bl
mov    %bl,0xf(%rsp)
jne    13c0 <oauth_serialize_url_sep+0x210>
mov    (%r12),%rdi
lea    0xcf3(%rip),%rsi
call   10d0 <strstr@plt>
test   %rax,%rax
je     13c0 <oauth_serialize_url_sep+0x210>
mov    (%r12),%rdi
call   10a0 <xstrdup@plt>
mov    %rax,%r12
mov    %rax,%rdi
mov    $0x20,%esi
call   1070 <strchr@plt>
test   %rax,%rax
je     146c <oauth_serialize_url_sep+0x2bc>
mov    %rax,%r15
nopl   0x0(%rax)
mov    %r15,%rbx
sub    %r12,%rbx
mov    %r12,%rdi
call   1060 <strlen@plt>
lea    0x3(%rax),%edi
call   1090 <xmalloc@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %r12,%rsi
call   1050 <strcpy@plt>
lea    (%rbx,%rbp,1),%rdi
add    $0x2,%rdi
mov    %r15,%rsi
call   1050 <strcpy@plt>
movw   $0x3225,0x0(%rbp,%rbx,1)
movb   $0x30,0x2(%rbp,%rbx,1)
mov    %r12,%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
mov    $0x20,%esi
call   1070 <strchr@plt>
mov    %rax,%r15
mov    %rbp,%r12
test   %rax,%rax
jne    1350 <oauth_serialize_url_sep+0x1a0>
mov    %rbp,%r12
jmp    146c <oauth_serialize_url_sep+0x2bc>
nopl   0x0(%rax,%rax,1)
mov    (%r12,%r13,8),%rbp
mov    %rbp,%rdi
mov    $0x3d,%esi
call   1070 <strchr@plt>
test   %rax,%rax
je     1473 <oauth_serialize_url_sep+0x2c3>
mov    %rax,%rbx
movb   $0x0,(%rax)
mov    (%r12,%r13,8),%rdi
call   10b0 <oauth_url_escape@plt>
mov    %rax,%rbp
movb   $0x3d,(%rbx)
add    $0x1,%rbx
mov    %rbx,%rdi
call   10b0 <oauth_url_escape@plt>
mov    %rax,%r15
mov    %rbp,%rdi
call   1060 <strlen@plt>
mov    %eax,%ebx
mov    %r15,%rdi
call   1060 <strlen@plt>
add    0x18(%rsp),%ebx
add    %eax,%ebx
mov    %rbp,%rdi
mov    %ebx,%esi
call   1080 <xrealloc@plt>
mov    %rax,%r12
mov    %rax,%rdi
lea    0xbdf(%rip),%rsi
call   10c0 <strcat@plt>
mov    %r15,%rsi
cmpl   $0x0,0x1c(%rsp)
je     145c <oauth_serialize_url_sep+0x2ac>
mov    %r12,%rdi
lea    0xbc8(%rip),%rbx
mov    %rbx,%rsi
call   10c0 <strcat@plt>
mov    %r12,%rdi
mov    %r15,%rsi
call   10c0 <strcat@plt>
mov    %rbx,%rsi
mov    %r12,%rdi
call   10c0 <strcat@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    0x10(%rsp),%r15d
jmp    14a3 <oauth_serialize_url_sep+0x2f3>
mov    %rbp,%rdi
call   10a0 <xstrdup@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <strlen@plt>
lea    0x2(%rax),%esi
mov    %rbx,%rdi
call   1080 <xrealloc@plt>
mov    %rax,%r12
mov    %rax,%rdi
lea    0xb6e(%rip),%rsi
call   10c0 <strcat@plt>
mov    %r12,%rdi
call   1060 <strlen@plt>
add    0x14(%rsp),%r14d
add    %eax,%r14d
mov    0x40(%rsp),%rdi
mov    %r14d,%esi
call   1080 <xrealloc@plt>
cmpl   $0x0,0x24(%rsp)
mov    0x38(%rsp),%rsi
lea    0xb3e(%rip),%rcx
cmovne %rcx,%rsi
mov    %rax,%rbx
cmp    0x28(%rsp),%r13
cmove  %rcx,%rsi
mov    %rax,%rdi
call   10c0 <strcat@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   10c0 <strcat@plt>
xor    %ebp,%ebp
cmpb   $0x0,0xf(%rsp)
je     1230 <oauth_serialize_url_sep+0x80>
mov    %r12,%rdi
lea    0xafe(%rip),%rsi
call   10d0 <strstr@plt>
test   %rax,%rax
je     1230 <oauth_serialize_url_sep+0x80>
mov    %rbx,%rdi
lea    0xaed(%rip),%rsi
call   10c0 <strcat@plt>
mov    $0x1,%ebp
jmp    1230 <oauth_serialize_url_sep+0x80>
mov    %rbx,%rax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"oauth_\00"
@.str.1 = [9 x i8] c"x_oauth_\00"
@.str.2 = [3 x i8] c":/\00"
@.str.3 = [2 x i8] c"=\00"
@.str.4 = [2 x i8] c"\22\00"
@.str.5 = [1 x i8] zeroinitializer
@.str.6 = [2 x i8] c"?\00"
define i8* @oauth_serialize_url_sep(i32 %0, i32 %1, i8** %2, i8* %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8**
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i8*
%17 = alloca i32
%18 = alloca i64
%19 = alloca i8*
store i32 %0, i32* %6
store i32 %1, i32* %7
store i8** %2, i8*** %8
store i8* %3, i8** %9
store i32 %4, i32* %10
store i32 0, i32* %14
%20 = load i8*, i8** %9
%21 = call i32 @strlen(i8* %20)
store i32 %21, i32* %15
%22 = call i64 @xmalloc(i32 1)
%23 = inttoptr i64 %22 to i8*
store i8* %23, i8** %16
%24 = load i8*, i8** %16
store i8 0, i8* %24
%25 = load i32, i32* %7
store i32 %25, i32* %13
br label %26
26: ; preds = %283, %5
%27 = load i32, i32* %13
%28 = load i32, i32* %6
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %286
30: ; preds = %26
store i32 0, i32* %17
%31 = load i32, i32* %10
%32 = and i32 %31, 1
%33 = icmp eq i32 %32, 1
br i1 %33, label %34, label %51
34: ; preds = %30
%35 = load i8**, i8*** %8
%36 = load i32, i32* %13
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8*, i8** %35, i64 %37
%39 = load i8*, i8** %38
%40 = call i64 @strncmp(i8* %39, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 6)
%41 = icmp eq i64 %40, 0
br i1 %41, label %50, label %42
42: ; preds = %34
%43 = load i8**, i8*** %8
%44 = load i32, i32* %13
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8*, i8** %43, i64 %45
%47 = load i8*, i8** %46
%48 = call i64 @strncmp(i8* %47, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 8)
%49 = icmp eq i64 %48, 0
br i1 %49, label %50, label %51
50: ; preds = %42, %34
br label %283
51: ; preds = %42, %30
%52 = load i32, i32* %10
%53 = and i32 %52, 2
%54 = icmp eq i32 %53, 2
br i1 %54, label %55, label %75
55: ; preds = %51
%56 = load i8**, i8*** %8
%57 = load i32, i32* %13
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8*, i8** %56, i64 %58
%60 = load i8*, i8** %59
%61 = call i64 @strncmp(i8* %60, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 6)
%62 = icmp ne i64 %61, 0
br i1 %62, label %63, label %75
63: ; preds = %55
%64 = load i8**, i8*** %8
%65 = load i32, i32* %13
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i8*, i8** %64, i64 %66
%68 = load i8*, i8** %67
%69 = call i64 @strncmp(i8* %68, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 8)
%70 = icmp ne i64 %69, 0
br i1 %70, label %71, label %75
71: ; preds = %63
%72 = load i32, i32* %13
%73 = icmp ne i32 %72, 0
br i1 %73, label %74, label %75
74: ; preds = %71
br label %283
75: ; preds = %71, %63, %55, %51
%76 = load i8*, i8** %16
%77 = icmp ne i8* %76, null
br i1 %77, label %78, label %83
78: ; preds = %75
%79 = load i8*, i8** %16
%80 = call i32 @strlen(i8* %79)
%81 = load i32, i32* %17
%82 = add nsw i32 %81, %80
store i32 %82, i32* %17
br label %83
83: ; preds = %78, %75
%84 = load i32, i32* %13
%85 = load i32, i32* %7
%86 = icmp eq i32 %84, %85
br i1 %86, label %87, label %153
87: ; preds = %83
%88 = load i32, i32* %13
%89 = icmp eq i32 %88, 0
br i1 %89, label %90, label %153
90: ; preds = %87
%91 = load i8**, i8*** %8
%92 = load i32, i32* %13
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds i8*, i8** %91, i64 %93
%95 = load i8*, i8** %94
%96 = call i64 @strstr(i8* %95, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%97 = icmp ne i64 %96, 0
br i1 %97, label %98, label %153
98: ; preds = %90
%99 = load i8**, i8*** %8
%100 = load i32, i32* %13
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds i8*, i8** %99, i64 %101
%103 = load i8*, i8** %102
%104 = call i8* @xstrdup(i8* %103)
store i8* %104, i8** %11
br label %105
105: ; preds = %109, %98
%106 = load i8*, i8** %11
%107 = call i8* @strchr(i8* %106, i8 signext 32)
store i8* %107, i8** %12
%108 = icmp ne i8* %107, null
br i1 %108, label %109, label %148
109: ; preds = %105
%110 = load i8*, i8** %12
%111 = load i8*, i8** %11
%112 = ptrtoint i8* %110 to i64
%113 = ptrtoint i8* %111 to i64
%114 = sub i64 %112, %113
store i64 %114, i64* %18
%115 = load i8*, i8** %11
%116 = call i32 @strlen(i8* %115)
%117 = add nsw i32 3, %116
%118 = sext i32 %117 to i64
%119 = mul i64 1, %118
%120 = trunc i64 %119 to i32
%121 = call i64 @xmalloc(i32 %120)
%122 = inttoptr i64 %121 to i8*
store i8* %122, i8** %19
%123 = load i8*, i8** %19
%124 = load i8*, i8** %11
%125 = call i32 @strcpy(i8* %123, i8* %124)
%126 = load i8*, i8** %19
%127 = load i64, i64* %18
%128 = getelementptr inbounds i8, i8* %126, i64 %127
%129 = getelementptr inbounds i8, i8* %128, i64 2
%130 = load i8*, i8** %11
%131 = load i64, i64* %18
%132 = getelementptr inbounds i8, i8* %130, i64 %131
%133 = call i32 @strcpy(i8* %129, i8* %132)
%134 = load i8*, i8** %19
%135 = load i64, i64* %18
%136 = getelementptr inbounds i8, i8* %134, i64 %135
store i8 37, i8* %136
%137 = load i8*, i8** %19
%138 = load i64, i64* %18
%139 = getelementptr inbounds i8, i8* %137, i64 %138
%140 = getelementptr inbounds i8, i8* %139, i64 1
store i8 50, i8* %140
%141 = load i8*, i8** %19
%142 = load i64, i64* %18
%143 = getelementptr inbounds i8, i8* %141, i64 %142
%144 = getelementptr inbounds i8, i8* %143, i64 2
store i8 48, i8* %144
%145 = load i8*, i8** %11
%146 = call i32 @free(i8* %145)
%147 = load i8*, i8** %19
store i8* %147, i8** %11
br label %105
148: ; preds = %105
%149 = load i8*, i8** %11
%150 = call i32 @strlen(i8* %149)
%151 = load i32, i32* %17
%152 = add nsw i32 %151, %150
store i32 %152, i32* %17
br label %239
153: ; preds = %90, %87, %83
%154 = load i8**, i8*** %8
%155 = load i32, i32* %13
%156 = sext i32 %155 to i64
%157 = getelementptr inbounds i8*, i8** %154, i64 %156
%158 = load i8*, i8** %157
%159 = call i8* @strchr(i8* %158, i8 signext 61)
store i8* %159, i8** %12
%160 = icmp ne i8* %159, null
br i1 %160, label %183, label %161
161: ; preds = %153
%162 = load i8**, i8*** %8
%163 = load i32, i32* %13
%164 = sext i32 %163 to i64
%165 = getelementptr inbounds i8*, i8** %162, i64 %164
%166 = load i8*, i8** %165
%167 = call i8* @xstrdup(i8* %166)
store i8* %167, i8** %11
%168 = load i8*, i8** %11
%169 = load i8*, i8** %11
%170 = call i32 @strlen(i8* %169)
%171 = add nsw i32 %170, 2
%172 = sext i32 %171 to i64
%173 = mul i64 %172, 1
%174 = trunc i64 %173 to i32
%175 = call i64 @xrealloc(i8* %168, i32 %174)
%176 = inttoptr i64 %175 to i8*
store i8* %176, i8** %11
%177 = load i8*, i8** %11
%178 = call i32 @strcat(i8* %177, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%179 = load i8*, i8** %11
%180 = call i32 @strlen(i8* %179)
%181 = load i32, i32* %17
%182 = add nsw i32 %181, %180
store i32 %182, i32* %17
br label %238
183: ; preds = %153
%184 = load i8*, i8** %12
store i8 0, i8* %184
%185 = load i8**, i8*** %8
%186 = load i32, i32* %13
%187 = sext i32 %186 to i64
%188 = getelementptr inbounds i8*, i8** %185, i64 %187
%189 = load i8*, i8** %188
%190 = call i8* @oauth_url_escape(i8* %189)
store i8* %190, i8** %11
%191 = load i8*, i8** %12
store i8 61, i8* %191
%192 = load i8*, i8** %12
%193 = getelementptr inbounds i8, i8* %192, i64 1
%194 = call i8* @oauth_url_escape(i8* %193)
store i8* %194, i8** %12
%195 = load i8*, i8** %11
%196 = load i8*, i8** %11
%197 = call i32 @strlen(i8* %196)
%198 = load i8*, i8** %12
%199 = call i32 @strlen(i8* %198)
%200 = add nsw i32 %197, %199
%201 = add nsw i32 %200, 2
%202 = load i32, i32* %10
%203 = and i32 %202, 4
%204 = icmp ne i32 %203, 0
%205 = zext i1 %204 to i64
%206 = select i1 %204, i32 2, i32 0
%207 = add nsw i32 %201, %206
%208 = sext i32 %207 to i64
%209 = mul i64 %208, 1
%210 = trunc i64 %209 to i32
%211 = call i64 @xrealloc(i8* %195, i32 %210)
%212 = inttoptr i64 %211 to i8*
store i8* %212, i8** %11
%213 = load i8*, i8** %11
%214 = call i32 @strcat(i8* %213, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%215 = load i32, i32* %10
%216 = and i32 %215, 4
%217 = icmp ne i32 %216, 0
br i1 %217, label %218, label %221
218: ; preds = %183
%219 = load i8*, i8** %11
%220 = call i32 @strcat(i8* %219, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %221
221: ; preds = %218, %183
%222 = load i8*, i8** %11
%223 = load i8*, i8** %12
%224 = call i32 @strcat(i8* %222, i8* %223)
%225 = load i32, i32* %10
%226 = and i32 %225, 4
%227 = icmp ne i32 %226, 0
br i1 %227, label %228, label %231
228: ; preds = %221
%229 = load i8*, i8** %11
%230 = call i32 @strcat(i8* %229, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %231
231: ; preds = %228, %221
%232 = load i8*, i8** %12
%233 = call i32 @free(i8* %232)
%234 = load i8*, i8** %11
%235 = call i32 @strlen(i8* %234)
%236 = load i32, i32* %17
%237 = add nsw i32 %236, %235
store i32 %237, i32* %17
br label %238
238: ; preds = %231, %161
br label %239
239: ; preds = %238, %148
%240 = load i32, i32* %15
%241 = add nsw i32 %240, 1
%242 = load i32, i32* %17
%243 = add nsw i32 %242, %241
store i32 %243, i32* %17
%244 = load i8*, i8** %16
%245 = load i32, i32* %17
%246 = sext i32 %245 to i64
%247 = mul i64 %246, 1
%248 = trunc i64 %247 to i32
%249 = call i64 @xrealloc(i8* %244, i32 %248)
%250 = inttoptr i64 %249 to i8*
store i8* %250, i8** %16
%251 = load i8*, i8** %16
%252 = load i32, i32* %13
%253 = load i32, i32* %7
%254 = icmp eq i32 %252, %253
br i1 %254, label %258, label %255
255: ; preds = %239
%256 = load i32, i32* %14
%257 = icmp ne i32 %256, 0
br i1 %257, label %258, label %259
258: ; preds = %255, %239
br label %261
259: ; preds = %255
%260 = load i8*, i8** %9
br label %261
261: ; preds = %259, %258
%262 = phi i8* [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0), %258 ], [ %260, %259 ]
%263 = call i32 @strcat(i8* %251, i8* %262)
store i32 0, i32* %14
%264 = load i8*, i8** %16
%265 = load i8*, i8** %11
%266 = call i32 @strcat(i8* %264, i8* %265)
%267 = load i32, i32* %13
%268 = load i32, i32* %7
%269 = icmp eq i32 %267, %268
br i1 %269, label %270, label %280
270: ; preds = %261
%271 = load i32, i32* %13
%272 = icmp eq i32 %271, 0
br i1 %272, label %273, label %280
273: ; preds = %270
%274 = load i8*, i8** %11
%275 = call i64 @strstr(i8* %274, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%276 = icmp ne i64 %275, 0
br i1 %276, label %277, label %280
277: ; preds = %273
%278 = load i8*, i8** %16
%279 = call i32 @strcat(i8* %278, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %14
br label %280
280: ; preds = %277, %273, %270, %261
%281 = load i8*, i8** %11
%282 = call i32 @free(i8* %281)
br label %283
283: ; preds = %280, %74, %50
%284 = load i32, i32* %13
%285 = add nsw i32 %284, 1
store i32 %285, i32* %13
br label %26
286: ; preds = %26
%287 = load i8*, i8** %16
ret i8* %287
}

LLVM IR (-O2):
@.str = [7 x i8] c"oauth_\00"
@.str.1 = [9 x i8] c"x_oauth_\00"
@.str.2 = [3 x i8] c":/\00"
@.str.3 = [2 x i8] c"=\00"
@.str.4 = [2 x i8] c"\22\00"
@.str.5 = [1 x i8] zeroinitializer
@.str.6 = [2 x i8] c"?\00"
define i8* @oauth_serialize_url_sep(i32 %0, i32 %1, i8** nocapture %2, i8* %3, i32 %4) {
%6 = tail call i32 @strlen(i8* %3)
%7 = tail call i64 @xmalloc(i32 1)
%8 = inttoptr i64 %7 to i8*
store i8 0, i8* %8
%9 = icmp slt i32 %1, %0
br i1 %9, label %10, label %142
10: ; preds = %5
%11 = and i32 %4, 1
%12 = icmp eq i32 %11, 0
%13 = and i32 %4, 2
%14 = icmp eq i32 %13, 0
%15 = and i32 %4, 4
%16 = icmp eq i32 %15, 0
%17 = lshr exact i32 %15, 1
%18 = add nuw nsw i32 %17, 2
%19 = add i32 %6, 1
%20 = sext i32 %1 to i64
br label %21
21: ; preds = %10, %136
%22 = phi i64 [ %20, %10 ], [ %139, %136 ]
%23 = phi i8* [ %8, %10 ], [ %138, %136 ]
%24 = phi i32 [ 0, %10 ], [ %137, %136 ]
br i1 %12, label %34, label %25
25: ; preds = %21
%26 = getelementptr inbounds i8*, i8** %2, i64 %22
%27 = load i8*, i8** %26
%28 = tail call i64 @strncmp(i8* %27, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 6)
%29 = icmp eq i64 %28, 0
br i1 %29, label %136, label %30
30: ; preds = %25
%31 = load i8*, i8** %26
%32 = tail call i64 @strncmp(i8* %31, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 8)
%33 = icmp eq i64 %32, 0
br i1 %33, label %136, label %34
34: ; preds = %30, %21
br i1 %14, label %46, label %35
35: ; preds = %34
%36 = getelementptr inbounds i8*, i8** %2, i64 %22
%37 = load i8*, i8** %36
%38 = tail call i64 @strncmp(i8* %37, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 6)
%39 = icmp eq i64 %38, 0
br i1 %39, label %46, label %40
40: ; preds = %35
%41 = load i8*, i8** %36
%42 = tail call i64 @strncmp(i8* %41, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 8)
%43 = icmp ne i64 %42, 0
%44 = icmp ne i64 %22, 0
%45 = select i1 %43, i1 %44, i1 false
br i1 %45, label %136, label %46
46: ; preds = %40, %35, %34
%47 = icmp eq i8* %23, null
br i1 %47, label %50, label %48
48: ; preds = %46
%49 = tail call i32 @strlen(i8* %23)
br label %50
50: ; preds = %48, %46
%51 = phi i32 [ %49, %48 ], [ 0, %46 ]
%52 = icmp eq i64 %22, %20
%53 = icmp eq i64 %22, 0
%54 = and i1 %52, %53
br i1 %54, label %55, label %85
55: ; preds = %50
%56 = load i8*, i8** %2
%57 = tail call i64 @strstr(i8* %56, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%58 = icmp eq i64 %57, 0
br i1 %58, label %85, label %59
59: ; preds = %55
%60 = load i8*, i8** %2
%61 = tail call i8* @xstrdup(i8* %60)
%62 = tail call i8* @strchr(i8* dereferenceable(1) %61, i8 signext 32)
%63 = icmp eq i8* %62, null
br i1 %63, label %116, label %64
64: ; preds = %59, %64
%65 = phi i8* [ %81, %64 ], [ %62, %59 ]
%66 = phi i8* [ %73, %64 ], [ %61, %59 ]
%67 = ptrtoint i8* %65 to i64
%68 = ptrtoint i8* %66 to i64
%69 = sub i64 %67, %68
%70 = tail call i32 @strlen(i8* %66)
%71 = add nsw i32 %70, 3
%72 = tail call i64 @xmalloc(i32 %71)
%73 = inttoptr i64 %72 to i8*
%74 = tail call i32 @strcpy(i8* %73, i8* %66)
%75 = getelementptr inbounds i8, i8* %73, i64 %69
%76 = getelementptr inbounds i8, i8* %75, i64 2
%77 = getelementptr inbounds i8, i8* %66, i64 %69
%78 = tail call i32 @strcpy(i8* %76, i8* %77)
store i8 37, i8* %75
%79 = getelementptr inbounds i8, i8* %75, i64 1
store i8 50, i8* %79
store i8 48, i8* %76
%80 = tail call i32 @free(i8* %66)
%81 = tail call i8* @strchr(i8* dereferenceable(1) %73, i8 signext 32)
%82 = icmp eq i8* %81, null
br i1 %82, label %83, label %64
83: ; preds = %64
%84 = inttoptr i64 %72 to i8*
br label %116
85: ; preds = %55, %50
%86 = getelementptr inbounds i8*, i8** %2, i64 %22
%87 = load i8*, i8** %86
%88 = tail call i8* @strchr(i8* dereferenceable(1) %87, i8 signext 61)
%89 = icmp eq i8* %88, null
br i1 %89, label %90, label %97
90: ; preds = %85
%91 = tail call i8* @xstrdup(i8* %87)
%92 = tail call i32 @strlen(i8* %91)
%93 = add nsw i32 %92, 2
%94 = tail call i64 @xrealloc(i8* %91, i32 %93)
%95 = inttoptr i64 %94 to i8*
%96 = tail call i32 @strcat(i8* %95, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %116
97: ; preds = %85
store i8 0, i8* %88
%98 = load i8*, i8** %86
%99 = tail call i8* @oauth_url_escape(i8* %98)
store i8 61, i8* %88
%100 = getelementptr inbounds i8, i8* %88, i64 1
%101 = tail call i8* @oauth_url_escape(i8* %100)
%102 = tail call i32 @strlen(i8* %99)
%103 = tail call i32 @strlen(i8* %101)
%104 = add i32 %18, %102
%105 = add i32 %104, %103
%106 = tail call i64 @xrealloc(i8* %99, i32 %105)
%107 = inttoptr i64 %106 to i8*
%108 = tail call i32 @strcat(i8* %107, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br i1 %16, label %112, label %109
109: ; preds = %97
%110 = tail call i32 @strcat(i8* %107, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%111 = tail call i32 @strcat(i8* %107, i8* %101)
br label %112
112: ; preds = %97, %109
%113 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), %109 ], [ %101, %97 ]
%114 = tail call i32 @strcat(i8* %107, i8* %113)
%115 = tail call i32 @free(i8* %101)
br label %116
116: ; preds = %59, %83, %90, %112
%117 = phi i8* [ %95, %90 ], [ %107, %112 ], [ %61, %59 ], [ %84, %83 ]
%118 = tail call i32 @strlen(i8* %117)
%119 = add i32 %19, %51
%120 = add i32 %119, %118
%121 = tail call i64 @xrealloc(i8* %23, i32 %120)
%122 = inttoptr i64 %121 to i8*
%123 = icmp ne i32 %24, 0
%124 = select i1 %52, i1 true, i1 %123
%125 = select i1 %124, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0), i8* %3
%126 = tail call i32 @strcat(i8* %122, i8* %125)
%127 = tail call i32 @strcat(i8* %122, i8* %117)
br i1 %54, label %128, label %133
128: ; preds = %116
%129 = tail call i64 @strstr(i8* %117, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%130 = icmp eq i64 %129, 0
br i1 %130, label %133, label %131
131: ; preds = %128
%132 = tail call i32 @strcat(i8* %122, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %133
133: ; preds = %131, %128, %116
%134 = phi i32 [ 1, %131 ], [ 0, %128 ], [ 0, %116 ]
%135 = tail call i32 @free(i8* %117)
br label %136
136: ; preds = %40, %25, %30, %133
%137 = phi i32 [ %134, %133 ], [ %24, %30 ], [ %24, %25 ], [ %24, %40 ]
%138 = phi i8* [ %122, %133 ], [ %23, %30 ], [ %23, %25 ], [ %23, %40 ]
%139 = add nsw i64 %22, 1
%140 = trunc i64 %139 to i32
%141 = icmp eq i32 %140, %0
br i1 %141, label %142, label %21
142: ; preds = %136, %5
%143 = phi i8* [ %8, %5 ], [ %138, %136 ]
ret i8* %143
}