#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 *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 *);
int /*<<< orphan*/ xfree(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 = 1;
  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;
    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';
        xfree(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, "\"");
      xfree(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;
    }
    xfree(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   $0x1,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <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    165a <oauth_serialize_url_sep+0x4aa>
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   1030 <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   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1270 <oauth_serialize_url_sep+0xc0>
jmp    164c <oauth_serialize_url_sep+0x49c>
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   1030 <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   1030 <strncmp@plt>
cmp    $0x0,%rax
je     12dc <oauth_serialize_url_sep+0x12c>
cmpl   $0x0,-0x34(%rbp)
je     12dc <oauth_serialize_url_sep+0x12c>
jmp    164c <oauth_serialize_url_sep+0x49c>
mov    -0x48(%rbp),%rdi
call   1050 <strlen@plt>
add    -0x4c(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    13f6 <oauth_serialize_url_sep+0x246>
cmpl   $0x0,-0x34(%rbp)
jne    13f6 <oauth_serialize_url_sep+0x246>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xcf5(%rip),%rsi
call   10d0 <strstr@plt>
cmp    $0x0,%rax
je     13f6 <oauth_serialize_url_sep+0x246>
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   1060 <strchr@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     13e2 <oauth_serialize_url_sep+0x232>
mov    -0x30(%rbp),%rax
mov    -0x28(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x58(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <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   1040 <strcpy@plt>
mov    -0x60(%rbp),%rdi
add    -0x58(%rbp),%rdi
add    $0x2,%rdi
mov    -0x28(%rbp),%rsi
add    -0x58(%rbp),%rsi
call   1040 <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   1070 <xfree@plt>
mov    -0x60(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    1338 <oauth_serialize_url_sep+0x188>
mov    -0x28(%rbp),%rdi
call   1050 <strlen@plt>
add    -0x4c(%rbp),%eax
mov    %eax,-0x4c(%rbp)
jmp    1579 <oauth_serialize_url_sep+0x3c9>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    $0x3d,%esi
call   1060 <strchr@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    147c <oauth_serialize_url_sep+0x2cc>
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   1050 <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    0xba9(%rip),%rsi
call   10c0 <strcat@plt>
mov    -0x28(%rbp),%rdi
call   1050 <strlen@plt>
add    -0x4c(%rbp),%eax
mov    %eax,-0x4c(%rbp)
jmp    1574 <oauth_serialize_url_sep+0x3c4>
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   1050 <strlen@plt>
mov    %eax,-0x6c(%rbp)
mov    -0x30(%rbp),%rdi
call   1050 <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    0xb00(%rip),%rsi
call   10c0 <strcat@plt>
mov    -0x1c(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     1530 <oauth_serialize_url_sep+0x380>
mov    -0x28(%rbp),%rdi
lea    0xae3(%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     155c <oauth_serialize_url_sep+0x3ac>
mov    -0x28(%rbp),%rdi
lea    0xab7(%rip),%rsi
call   10c0 <strcat@plt>
mov    -0x30(%rbp),%rdi
call   1070 <xfree@plt>
mov    -0x28(%rbp),%rdi
call   1050 <strlen@plt>
add    -0x4c(%rbp),%eax
mov    %eax,-0x4c(%rbp)
jmp    1579 <oauth_serialize_url_sep+0x3c9>
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     15ba <oauth_serialize_url_sep+0x40a>
cmpl   $0x0,-0x38(%rbp)
je     15cd <oauth_serialize_url_sep+0x41d>
lea    0xa4e(%rip),%rax
mov    %rax,-0x88(%rbp)
jmp    15d8 <oauth_serialize_url_sep+0x428>
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    1643 <oauth_serialize_url_sep+0x493>
cmpl   $0x0,-0x34(%rbp)
jne    1643 <oauth_serialize_url_sep+0x493>
mov    -0x28(%rbp),%rdi
lea    0x9ec(%rip),%rsi
call   10d0 <strstr@plt>
cmp    $0x0,%rax
je     1643 <oauth_serialize_url_sep+0x493>
mov    -0x48(%rbp),%rdi
lea    0x9d9(%rip),%rsi
call   10c0 <strcat@plt>
movl   $0x1,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
call   1070 <xfree@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   1050 <strlen@plt>
mov    %eax,0x14(%rsp)
movl   $0x1,0x18(%rsp)
mov    $0x1,%edi
call   1090 <xmalloc@plt>
mov    %rax,%rbx
movb   $0x0,(%rax)
cmp    %ebp,%r14d
jge    153a <oauth_serialize_url_sep+0x38a>
mov    %r15d,%eax
and    $0x4,%eax
mov    %eax,0x20(%rsp)
shr    %eax
add    $0x2,%eax
mov    %eax,0x1c(%rsp)
addl   $0x1,0x14(%rsp)
movslq %r14d,%r13
mov    %r13,0x28(%rsp)
mov    %r15d,0x24(%rsp)
mov    %r12,0x30(%rsp)
mov    %ebp,0x10(%rsp)
jmp    1256 <oauth_serialize_url_sep+0xa6>
nopl   0x0(%rax,%rax,1)
mov    %ebp,0x18(%rsp)
mov    %r12,%rdi
call   1070 <xfree@plt>
mov    0x30(%rsp),%r12
mov    %r15d,%ebp
mov    0x24(%rsp),%r15d
add    $0x1,%r13
cmp    %ebp,%r13d
je     153a <oauth_serialize_url_sep+0x38a>
test   $0x1,%r15b
je     1290 <oauth_serialize_url_sep+0xe0>
mov    (%r12,%r13,8),%rdi
lea    0xd9b(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1249 <oauth_serialize_url_sep+0x99>
mov    (%r12,%r13,8),%rdi
lea    0xd7f(%rip),%rsi
mov    $0x8,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1249 <oauth_serialize_url_sep+0x99>
test   $0x2,%r15b
je     12e0 <oauth_serialize_url_sep+0x130>
mov    (%r12,%r13,8),%rdi
lea    0xd61(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     12e0 <oauth_serialize_url_sep+0x130>
mov    (%r12,%r13,8),%rdi
lea    0xd45(%rip),%rsi
mov    $0x8,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     12e0 <oauth_serialize_url_sep+0x130>
test   %r13,%r13
jne    1249 <oauth_serialize_url_sep+0x99>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,0x40(%rsp)
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %eax,%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    0xcf6(%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   1060 <strchr@plt>
test   %rax,%rax
je     1532 <oauth_serialize_url_sep+0x382>
mov    %rax,%r15
cs nopw 0x0(%rax,%rax,1)
mov    %r15,%rbx
sub    %r12,%rbx
mov    %r12,%rdi
call   1050 <strlen@plt>
lea    0x3(%rax),%edi
call   1090 <xmalloc@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %r12,%rsi
call   1040 <strcpy@plt>
lea    (%rbx,%rbp,1),%rdi
add    $0x2,%rdi
mov    %r15,%rsi
call   1040 <strcpy@plt>
movw   $0x3225,0x0(%rbp,%rbx,1)
movb   $0x30,0x2(%rbp,%rbx,1)
mov    %r12,%rdi
call   1070 <xfree@plt>
mov    %rbp,%rdi
mov    $0x20,%esi
call   1060 <strchr@plt>
mov    %rax,%r15
mov    %rbp,%r12
test   %rax,%rax
jne    1350 <oauth_serialize_url_sep+0x1a0>
mov    %rbp,%r12
jmp    149e <oauth_serialize_url_sep+0x2ee>
nopl   0x0(%rax,%rax,1)
mov    (%r12,%r13,8),%rbp
mov    %rbp,%rdi
mov    $0x3d,%esi
call   1060 <strchr@plt>
test   %rax,%rax
je     146e <oauth_serialize_url_sep+0x2be>
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   1050 <strlen@plt>
mov    %eax,%ebx
mov    %r15,%rdi
call   1050 <strlen@plt>
add    0x1c(%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,0x20(%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   1070 <xfree@plt>
jmp    149e <oauth_serialize_url_sep+0x2ee>
mov    %rbp,%rdi
call   10a0 <xstrdup@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <strlen@plt>
lea    0x2(%rax),%esi
mov    %rbx,%rdi
call   1080 <xrealloc@plt>
mov    %rax,%r12
mov    %rax,%rdi
lea    0xb73(%rip),%rsi
call   10c0 <strcat@plt>
mov    0x10(%rsp),%r15d
mov    %r12,%rdi
call   1050 <strlen@plt>
add    0x14(%rsp),%r14d
add    %eax,%r14d
mov    0x40(%rsp),%rdi
mov    %r14d,%esi
call   1080 <xrealloc@plt>
cmpl   $0x0,0x18(%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    %ebp,%r15d
jmp    14a3 <oauth_serialize_url_sep+0x2f3>
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 1, 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 = %279, %5
%27 = load i32, i32* %13
%28 = load i32, i32* %6
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %282
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 %279
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 %279
75: ; preds = %71, %63, %55, %51
%76 = load i8*, i8** %16
%77 = call i32 @strlen(i8* %76)
%78 = load i32, i32* %17
%79 = add nsw i32 %78, %77
store i32 %79, i32* %17
%80 = load i32, i32* %13
%81 = load i32, i32* %7
%82 = icmp eq i32 %80, %81
br i1 %82, label %83, label %149
83: ; preds = %75
%84 = load i32, i32* %13
%85 = icmp eq i32 %84, 0
br i1 %85, label %86, label %149
86: ; preds = %83
%87 = load i8**, i8*** %8
%88 = load i32, i32* %13
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds i8*, i8** %87, i64 %89
%91 = load i8*, i8** %90
%92 = call i64 @strstr(i8* %91, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%93 = icmp ne i64 %92, 0
br i1 %93, label %94, label %149
94: ; preds = %86
%95 = load i8**, i8*** %8
%96 = load i32, i32* %13
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds i8*, i8** %95, i64 %97
%99 = load i8*, i8** %98
%100 = call i8* @xstrdup(i8* %99)
store i8* %100, i8** %11
br label %101
101: ; preds = %105, %94
%102 = load i8*, i8** %11
%103 = call i8* @strchr(i8* %102, i8 signext 32)
store i8* %103, i8** %12
%104 = icmp ne i8* %103, null
br i1 %104, label %105, label %144
105: ; preds = %101
%106 = load i8*, i8** %12
%107 = load i8*, i8** %11
%108 = ptrtoint i8* %106 to i64
%109 = ptrtoint i8* %107 to i64
%110 = sub i64 %108, %109
store i64 %110, i64* %18
%111 = load i8*, i8** %11
%112 = call i32 @strlen(i8* %111)
%113 = add nsw i32 3, %112
%114 = sext i32 %113 to i64
%115 = mul i64 1, %114
%116 = trunc i64 %115 to i32
%117 = call i64 @xmalloc(i32 %116)
%118 = inttoptr i64 %117 to i8*
store i8* %118, i8** %19
%119 = load i8*, i8** %19
%120 = load i8*, i8** %11
%121 = call i32 @strcpy(i8* %119, i8* %120)
%122 = load i8*, i8** %19
%123 = load i64, i64* %18
%124 = getelementptr inbounds i8, i8* %122, i64 %123
%125 = getelementptr inbounds i8, i8* %124, i64 2
%126 = load i8*, i8** %11
%127 = load i64, i64* %18
%128 = getelementptr inbounds i8, i8* %126, i64 %127
%129 = call i32 @strcpy(i8* %125, i8* %128)
%130 = load i8*, i8** %19
%131 = load i64, i64* %18
%132 = getelementptr inbounds i8, i8* %130, i64 %131
store i8 37, i8* %132
%133 = load i8*, i8** %19
%134 = load i64, i64* %18
%135 = getelementptr inbounds i8, i8* %133, i64 %134
%136 = getelementptr inbounds i8, i8* %135, i64 1
store i8 50, 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 2
store i8 48, i8* %140
%141 = load i8*, i8** %11
%142 = call i32 @xfree(i8* %141)
%143 = load i8*, i8** %19
store i8* %143, i8** %11
br label %101
144: ; preds = %101
%145 = load i8*, i8** %11
%146 = call i32 @strlen(i8* %145)
%147 = load i32, i32* %17
%148 = add nsw i32 %147, %146
store i32 %148, i32* %17
br label %235
149: ; preds = %86, %83, %75
%150 = load i8**, i8*** %8
%151 = load i32, i32* %13
%152 = sext i32 %151 to i64
%153 = getelementptr inbounds i8*, i8** %150, i64 %152
%154 = load i8*, i8** %153
%155 = call i8* @strchr(i8* %154, i8 signext 61)
store i8* %155, i8** %12
%156 = icmp ne i8* %155, null
br i1 %156, label %179, label %157
157: ; preds = %149
%158 = load i8**, i8*** %8
%159 = load i32, i32* %13
%160 = sext i32 %159 to i64
%161 = getelementptr inbounds i8*, i8** %158, i64 %160
%162 = load i8*, i8** %161
%163 = call i8* @xstrdup(i8* %162)
store i8* %163, i8** %11
%164 = load i8*, i8** %11
%165 = load i8*, i8** %11
%166 = call i32 @strlen(i8* %165)
%167 = add nsw i32 %166, 2
%168 = sext i32 %167 to i64
%169 = mul i64 %168, 1
%170 = trunc i64 %169 to i32
%171 = call i64 @xrealloc(i8* %164, i32 %170)
%172 = inttoptr i64 %171 to i8*
store i8* %172, i8** %11
%173 = load i8*, i8** %11
%174 = call i32 @strcat(i8* %173, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%175 = load i8*, i8** %11
%176 = call i32 @strlen(i8* %175)
%177 = load i32, i32* %17
%178 = add nsw i32 %177, %176
store i32 %178, i32* %17
br label %234
179: ; preds = %149
%180 = load i8*, i8** %12
store i8 0, i8* %180
%181 = load i8**, i8*** %8
%182 = load i32, i32* %13
%183 = sext i32 %182 to i64
%184 = getelementptr inbounds i8*, i8** %181, i64 %183
%185 = load i8*, i8** %184
%186 = call i8* @oauth_url_escape(i8* %185)
store i8* %186, i8** %11
%187 = load i8*, i8** %12
store i8 61, i8* %187
%188 = load i8*, i8** %12
%189 = getelementptr inbounds i8, i8* %188, i64 1
%190 = call i8* @oauth_url_escape(i8* %189)
store i8* %190, i8** %12
%191 = load i8*, i8** %11
%192 = load i8*, i8** %11
%193 = call i32 @strlen(i8* %192)
%194 = load i8*, i8** %12
%195 = call i32 @strlen(i8* %194)
%196 = add nsw i32 %193, %195
%197 = add nsw i32 %196, 2
%198 = load i32, i32* %10
%199 = and i32 %198, 4
%200 = icmp ne i32 %199, 0
%201 = zext i1 %200 to i64
%202 = select i1 %200, i32 2, i32 0
%203 = add nsw i32 %197, %202
%204 = sext i32 %203 to i64
%205 = mul i64 %204, 1
%206 = trunc i64 %205 to i32
%207 = call i64 @xrealloc(i8* %191, i32 %206)
%208 = inttoptr i64 %207 to i8*
store i8* %208, i8** %11
%209 = load i8*, i8** %11
%210 = call i32 @strcat(i8* %209, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%211 = load i32, i32* %10
%212 = and i32 %211, 4
%213 = icmp ne i32 %212, 0
br i1 %213, label %214, label %217
214: ; preds = %179
%215 = load i8*, i8** %11
%216 = call i32 @strcat(i8* %215, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %217
217: ; preds = %214, %179
%218 = load i8*, i8** %11
%219 = load i8*, i8** %12
%220 = call i32 @strcat(i8* %218, i8* %219)
%221 = load i32, i32* %10
%222 = and i32 %221, 4
%223 = icmp ne i32 %222, 0
br i1 %223, label %224, label %227
224: ; preds = %217
%225 = load i8*, i8** %11
%226 = call i32 @strcat(i8* %225, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %227
227: ; preds = %224, %217
%228 = load i8*, i8** %12
%229 = call i32 @xfree(i8* %228)
%230 = load i8*, i8** %11
%231 = call i32 @strlen(i8* %230)
%232 = load i32, i32* %17
%233 = add nsw i32 %232, %231
store i32 %233, i32* %17
br label %234
234: ; preds = %227, %157
br label %235
235: ; preds = %234, %144
%236 = load i32, i32* %15
%237 = add nsw i32 %236, 1
%238 = load i32, i32* %17
%239 = add nsw i32 %238, %237
store i32 %239, i32* %17
%240 = load i8*, i8** %16
%241 = load i32, i32* %17
%242 = sext i32 %241 to i64
%243 = mul i64 %242, 1
%244 = trunc i64 %243 to i32
%245 = call i64 @xrealloc(i8* %240, i32 %244)
%246 = inttoptr i64 %245 to i8*
store i8* %246, i8** %16
%247 = load i8*, i8** %16
%248 = load i32, i32* %13
%249 = load i32, i32* %7
%250 = icmp eq i32 %248, %249
br i1 %250, label %254, label %251
251: ; preds = %235
%252 = load i32, i32* %14
%253 = icmp ne i32 %252, 0
br i1 %253, label %254, label %255
254: ; preds = %251, %235
br label %257
255: ; preds = %251
%256 = load i8*, i8** %9
br label %257
257: ; preds = %255, %254
%258 = phi i8* [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0), %254 ], [ %256, %255 ]
%259 = call i32 @strcat(i8* %247, i8* %258)
store i32 0, i32* %14
%260 = load i8*, i8** %16
%261 = load i8*, i8** %11
%262 = call i32 @strcat(i8* %260, i8* %261)
%263 = load i32, i32* %13
%264 = load i32, i32* %7
%265 = icmp eq i32 %263, %264
br i1 %265, label %266, label %276
266: ; preds = %257
%267 = load i32, i32* %13
%268 = icmp eq i32 %267, 0
br i1 %268, label %269, label %276
269: ; preds = %266
%270 = load i8*, i8** %11
%271 = call i64 @strstr(i8* %270, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%272 = icmp ne i64 %271, 0
br i1 %272, label %273, label %276
273: ; preds = %269
%274 = load i8*, i8** %16
%275 = call i32 @strcat(i8* %274, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %14
br label %276
276: ; preds = %273, %269, %266, %257
%277 = load i8*, i8** %11
%278 = call i32 @xfree(i8* %277)
br label %279
279: ; preds = %276, %74, %50
%280 = load i32, i32* %13
%281 = add nsw i32 %280, 1
store i32 %281, i32* %13
br label %26
282: ; preds = %26
%283 = load i8*, i8** %16
ret i8* %283
}

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 %138
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, %132
%22 = phi i64 [ %20, %10 ], [ %135, %132 ]
%23 = phi i8* [ %8, %10 ], [ %134, %132 ]
%24 = phi i32 [ 1, %10 ], [ %133, %132 ]
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 %132, 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 %132, 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 %132, label %46
46: ; preds = %40, %35, %34
%47 = tail call i32 @strlen(i8* %23)
%48 = icmp eq i64 %22, %20
%49 = icmp eq i64 %22, 0
%50 = and i1 %48, %49
br i1 %50, label %51, label %81
51: ; preds = %46
%52 = load i8*, i8** %2
%53 = tail call i64 @strstr(i8* %52, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%54 = icmp eq i64 %53, 0
br i1 %54, label %81, label %55
55: ; preds = %51
%56 = load i8*, i8** %2
%57 = tail call i8* @xstrdup(i8* %56)
%58 = tail call i8* @strchr(i8* dereferenceable(1) %57, i8 signext 32)
%59 = icmp eq i8* %58, null
br i1 %59, label %112, label %60
60: ; preds = %55, %60
%61 = phi i8* [ %77, %60 ], [ %58, %55 ]
%62 = phi i8* [ %69, %60 ], [ %57, %55 ]
%63 = ptrtoint i8* %61 to i64
%64 = ptrtoint i8* %62 to i64
%65 = sub i64 %63, %64
%66 = tail call i32 @strlen(i8* %62)
%67 = add nsw i32 %66, 3
%68 = tail call i64 @xmalloc(i32 %67)
%69 = inttoptr i64 %68 to i8*
%70 = tail call i32 @strcpy(i8* %69, i8* %62)
%71 = getelementptr inbounds i8, i8* %69, i64 %65
%72 = getelementptr inbounds i8, i8* %71, i64 2
%73 = getelementptr inbounds i8, i8* %62, i64 %65
%74 = tail call i32 @strcpy(i8* %72, i8* %73)
store i8 37, i8* %71
%75 = getelementptr inbounds i8, i8* %71, i64 1
store i8 50, i8* %75
store i8 48, i8* %72
%76 = tail call i32 @xfree(i8* %62)
%77 = tail call i8* @strchr(i8* dereferenceable(1) %69, i8 signext 32)
%78 = icmp eq i8* %77, null
br i1 %78, label %79, label %60
79: ; preds = %60
%80 = inttoptr i64 %68 to i8*
br label %112
81: ; preds = %51, %46
%82 = getelementptr inbounds i8*, i8** %2, i64 %22
%83 = load i8*, i8** %82
%84 = tail call i8* @strchr(i8* dereferenceable(1) %83, i8 signext 61)
%85 = icmp eq i8* %84, null
br i1 %85, label %86, label %93
86: ; preds = %81
%87 = tail call i8* @xstrdup(i8* %83)
%88 = tail call i32 @strlen(i8* %87)
%89 = add nsw i32 %88, 2
%90 = tail call i64 @xrealloc(i8* %87, i32 %89)
%91 = inttoptr i64 %90 to i8*
%92 = tail call i32 @strcat(i8* %91, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %112
93: ; preds = %81
store i8 0, i8* %84
%94 = load i8*, i8** %82
%95 = tail call i8* @oauth_url_escape(i8* %94)
store i8 61, i8* %84
%96 = getelementptr inbounds i8, i8* %84, i64 1
%97 = tail call i8* @oauth_url_escape(i8* %96)
%98 = tail call i32 @strlen(i8* %95)
%99 = tail call i32 @strlen(i8* %97)
%100 = add i32 %18, %98
%101 = add i32 %100, %99
%102 = tail call i64 @xrealloc(i8* %95, i32 %101)
%103 = inttoptr i64 %102 to i8*
%104 = tail call i32 @strcat(i8* %103, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br i1 %16, label %108, label %105
105: ; preds = %93
%106 = tail call i32 @strcat(i8* %103, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%107 = tail call i32 @strcat(i8* %103, i8* %97)
br label %108
108: ; preds = %93, %105
%109 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), %105 ], [ %97, %93 ]
%110 = tail call i32 @strcat(i8* %103, i8* %109)
%111 = tail call i32 @xfree(i8* %97)
br label %112
112: ; preds = %55, %79, %86, %108
%113 = phi i8* [ %91, %86 ], [ %103, %108 ], [ %57, %55 ], [ %80, %79 ]
%114 = tail call i32 @strlen(i8* %113)
%115 = add i32 %19, %47
%116 = add i32 %115, %114
%117 = tail call i64 @xrealloc(i8* %23, i32 %116)
%118 = inttoptr i64 %117 to i8*
%119 = icmp ne i32 %24, 0
%120 = select i1 %48, i1 true, i1 %119
%121 = select i1 %120, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0), i8* %3
%122 = tail call i32 @strcat(i8* %118, i8* %121)
%123 = tail call i32 @strcat(i8* %118, i8* %113)
br i1 %50, label %124, label %129
124: ; preds = %112
%125 = tail call i64 @strstr(i8* %113, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%126 = icmp eq i64 %125, 0
br i1 %126, label %129, label %127
127: ; preds = %124
%128 = tail call i32 @strcat(i8* %118, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %129
129: ; preds = %127, %124, %112
%130 = phi i32 [ 1, %127 ], [ 0, %124 ], [ 0, %112 ]
%131 = tail call i32 @xfree(i8* %113)
br label %132
132: ; preds = %40, %25, %30, %129
%133 = phi i32 [ %130, %129 ], [ %24, %30 ], [ %24, %25 ], [ %24, %40 ]
%134 = phi i8* [ %118, %129 ], [ %23, %30 ], [ %23, %25 ], [ %23, %40 ]
%135 = add nsw i64 %22, 1
%136 = trunc i64 %135 to i32
%137 = icmp eq i32 %136, %0
br i1 %137, label %138, label %21
138: ; preds = %132, %5
%139 = phi i8* [ %8, %5 ], [ %134, %132 ]
ret i8* %139
}