#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*/ base64(unsigned char *, unsigned char *, int);
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
int strlen(char *);
char *basicauth(char *user, char *pass) {
  char *b64str = malloc(80);
  int len = strlen(user) + strlen(pass) + 2;
  char *p = (char *)malloc(len);
  sprintf(p, "%s:%s", user, pass);
  base64((unsigned char *)b64str, (unsigned char *)p, strlen(p));
  free(p);
  return b64str;
}


x86 assembly (clang, -O0):
<basicauth>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x50,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x3c(%rbp),%eax
add    %ecx,%eax
add    $0x2,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xe51(%rip),%rsi
call   1070 <sprintf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    %eax,%edx
call   1050 <base64@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<basicauth>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r12
mov    $0x50,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
mov    %r12,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebx
mov    %r15,%rdi
call   1040 <strlen@plt>
lea    (%rbx,%rax,1),%edi
add    $0x2,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0xe6e(%rip),%rsi
mov    %rax,%rdi
mov    %r12,%rdx
mov    %r15,%rcx
call   1070 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1050 <base64@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%s:%s\00"
define i8* @basicauth(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = call i8* @malloc(i32 80)
store i8* %8, i8** %5
%9 = load i8*, i8** %3
%10 = call i32 @strlen(i8* %9)
%11 = load i8*, i8** %4
%12 = call i32 @strlen(i8* %11)
%13 = add nsw i32 %10, %12
%14 = add nsw i32 %13, 2
store i32 %14, i32* %6
%15 = load i32, i32* %6
%16 = call i8* @malloc(i32 %15)
store i8* %16, i8** %7
%17 = load i8*, i8** %7
%18 = load i8*, i8** %3
%19 = load i8*, i8** %4
%20 = call i32 @sprintf(i8* %17, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %18, i8* %19)
%21 = load i8*, i8** %5
%22 = load i8*, i8** %7
%23 = load i8*, i8** %7
%24 = call i32 @strlen(i8* %23)
%25 = call i32 @base64(i8* %21, i8* %22, i32 %24)
%26 = load i8*, i8** %7
%27 = call i32 @free(i8* %26)
%28 = load i8*, i8** %5
ret i8* %28
}

LLVM IR (-O2):
@.str = [6 x i8] c"%s:%s\00"
define i8* @basicauth(i8* %0, i8* %1) {
%3 = tail call dereferenceable_or_null(80) i8* @malloc(i32 80)
%4 = tail call i32 @strlen(i8* %0)
%5 = tail call i32 @strlen(i8* %1)
%6 = add i32 %4, 2
%7 = add i32 %6, %5
%8 = tail call i8* @malloc(i32 %7)
%9 = tail call i32 @sprintf(i8* dereferenceable(1) %8, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
%10 = tail call i32 @strlen(i8* %8)
%11 = tail call i32 @base64(i8* %3, i8* %8, i32 %10)
%12 = tail call i32 @free(i8* %8)
ret i8* %3
}