#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 */
typedef int /*<<< orphan*/ tmp;

/* Variables and functions */
int /*<<< orphan*/ http_base64enc(char *, size_t, char *, int /*<<< orphan*/);
int /*<<< orphan*/ snprintf(char *, int, char *, char const *, char const *);
size_t strlen(char *);
void http_createauth(const char *user, const char *pwd, char *buf, int len) {
  char tmp[80];
  snprintf(tmp, sizeof(tmp), "%s:%s", user, pwd);
  http_base64enc(tmp, strlen(tmp), &buf[strlen(buf)], len - strlen(buf));
}


x86 assembly (clang, -O0):
<http_createauth>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%r8
mov    $0x50,%esi
lea    0xe9e(%rip),%rdx
call   1040 <snprintf@plt>
lea    -0x70(%rbp),%rax
mov    %rax,-0x90(%rbp)
lea    -0x70(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x88(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x98(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x80(%rbp)
movslq -0x1c(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x90(%rbp),%rdi
mov    -0x88(%rbp),%rsi
mov    -0x80(%rbp),%rdx
mov    %rax,%rcx
mov    -0x78(%rbp),%rax
sub    %rcx,%rax
mov    %eax,%ecx
call   1050 <http_base64enc@plt>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<http_createauth>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x58,%rsp
mov    %ecx,%ebp
mov    %rdx,%rbx
mov    %rsi,%r8
mov    %rdi,%rcx
lea    0xeb4(%rip),%rdx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x50,%esi
call   1040 <snprintf@plt>
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %rax,%r15
mov    %rbx,%rdi
call   1030 <strlen@plt>
add    %rax,%rbx
sub    %eax,%ebp
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
mov    %ebp,%ecx
call   1050 <http_base64enc@plt>
add    $0x58,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%s:%s\00"
define void @http_createauth(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca [80 x i8]
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%10 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%11 = load i8*, i8** %5
%12 = load i8*, i8** %6
%13 = call i32 @snprintf(i8* %10, i32 80, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %11, i8* %12)
%14 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%15 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%16 = call i64 @strlen(i8* %15)
%17 = load i8*, i8** %7
%18 = load i8*, i8** %7
%19 = call i64 @strlen(i8* %18)
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = load i32, i32* %8
%22 = sext i32 %21 to i64
%23 = load i8*, i8** %7
%24 = call i64 @strlen(i8* %23)
%25 = sub i64 %22, %24
%26 = trunc i64 %25 to i32
%27 = call i32 @http_base64enc(i8* %14, i64 %16, i8* %20, i32 %26)
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%s:%s\00"
define void @http_createauth(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca [80 x i8]
%6 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%7 = call i32 @snprintf(i8* %6, i32 80, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
%8 = call i64 @strlen(i8* %6)
%9 = call i64 @strlen(i8* dereferenceable(1) %2)
%10 = getelementptr inbounds i8, i8* %2, i64 %9
%11 = trunc i64 %9 to i32
%12 = sub i32 %3, %11
%13 = call i32 @http_base64enc(i8* %6, i64 %8, i8* %10, i32 %12)
ret void
}