#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*/ strcat(char *, char *);
scalar_t__ strlen(char *);
void ocappendparams(char *newuri, char **p) {
  while (*p) {
    strcat(newuri, "[");
    strcat(newuri, *p++);
    if (strlen(*p) > 0) {
      strcat(newuri, "=");
      strcat(newuri, *p);
    }
    p++;
    strcat(newuri, "]");
  }
}


x86 assembly (clang, -O0):
<ocappendparams>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     11c0 <ocappendparams+0xa0>
mov    -0x8(%rbp),%rdi
lea    0xeb7(%rip),%rsi
call   1040 <strcat@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%rsi
call   1040 <strcat@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%rax
jle    119f <ocappendparams+0x7f>
mov    -0x8(%rbp),%rdi
lea    0xe78(%rip),%rsi
call   1040 <strcat@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
call   1040 <strcat@plt>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe4e(%rip),%rsi
call   1040 <strcat@plt>
jmp    1130 <ocappendparams+0x10>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ocappendparams>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
cmpq   $0x0,(%rsi)
je     11a3 <ocappendparams+0x83>
mov    %rsi,%rbx
mov    %rdi,%r14
add    $0x10,%rbx
lea    0xec0(%rip),%r15
lea    0xebb(%rip),%r12
lea    0xeb6(%rip),%r13
jmp    1165 <ocappendparams+0x45>
mov    %r14,%rdi
mov    %r13,%rsi
call   1040 <strcat@plt>
cmpq   $0x0,(%rbx)
lea    0x10(%rbx),%rbx
je     11a3 <ocappendparams+0x83>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <strcat@plt>
mov    -0x10(%rbx),%rsi
mov    %r14,%rdi
call   1040 <strcat@plt>
mov    -0x8(%rbx),%rdi
call   1030 <strlen@plt>
test   %rax,%rax
jle    1150 <ocappendparams+0x30>
mov    %r14,%rdi
mov    %r12,%rsi
call   1040 <strcat@plt>
mov    -0x8(%rbx),%rsi
mov    %r14,%rdi
call   1040 <strcat@plt>
jmp    1150 <ocappendparams+0x30>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"[\00"
@.str.1 = [2 x i8] c"=\00"
@.str.2 = [2 x i8] c"]\00"
define void @ocappendparams(i8* %0, i8** %1) {
%3 = alloca i8*
%4 = alloca i8**
store i8* %0, i8** %3
store i8** %1, i8*** %4
br label %5
5: ; preds = %28, %2
%6 = load i8**, i8*** %4
%7 = load i8*, i8** %6
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %33
9: ; preds = %5
%10 = load i8*, i8** %3
%11 = call i32 @strcat(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = load i8*, i8** %3
%13 = load i8**, i8*** %4
%14 = getelementptr inbounds i8*, i8** %13, i32 1
store i8** %14, i8*** %4
%15 = load i8*, i8** %13
%16 = call i32 @strcat(i8* %12, i8* %15)
%17 = load i8**, i8*** %4
%18 = load i8*, i8** %17
%19 = call i64 @strlen(i8* %18)
%20 = icmp sgt i64 %19, 0
br i1 %20, label %21, label %28
21: ; preds = %9
%22 = load i8*, i8** %3
%23 = call i32 @strcat(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%24 = load i8*, i8** %3
%25 = load i8**, i8*** %4
%26 = load i8*, i8** %25
%27 = call i32 @strcat(i8* %24, i8* %26)
br label %28
28: ; preds = %21, %9
%29 = load i8**, i8*** %4
%30 = getelementptr inbounds i8*, i8** %29, i32 1
store i8** %30, i8*** %4
%31 = load i8*, i8** %3
%32 = call i32 @strcat(i8* %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %5
33: ; preds = %5
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"[\00"
@.str.1 = [2 x i8] c"=\00"
@.str.2 = [2 x i8] c"]\00"
define void @ocappendparams(i8* %0, i8** nocapture %1) {
%3 = load i8*, i8** %1
%4 = icmp eq i8* %3, null
br i1 %4, label %23, label %5
5: ; preds = %2, %18
%6 = phi i8** [ %19, %18 ], [ %1, %2 ]
%7 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds i8*, i8** %6, i64 1
%9 = load i8*, i8** %6
%10 = tail call i32 @strcat(i8* %0, i8* %9)
%11 = load i8*, i8** %8
%12 = tail call i64 @strlen(i8* dereferenceable(1) %11)
%13 = icmp sgt i64 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %5
%15 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%16 = load i8*, i8** %8
%17 = tail call i32 @strcat(i8* %0, i8* %16)
br label %18
18: ; preds = %14, %5
%19 = getelementptr inbounds i8*, i8** %6, i64 2
%20 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%21 = load i8*, i8** %19
%22 = icmp eq i8* %21, null
br i1 %22, label %23, label %5
23: ; preds = %18, %2
ret void
}