#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*/ sprintf(char *, char *, char *, char *);
char *strdup(char *);
char *document_set_onload_control_string(char *document_onload_control_string,
                                         char *s) {
  if (!s)
    return document_onload_control_string;
  if (document_onload_control_string) {
    char buffer[4096];
    sprintf(buffer, "%s;%s", document_onload_control_string, s);
    document_onload_control_string = strdup(buffer);
  } else {
    document_onload_control_string = strdup(s);
  }
  return document_onload_control_string;
}


x86 assembly (clang, -O0):
<document_set_onload_control_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1020,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    114b <document_set_onload_control_string+0x2b>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    119b <document_set_onload_control_string+0x7b>
cmpq   $0x0,-0x10(%rbp)
je     1186 <document_set_onload_control_string+0x66>
lea    -0x1020(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xe94(%rip),%rsi
call   1030 <sprintf@plt>
lea    -0x1020(%rbp),%rdi
call   1040 <strdup@plt>
mov    %rax,-0x10(%rbp)
jmp    1193 <document_set_onload_control_string+0x73>
mov    -0x18(%rbp),%rdi
call   1040 <strdup@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<document_set_onload_control_string>:
mov    %rdi,%rax
test   %rsi,%rsi
je     115d <document_set_onload_control_string+0x3d>
mov    %rsi,%rcx
test   %rax,%rax
je     115e <document_set_onload_control_string+0x3e>
push   %rbx
sub    $0x1000,%rsp
lea    0xec1(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %rax,%rdx
call   1030 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <strdup@plt>
add    $0x1000,%rsp
pop    %rbx
ret
mov    %rcx,%rdi
jmp    1040 <strdup@plt>

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

LLVM IR (-O2):
@.str = [6 x i8] c"%s;%s\00"
define i8* @document_set_onload_control_string(i8* %0, i8* %1) {
%3 = alloca [4096 x i8]
%4 = icmp eq i8* %1, null
br i1 %4, label %13, label %5
5: ; preds = %2
%6 = icmp eq i8* %0, null
br i1 %6, label %11, label %7
7: ; preds = %5
%8 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%9 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
%10 = call i8* @strdup(i8* %8)
br label %13
11: ; preds = %5
%12 = tail call i8* @strdup(i8* %1)
br label %13
13: ; preds = %7, %11, %2
%14 = phi i8* [ %0, %2 ], [ %10, %7 ], [ %12, %11 ]
ret i8* %14
}