#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 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]);
      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    $0x80,%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   1050 <strlen@plt>
mov    %eax,-0x3c(%rbp)
mov    $0x1,%edi
call   1080 <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    15a2 <oauth_serialize_url_sep+0x402>
movl   $0x0,-0x4c(%rbp)
mov    -0x1c(%rbp),%eax
and    $0x1,%eax
cmp    $0x1,%eax
jne    1260 <oauth_serialize_url_sep+0xc0>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xde2(%rip),%rsi
mov    $0x6,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
je     125b <oauth_serialize_url_sep+0xbb>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xdb9(%rip),%rsi
mov    $0x8,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    1260 <oauth_serialize_url_sep+0xc0>
jmp    1594 <oauth_serialize_url_sep+0x3f4>
mov    -0x1c(%rbp),%eax
and    $0x2,%eax
cmp    $0x2,%eax
jne    12cc <oauth_serialize_url_sep+0x12c>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd80(%rip),%rsi
mov    $0x6,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
je     12cc <oauth_serialize_url_sep+0x12c>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd57(%rip),%rsi
mov    $0x8,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
je     12cc <oauth_serialize_url_sep+0x12c>
cmpl   $0x0,-0x34(%rbp)
je     12cc <oauth_serialize_url_sep+0x12c>
jmp    1594 <oauth_serialize_url_sep+0x3f4>
cmpq   $0x0,-0x48(%rbp)
je     12e6 <oauth_serialize_url_sep+0x146>
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    1347 <oauth_serialize_url_sep+0x1a7>
cmpl   $0x0,-0x34(%rbp)
jne    1347 <oauth_serialize_url_sep+0x1a7>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xcfa(%rip),%rsi
call   10c0 <strstr@plt>
cmp    $0x0,%rax
je     1347 <oauth_serialize_url_sep+0x1a7>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1090 <xstrdup@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <strlen@plt>
add    -0x4c(%rbp),%eax
mov    %eax,-0x4c(%rbp)
jmp    14ca <oauth_serialize_url_sep+0x32a>
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    13cd <oauth_serialize_url_sep+0x22d>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1090 <xstrdup@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x58(%rbp),%rdi
add    $0x2,%eax
cltq
shl    $0x0,%rax
mov    %eax,%esi
call   1070 <xrealloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xc58(%rip),%rsi
call   10b0 <strcat@plt>
mov    -0x28(%rbp),%rdi
call   1050 <strlen@plt>
add    -0x4c(%rbp),%eax
mov    %eax,-0x4c(%rbp)
jmp    14c5 <oauth_serialize_url_sep+0x325>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   10a0 <oauth_url_escape@plt>
mov    %rax,-0x28(%rbp)
mov    -0x30(%rbp),%rax
movb   $0x3d,(%rax)
mov    -0x30(%rbp),%rdi
add    $0x1,%rdi
call   10a0 <oauth_url_escape@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x30(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x68(%rbp),%rdi
mov    %eax,%ecx
mov    -0x5c(%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   1070 <xrealloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xbaf(%rip),%rsi
call   10b0 <strcat@plt>
mov    -0x1c(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     1481 <oauth_serialize_url_sep+0x2e1>
mov    -0x28(%rbp),%rdi
lea    0xb92(%rip),%rsi
call   10b0 <strcat@plt>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   10b0 <strcat@plt>
mov    -0x1c(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     14ad <oauth_serialize_url_sep+0x30d>
mov    -0x28(%rbp),%rdi
lea    0xb66(%rip),%rsi
call   10b0 <strcat@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1050 <strlen@plt>
add    -0x4c(%rbp),%eax
mov    %eax,-0x4c(%rbp)
jmp    14ca <oauth_serialize_url_sep+0x32a>
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   1070 <xrealloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x8(%rbp),%eax
je     150b <oauth_serialize_url_sep+0x36b>
cmpl   $0x0,-0x38(%rbp)
je     151b <oauth_serialize_url_sep+0x37b>
lea    0xafd(%rip),%rax
mov    %rax,-0x78(%rbp)
jmp    1523 <oauth_serialize_url_sep+0x383>
mov    -0x18(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x70(%rbp),%rdi
mov    -0x78(%rbp),%rsi
call   10b0 <strcat@plt>
movl   $0x0,-0x38(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   10b0 <strcat@plt>
mov    -0x34(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    158b <oauth_serialize_url_sep+0x3eb>
cmpl   $0x0,-0x34(%rbp)
jne    158b <oauth_serialize_url_sep+0x3eb>
mov    -0x28(%rbp),%rdi
lea    0xaa4(%rip),%rsi
call   10c0 <strstr@plt>
cmp    $0x0,%rax
je     158b <oauth_serialize_url_sep+0x3eb>
mov    -0x48(%rbp),%rdi
lea    0xa91(%rip),%rsi
call   10b0 <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    11eb <oauth_serialize_url_sep+0x4b>
mov    -0x48(%rbp),%rax
add    $0x80,%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,%r13d
mov    %rdx,0x8(%rsp)
mov    %esi,%r14d
mov    %edi,%r15d
mov    %rcx,0x40(%rsp)
mov    %rcx,%rdi
call   1050 <strlen@plt>
mov    %eax,0x4(%rsp)
mov    $0x1,%edi
call   1080 <xmalloc@plt>
mov    %rax,%rbp
movb   $0x0,(%rax)
mov    %r15,0x10(%rsp)
cmp    %r15d,%r14d
jge    14d0 <oauth_serialize_url_sep+0x330>
mov    %r13d,%eax
and    $0x4,%eax
mov    %eax,0x1c(%rsp)
shr    %eax
add    $0x2,%eax
mov    %eax,0x18(%rsp)
addl   $0x1,0x4(%rsp)
movslq %r14d,%rcx
mov    0x8(%rsp),%rax
lea    (%rax,%rcx,8),%rax
neg    %rcx
mov    %rcx,0x28(%rsp)
mov    0x10(%rsp),%rcx
sub    %r14d,%ecx
mov    %rcx,0x10(%rsp)
mov    %rax,%r14
xor    %r12d,%r12d
xor    %r15d,%r15d
mov    %rax,0x38(%rsp)
mov    %r13d,0x20(%rsp)
jmp    125c <oauth_serialize_url_sep+0xbc>
nopl   0x0(%rax)
mov    %r14,%rdi
call   1030 <free@plt>
mov    0x38(%rsp),%r14
add    $0x1,%r12
cmp    %r12d,0x10(%rsp)
je     14d0 <oauth_serialize_url_sep+0x330>
test   $0x1,%r13b
je     1296 <oauth_serialize_url_sep+0xf6>
mov    (%r14,%r12,8),%rdi
lea    0xd95(%rip),%rsi
mov    $0x6,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     124d <oauth_serialize_url_sep+0xad>
mov    (%r14,%r12,8),%rdi
lea    0xd79(%rip),%rsi
mov    $0x8,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     124d <oauth_serialize_url_sep+0xad>
test   $0x2,%r13b
je     12e0 <oauth_serialize_url_sep+0x140>
mov    (%r14,%r12,8),%rdi
lea    0xd5b(%rip),%rsi
mov    $0x6,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     12e0 <oauth_serialize_url_sep+0x140>
mov    (%r14,%r12,8),%rdi
lea    0xd3f(%rip),%rsi
mov    $0x8,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     12e0 <oauth_serialize_url_sep+0x140>
cmp    %r12,0x28(%rsp)
jne    124d <oauth_serialize_url_sep+0xad>
nopl   0x0(%rax,%rax,1)
test   %rbp,%rbp
mov    %r15d,0x24(%rsp)
je     1300 <oauth_serialize_url_sep+0x160>
mov    %rbp,%rdi
call   1050 <strlen@plt>
mov    %eax,%r15d
jmp    1303 <oauth_serialize_url_sep+0x163>
nopw   0x0(%rax,%rax,1)
xor    %r15d,%r15d
mov    0x28(%rsp),%rax
xor    %r12,%rax
or     %r12,%rax
sete   %bl
jne    1350 <oauth_serialize_url_sep+0x1b0>
mov    0x8(%rsp),%rax
mov    (%rax),%rdi
lea    0xce7(%rip),%rsi
call   10c0 <strstr@plt>
test   %rax,%rax
je     1350 <oauth_serialize_url_sep+0x1b0>
mov    0x8(%rsp),%rax
mov    (%rax),%rdi
call   1090 <xstrdup@plt>
mov    %rax,%r14
jmp    1446 <oauth_serialize_url_sep+0x2a6>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %bl,0x3(%rsp)
mov    %rbp,0x30(%rsp)
mov    (%r14,%r12,8),%rbp
mov    %rbp,%rdi
mov    $0x3d,%esi
call   1060 <strchr@plt>
test   %rax,%rax
je     140c <oauth_serialize_url_sep+0x26c>
mov    %rax,%rbx
movb   $0x0,(%rax)
mov    (%r14,%r12,8),%rdi
call   10a0 <oauth_url_escape@plt>
mov    %rax,%rbp
movb   $0x3d,(%rbx)
add    $0x1,%rbx
mov    %rbx,%rdi
call   10a0 <oauth_url_escape@plt>
mov    %rax,%r13
mov    %rbp,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebx
mov    %r13,%rdi
call   1050 <strlen@plt>
add    0x18(%rsp),%ebx
add    %eax,%ebx
mov    %rbp,%rdi
mov    %ebx,%esi
call   1070 <xrealloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
lea    0xc46(%rip),%rsi
call   10b0 <strcat@plt>
mov    %r13,%rsi
cmpl   $0x0,0x1c(%rsp)
je     13f5 <oauth_serialize_url_sep+0x255>
mov    %r14,%rdi
lea    0xc2f(%rip),%rbx
mov    %rbx,%rsi
call   10b0 <strcat@plt>
mov    %r14,%rdi
mov    %r13,%rsi
call   10b0 <strcat@plt>
mov    %rbx,%rsi
mov    %r14,%rdi
call   10b0 <strcat@plt>
mov    %r13,%rdi
call   1030 <free@plt>
mov    0x20(%rsp),%r13d
jmp    143c <oauth_serialize_url_sep+0x29c>
mov    %rbp,%rdi
call   1090 <xstrdup@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <strlen@plt>
lea    0x2(%rax),%esi
mov    %rbx,%rdi
call   1070 <xrealloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
lea    0xbd5(%rip),%rsi
call   10b0 <strcat@plt>
mov    0x30(%rsp),%rbp
movzbl 0x3(%rsp),%ebx
mov    %r14,%rdi
call   1050 <strlen@plt>
add    0x4(%rsp),%r15d
add    %eax,%r15d
mov    %rbp,%rdi
mov    %r15d,%esi
call   1070 <xrealloc@plt>
cmpl   $0x0,0x24(%rsp)
mov    0x40(%rsp),%rsi
lea    0xb9d(%rip),%rcx
cmovne %rcx,%rsi
mov    %rax,%rbp
test   %r12,%r12
cmove  %rcx,%rsi
mov    %rax,%rdi
call   10b0 <strcat@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
call   10b0 <strcat@plt>
xor    %r15d,%r15d
test   %bl,%bl
je     1240 <oauth_serialize_url_sep+0xa0>
mov    %r14,%rdi
lea    0xb61(%rip),%rsi
call   10c0 <strstr@plt>
test   %rax,%rax
je     1240 <oauth_serialize_url_sep+0xa0>
mov    %rbp,%rdi
lea    0xb50(%rip),%rsi
call   10b0 <strcat@plt>
mov    $0x1,%r15d
jmp    1240 <oauth_serialize_url_sep+0xa0>
mov    %rbp,%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
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
%18 = load i8*, i8** %9
%19 = call i32 @strlen(i8* %18)
store i32 %19, i32* %15
%20 = call i64 @xmalloc(i32 1)
%21 = inttoptr i64 %20 to i8*
store i8* %21, i8** %16
%22 = load i8*, i8** %16
store i8 0, i8* %22
%23 = load i32, i32* %7
store i32 %23, i32* %13
br label %24
24: ; preds = %237, %5
%25 = load i32, i32* %13
%26 = load i32, i32* %6
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %240
28: ; preds = %24
store i32 0, i32* %17
%29 = load i32, i32* %10
%30 = and i32 %29, 1
%31 = icmp eq i32 %30, 1
br i1 %31, label %32, label %49
32: ; preds = %28
%33 = load i8**, i8*** %8
%34 = load i32, i32* %13
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8*, i8** %33, i64 %35
%37 = load i8*, i8** %36
%38 = 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 %48, label %40
40: ; preds = %32
%41 = load i8**, i8*** %8
%42 = load i32, i32* %13
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8*, i8** %41, i64 %43
%45 = load i8*, i8** %44
%46 = call i64 @strncmp(i8* %45, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 8)
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %49
48: ; preds = %40, %32
br label %237
49: ; preds = %40, %28
%50 = load i32, i32* %10
%51 = and i32 %50, 2
%52 = icmp eq i32 %51, 2
br i1 %52, label %53, label %73
53: ; preds = %49
%54 = load i8**, i8*** %8
%55 = load i32, i32* %13
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8*, i8** %54, i64 %56
%58 = load i8*, i8** %57
%59 = call i64 @strncmp(i8* %58, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 6)
%60 = icmp ne i64 %59, 0
br i1 %60, label %61, label %73
61: ; preds = %53
%62 = load i8**, i8*** %8
%63 = load i32, i32* %13
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i8*, i8** %62, i64 %64
%66 = load i8*, i8** %65
%67 = call i64 @strncmp(i8* %66, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 8)
%68 = icmp ne i64 %67, 0
br i1 %68, label %69, label %73
69: ; preds = %61
%70 = load i32, i32* %13
%71 = icmp ne i32 %70, 0
br i1 %71, label %72, label %73
72: ; preds = %69
br label %237
73: ; preds = %69, %61, %53, %49
%74 = load i8*, i8** %16
%75 = icmp ne i8* %74, null
br i1 %75, label %76, label %81
76: ; preds = %73
%77 = load i8*, i8** %16
%78 = call i32 @strlen(i8* %77)
%79 = load i32, i32* %17
%80 = add nsw i32 %79, %78
store i32 %80, i32* %17
br label %81
81: ; preds = %76, %73
%82 = load i32, i32* %13
%83 = load i32, i32* %7
%84 = icmp eq i32 %82, %83
br i1 %84, label %85, label %107
85: ; preds = %81
%86 = load i32, i32* %13
%87 = icmp eq i32 %86, 0
br i1 %87, label %88, label %107
88: ; preds = %85
%89 = load i8**, i8*** %8
%90 = load i32, i32* %13
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds i8*, i8** %89, i64 %91
%93 = load i8*, i8** %92
%94 = call i64 @strstr(i8* %93, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%95 = icmp ne i64 %94, 0
br i1 %95, label %96, label %107
96: ; preds = %88
%97 = load i8**, i8*** %8
%98 = load i32, i32* %13
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds i8*, i8** %97, i64 %99
%101 = load i8*, i8** %100
%102 = call i8* @xstrdup(i8* %101)
store i8* %102, i8** %11
%103 = load i8*, i8** %11
%104 = call i32 @strlen(i8* %103)
%105 = load i32, i32* %17
%106 = add nsw i32 %105, %104
store i32 %106, i32* %17
br label %193
107: ; preds = %88, %85, %81
%108 = load i8**, i8*** %8
%109 = load i32, i32* %13
%110 = sext i32 %109 to i64
%111 = getelementptr inbounds i8*, i8** %108, i64 %110
%112 = load i8*, i8** %111
%113 = call i8* @strchr(i8* %112, i8 signext 61)
store i8* %113, i8** %12
%114 = icmp ne i8* %113, null
br i1 %114, label %137, label %115
115: ; preds = %107
%116 = load i8**, i8*** %8
%117 = load i32, i32* %13
%118 = sext i32 %117 to i64
%119 = getelementptr inbounds i8*, i8** %116, i64 %118
%120 = load i8*, i8** %119
%121 = call i8* @xstrdup(i8* %120)
store i8* %121, i8** %11
%122 = load i8*, i8** %11
%123 = load i8*, i8** %11
%124 = call i32 @strlen(i8* %123)
%125 = add nsw i32 %124, 2
%126 = sext i32 %125 to i64
%127 = mul i64 %126, 1
%128 = trunc i64 %127 to i32
%129 = call i64 @xrealloc(i8* %122, i32 %128)
%130 = inttoptr i64 %129 to i8*
store i8* %130, i8** %11
%131 = load i8*, i8** %11
%132 = call i32 @strcat(i8* %131, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%133 = load i8*, i8** %11
%134 = call i32 @strlen(i8* %133)
%135 = load i32, i32* %17
%136 = add nsw i32 %135, %134
store i32 %136, i32* %17
br label %192
137: ; preds = %107
%138 = load i8*, i8** %12
store i8 0, i8* %138
%139 = load i8**, i8*** %8
%140 = load i32, i32* %13
%141 = sext i32 %140 to i64
%142 = getelementptr inbounds i8*, i8** %139, i64 %141
%143 = load i8*, i8** %142
%144 = call i8* @oauth_url_escape(i8* %143)
store i8* %144, i8** %11
%145 = load i8*, i8** %12
store i8 61, i8* %145
%146 = load i8*, i8** %12
%147 = getelementptr inbounds i8, i8* %146, i64 1
%148 = call i8* @oauth_url_escape(i8* %147)
store i8* %148, i8** %12
%149 = load i8*, i8** %11
%150 = load i8*, i8** %11
%151 = call i32 @strlen(i8* %150)
%152 = load i8*, i8** %12
%153 = call i32 @strlen(i8* %152)
%154 = add nsw i32 %151, %153
%155 = add nsw i32 %154, 2
%156 = load i32, i32* %10
%157 = and i32 %156, 4
%158 = icmp ne i32 %157, 0
%159 = zext i1 %158 to i64
%160 = select i1 %158, i32 2, i32 0
%161 = add nsw i32 %155, %160
%162 = sext i32 %161 to i64
%163 = mul i64 %162, 1
%164 = trunc i64 %163 to i32
%165 = call i64 @xrealloc(i8* %149, i32 %164)
%166 = inttoptr i64 %165 to i8*
store i8* %166, i8** %11
%167 = load i8*, i8** %11
%168 = call i32 @strcat(i8* %167, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%169 = load i32, i32* %10
%170 = and i32 %169, 4
%171 = icmp ne i32 %170, 0
br i1 %171, label %172, label %175
172: ; preds = %137
%173 = load i8*, i8** %11
%174 = call i32 @strcat(i8* %173, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %175
175: ; preds = %172, %137
%176 = load i8*, i8** %11
%177 = load i8*, i8** %12
%178 = call i32 @strcat(i8* %176, i8* %177)
%179 = load i32, i32* %10
%180 = and i32 %179, 4
%181 = icmp ne i32 %180, 0
br i1 %181, label %182, label %185
182: ; preds = %175
%183 = load i8*, i8** %11
%184 = call i32 @strcat(i8* %183, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %185
185: ; preds = %182, %175
%186 = load i8*, i8** %12
%187 = call i32 @free(i8* %186)
%188 = load i8*, i8** %11
%189 = call i32 @strlen(i8* %188)
%190 = load i32, i32* %17
%191 = add nsw i32 %190, %189
store i32 %191, i32* %17
br label %192
192: ; preds = %185, %115
br label %193
193: ; preds = %192, %96
%194 = load i32, i32* %15
%195 = add nsw i32 %194, 1
%196 = load i32, i32* %17
%197 = add nsw i32 %196, %195
store i32 %197, i32* %17
%198 = load i8*, i8** %16
%199 = load i32, i32* %17
%200 = sext i32 %199 to i64
%201 = mul i64 %200, 1
%202 = trunc i64 %201 to i32
%203 = call i64 @xrealloc(i8* %198, i32 %202)
%204 = inttoptr i64 %203 to i8*
store i8* %204, i8** %16
%205 = load i8*, i8** %16
%206 = load i32, i32* %13
%207 = load i32, i32* %7
%208 = icmp eq i32 %206, %207
br i1 %208, label %212, label %209
209: ; preds = %193
%210 = load i32, i32* %14
%211 = icmp ne i32 %210, 0
br i1 %211, label %212, label %213
212: ; preds = %209, %193
br label %215
213: ; preds = %209
%214 = load i8*, i8** %9
br label %215
215: ; preds = %213, %212
%216 = phi i8* [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0), %212 ], [ %214, %213 ]
%217 = call i32 @strcat(i8* %205, i8* %216)
store i32 0, i32* %14
%218 = load i8*, i8** %16
%219 = load i8*, i8** %11
%220 = call i32 @strcat(i8* %218, i8* %219)
%221 = load i32, i32* %13
%222 = load i32, i32* %7
%223 = icmp eq i32 %221, %222
br i1 %223, label %224, label %234
224: ; preds = %215
%225 = load i32, i32* %13
%226 = icmp eq i32 %225, 0
br i1 %226, label %227, label %234
227: ; preds = %224
%228 = load i8*, i8** %11
%229 = call i64 @strstr(i8* %228, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%230 = icmp ne i64 %229, 0
br i1 %230, label %231, label %234
231: ; preds = %227
%232 = load i8*, i8** %16
%233 = call i32 @strcat(i8* %232, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %14
br label %234
234: ; preds = %231, %227, %224, %215
%235 = load i8*, i8** %11
%236 = call i32 @free(i8* %235)
br label %237
237: ; preds = %234, %72, %48
%238 = load i32, i32* %13
%239 = add nsw i32 %238, 1
store i32 %239, i32* %13
br label %24
240: ; preds = %24
%241 = load i8*, i8** %16
ret i8* %241
}

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 %119
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, %113
%22 = phi i64 [ %20, %10 ], [ %116, %113 ]
%23 = phi i8* [ %8, %10 ], [ %115, %113 ]
%24 = phi i32 [ 0, %10 ], [ %114, %113 ]
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 %113, 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 %113, 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 %113, 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 %62
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 %62, label %59
59: ; preds = %55
%60 = load i8*, i8** %2
%61 = tail call i8* @xstrdup(i8* %60)
br label %93
62: ; preds = %55, %50
%63 = getelementptr inbounds i8*, i8** %2, i64 %22
%64 = load i8*, i8** %63
%65 = tail call i8* @strchr(i8* dereferenceable(1) %64, i8 signext 61)
%66 = icmp eq i8* %65, null
br i1 %66, label %67, label %74
67: ; preds = %62
%68 = tail call i8* @xstrdup(i8* %64)
%69 = tail call i32 @strlen(i8* %68)
%70 = add nsw i32 %69, 2
%71 = tail call i64 @xrealloc(i8* %68, i32 %70)
%72 = inttoptr i64 %71 to i8*
%73 = tail call i32 @strcat(i8* %72, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %93
74: ; preds = %62
store i8 0, i8* %65
%75 = load i8*, i8** %63
%76 = tail call i8* @oauth_url_escape(i8* %75)
store i8 61, i8* %65
%77 = getelementptr inbounds i8, i8* %65, i64 1
%78 = tail call i8* @oauth_url_escape(i8* %77)
%79 = tail call i32 @strlen(i8* %76)
%80 = tail call i32 @strlen(i8* %78)
%81 = add i32 %18, %79
%82 = add i32 %81, %80
%83 = tail call i64 @xrealloc(i8* %76, i32 %82)
%84 = inttoptr i64 %83 to i8*
%85 = tail call i32 @strcat(i8* %84, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br i1 %16, label %89, label %86
86: ; preds = %74
%87 = tail call i32 @strcat(i8* %84, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%88 = tail call i32 @strcat(i8* %84, i8* %78)
br label %89
89: ; preds = %74, %86
%90 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), %86 ], [ %78, %74 ]
%91 = tail call i32 @strcat(i8* %84, i8* %90)
%92 = tail call i32 @free(i8* %78)
br label %93
93: ; preds = %67, %89, %59
%94 = phi i8* [ %72, %67 ], [ %84, %89 ], [ %61, %59 ]
%95 = tail call i32 @strlen(i8* %94)
%96 = add i32 %19, %51
%97 = add i32 %96, %95
%98 = tail call i64 @xrealloc(i8* %23, i32 %97)
%99 = inttoptr i64 %98 to i8*
%100 = icmp ne i32 %24, 0
%101 = select i1 %52, i1 true, i1 %100
%102 = select i1 %101, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0), i8* %3
%103 = tail call i32 @strcat(i8* %99, i8* %102)
%104 = tail call i32 @strcat(i8* %99, i8* %94)
br i1 %54, label %105, label %110
105: ; preds = %93
%106 = tail call i64 @strstr(i8* %94, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%107 = icmp eq i64 %106, 0
br i1 %107, label %110, label %108
108: ; preds = %105
%109 = tail call i32 @strcat(i8* %99, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %110
110: ; preds = %108, %105, %93
%111 = phi i32 [ 1, %108 ], [ 0, %105 ], [ 0, %93 ]
%112 = tail call i32 @free(i8* %94)
br label %113
113: ; preds = %40, %25, %30, %110
%114 = phi i32 [ %111, %110 ], [ %24, %30 ], [ %24, %25 ], [ %24, %40 ]
%115 = phi i8* [ %99, %110 ], [ %23, %30 ], [ %23, %25 ], [ %23, %40 ]
%116 = add nsw i64 %22, 1
%117 = trunc i64 %116 to i32
%118 = icmp eq i32 %117, %0
br i1 %118, label %119, label %21
119: ; preds = %113, %5
%120 = phi i8* [ %8, %5 ], [ %115, %113 ]
ret i8* %120
}