#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 */
struct http_connection {
  int dummy;
};
typedef int /*<<< orphan*/ prefix;

/* Variables and functions */
char *__xmalloc(char *, int, size_t);
size_t base64_encode(char const *, char *, size_t);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ send_header(struct http_connection *, char *, char *);
int /*<<< orphan*/ strcpy(char *, char const *);
void send_auth_header(struct http_connection *conn, const char *creds) {
  const char prefix[] = "Basic ";
  size_t len, offset;
  char *buf;
  offset = sizeof(prefix) - 1;
  len = base64_encode(creds, NULL, 0);
  buf = __xmalloc(
      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
      "2022-01-22/02-19-57/repos/locker/httpget/refs/heads/master/http.c",
      421, (len + offset + 1));
  strcpy(buf, prefix);
  base64_encode(creds, buf + offset, len + 1);
  send_header(conn, "Authorization", buf);
  free(buf);
}


x86 assembly (clang, -O0):
<send_auth_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xe9a(%rip),%eax
mov    %eax,-0x17(%rbp)
mov    0xe94(%rip),%ax
mov    %ax,-0x13(%rbp)
mov    0xe8c(%rip),%al
mov    %al,-0x11(%rbp)
movq   $0x6,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%edx
mov    %rdx,%rsi
call   1070 <base64_encode@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdx
add    -0x28(%rbp),%rdx
add    $0x1,%rdx
lea    0xe5b(%rip),%rdi
mov    $0x1a5,%esi
call   1050 <__xmalloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
lea    -0x17(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%rsi
add    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rdx
add    $0x1,%rdx
call   1070 <base64_encode@plt>
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rdx
lea    0xe9a(%rip),%rsi
call   1060 <send_header@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_auth_header>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r14
movl   $0x206369,0x3(%rsp)
movl   $0x69736142,(%rsp)
mov    %rsi,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1070 <base64_encode@plt>
mov    %rax,%rbx
lea    0x7(%rax),%rdx
lea    0xe80(%rip),%rdi
mov    $0x1a5,%esi
call   1050 <__xmalloc@plt>
mov    %rax,%r12
mov    %rsp,%rsi
mov    %rax,%rdi
call   1040 <strcpy@plt>
lea    0x6(%r12),%rsi
add    $0x1,%rbx
mov    %r15,%rdi
mov    %rbx,%rdx
call   1070 <base64_encode@plt>
lea    0xecf(%rip),%rsi
mov    %r14,%rdi
mov    %r12,%rdx
call   1060 <send_header@plt>
mov    %r12,%rdi
call   1030 <free@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.http_connection = type { i32 }
@__const.send_auth_header.prefix = [7 x i8] c"Basic \00"
@.str = [130 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/locker/httpget/refs/heads/master/http.c\00"
@.str.1 = [14 x i8] c"Authorization\00"
define void @send_auth_header(%struct.http_connection* %0, i8* %1) {
%3 = alloca %struct.http_connection*
%4 = alloca i8*
%5 = alloca [7 x i8]
%6 = alloca i64
%7 = alloca i64
%8 = alloca i8*
store %struct.http_connection* %0, %struct.http_connection** %3
store i8* %1, i8** %4
%9 = bitcast [7 x i8]* %5 to i8*
store i64 6, i64* %7
%10 = load i8*, i8** %4
%11 = call i64 @base64_encode(i8* %10, i8* null, i64 0)
store i64 %11, i64* %6
%12 = load i64, i64* %6
%13 = load i64, i64* %7
%14 = add i64 %12, %13
%15 = add i64 %14, 1
%16 = call i8* @__xmalloc(i8* getelementptr inbounds ([130 x i8], [130 x i8]* @.str, i64 0, i64 0), i32 421, i64 %15)
store i8* %16, i8** %8
%17 = load i8*, i8** %8
%18 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 0
%19 = call i32 @strcpy(i8* %17, i8* %18)
%20 = load i8*, i8** %4
%21 = load i8*, i8** %8
%22 = load i64, i64* %7
%23 = getelementptr inbounds i8, i8* %21, i64 %22
%24 = load i64, i64* %6
%25 = add i64 %24, 1
%26 = call i64 @base64_encode(i8* %20, i8* %23, i64 %25)
%27 = load %struct.http_connection*, %struct.http_connection** %3
%28 = load i8*, i8** %8
%29 = call i32 @send_header(%struct.http_connection* %27, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %28)
%30 = load i8*, i8** %8
%31 = call i32 @free(i8* %30)
ret void
}

LLVM IR (-O2):
%struct.http_connection = type { i32 }
@__const.send_auth_header.prefix = [7 x i8] c"Basic \00"
@.str = [130 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/locker/httpget/refs/heads/master/http.c\00"
@.str.1 = [14 x i8] c"Authorization\00"
define void @send_auth_header(%struct.http_connection* %0, i8* %1) {
%3 = alloca [7 x i8]
%4 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 0
%5 = tail call i64 @base64_encode(i8* %1, i8* null, i64 0)
%6 = add i64 %5, 7
%7 = tail call i8* @__xmalloc(i8* getelementptr inbounds ([130 x i8], [130 x i8]* @.str, i64 0, i64 0), i32 421, i64 %6)
%8 = call i32 @strcpy(i8* %7, i8* %4)
%9 = getelementptr inbounds i8, i8* %7, i64 6
%10 = add i64 %5, 1
%11 = call i64 @base64_encode(i8* %1, i8* %9, i64 %10)
%12 = call i32 @send_header(%struct.http_connection* %0, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%13 = call i32 @free(i8* %7)
ret void
}