#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 *base64Dup(char *);
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *authString(char *header, char *user, char *password) {
  char *ret = NULL;
  int templen;
  char *temp;
  char *temp64;
  if (!user || !password)
    return NULL;
  templen = strlen(user) + strlen(password) + 2;
  temp = malloc(templen);
  strcpy(temp, user);
  strcat(temp, ":");
  strcat(temp, password);
  temp64 = base64Dup(temp);
  free(temp);
  ret = malloc(strlen(temp64) + strlen(header) + 3);
  strcpy(ret, header);
  strcat(ret, temp64);
  strcat(ret, "\r\n");
  free(temp64);
  return ret;
}


x86 assembly (clang, -O0):
<authString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1192 <authString+0x32>
cmpq   $0x0,-0x20(%rbp)
jne    119f <authString+0x3f>
movq   $0x0,-0x8(%rbp)
jmp    126e <authString+0x10e>
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x48(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x48(%rbp),%eax
add    %ecx,%eax
add    $0x2,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%edi
call   1070 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x38(%rbp),%rdi
lea    0xe1b(%rip),%rsi
call   1080 <strcat@plt>
mov    -0x38(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1080 <strcat@plt>
mov    -0x38(%rbp),%rdi
call   1060 <base64Dup@plt>
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x44(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x44(%rbp),%edi
add    %eax,%edi
add    $0x3,%edi
call   1070 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x28(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   1080 <strcat@plt>
mov    -0x28(%rbp),%rdi
lea    0xdaa(%rip),%rsi
call   1080 <strcat@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<authString>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
xor    %ebx,%ebx
test   %rsi,%rsi
je     122a <authString+0xca>
mov    %rdx,%r15
test   %rdx,%rdx
je     122a <authString+0xca>
mov    %rsi,%r12
mov    %rdi,%r14
mov    %rsi,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebx
mov    %r15,%rdi
call   1050 <strlen@plt>
lea    (%rbx,%rax,1),%edi
add    $0x2,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r12,%rsi
call   1040 <strcpy@plt>
lea    0xe49(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcat@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <strcat@plt>
mov    %rbx,%rdi
call   1060 <base64Dup@plt>
mov    %rax,%r15
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1050 <strlen@plt>
lea    (%rbx,%rax,1),%edi
add    $0x3,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <strcat@plt>
lea    0xde8(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcat@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c":\00"
@.str.1 = [3 x i8] c"\0D\0A\00"
define i8* @authString(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* null, i8** %8
%12 = load i8*, i8** %6
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %17
14: ; preds = %3
%15 = load i8*, i8** %7
%16 = icmp ne i8* %15, null
br i1 %16, label %18, label %17
17: ; preds = %14, %3
store i8* null, i8** %4
br label %57
18: ; preds = %14
%19 = load i8*, i8** %6
%20 = call i32 @strlen(i8* %19)
%21 = load i8*, i8** %7
%22 = call i32 @strlen(i8* %21)
%23 = add nsw i32 %20, %22
%24 = add nsw i32 %23, 2
store i32 %24, i32* %9
%25 = load i32, i32* %9
%26 = call i8* @malloc(i32 %25)
store i8* %26, i8** %10
%27 = load i8*, i8** %10
%28 = load i8*, i8** %6
%29 = call i32 @strcpy(i8* %27, i8* %28)
%30 = load i8*, i8** %10
%31 = call i32 @strcat(i8* %30, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%32 = load i8*, i8** %10
%33 = load i8*, i8** %7
%34 = call i32 @strcat(i8* %32, i8* %33)
%35 = load i8*, i8** %10
%36 = call i8* @base64Dup(i8* %35)
store i8* %36, i8** %11
%37 = load i8*, i8** %10
%38 = call i32 @free(i8* %37)
%39 = load i8*, i8** %11
%40 = call i32 @strlen(i8* %39)
%41 = load i8*, i8** %5
%42 = call i32 @strlen(i8* %41)
%43 = add nsw i32 %40, %42
%44 = add nsw i32 %43, 3
%45 = call i8* @malloc(i32 %44)
store i8* %45, i8** %8
%46 = load i8*, i8** %8
%47 = load i8*, i8** %5
%48 = call i32 @strcpy(i8* %46, i8* %47)
%49 = load i8*, i8** %8
%50 = load i8*, i8** %11
%51 = call i32 @strcat(i8* %49, i8* %50)
%52 = load i8*, i8** %8
%53 = call i32 @strcat(i8* %52, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%54 = load i8*, i8** %11
%55 = call i32 @free(i8* %54)
%56 = load i8*, i8** %8
store i8* %56, i8** %4
br label %57
57: ; preds = %18, %17
%58 = load i8*, i8** %4
ret i8* %58
}

LLVM IR (-O2):
@.str = [2 x i8] c":\00"
@.str.1 = [3 x i8] c"\0D\0A\00"
define i8* @authString(i8* %0, i8* %1, i8* %2) {
%4 = icmp ne i8* %1, null
%5 = icmp ne i8* %2, null
%6 = and i1 %4, %5
br i1 %6, label %7, label %27
7: ; preds = %3
%8 = tail call i32 @strlen(i8* %1)
%9 = tail call i32 @strlen(i8* %2)
%10 = add i32 %8, 2
%11 = add i32 %10, %9
%12 = tail call i8* @malloc(i32 %11)
%13 = tail call i32 @strcpy(i8* %12, i8* %1)
%14 = tail call i32 @strcat(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%15 = tail call i32 @strcat(i8* %12, i8* %2)
%16 = tail call i8* @base64Dup(i8* %12)
%17 = tail call i32 @free(i8* %12)
%18 = tail call i32 @strlen(i8* %16)
%19 = tail call i32 @strlen(i8* %0)
%20 = add i32 %18, 3
%21 = add i32 %20, %19
%22 = tail call i8* @malloc(i32 %21)
%23 = tail call i32 @strcpy(i8* %22, i8* %0)
%24 = tail call i32 @strcat(i8* %22, i8* %16)
%25 = tail call i32 @strcat(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%26 = tail call i32 @free(i8* %16)
br label %27
27: ; preds = %3, %7
%28 = phi i8* [ %22, %7 ], [ null, %3 ]
ret i8* %28
}