#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 uint8_t;
typedef int /*<<< orphan*/ out;
typedef int /*<<< orphan*/ in;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ memset(char *, int, int);
int /*<<< orphan*/ test(char *);
int /*<<< orphan*/ websafe_base64_encode(char *, int /*<<< orphan*/, int *,
                                         int);
void test_empty_buffer_writes_nothing() {
  test("test_empty_buffer_writes_nothing");
  char out[1];
  memset(out, 0xaa, sizeof(out));
  uint8_t in[] = {0x01};
  assert(!websafe_base64_encode(out, 0, in, sizeof(in)));
  assert(out[0] == 0xaa);
}


x86 assembly (clang, -O0):
<test_empty_buffer_writes_nothing>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
call   1060 <test@plt>
lea    -0x1(%rbp),%rdi
mov    $0xaa,%esi
mov    $0x1,%edx
call   1030 <memset@plt>
mov    0xeb7(%rip),%eax
mov    %eax,-0x8(%rbp)
lea    -0x1(%rbp),%rdi
lea    -0x8(%rbp),%rdx
xor    %esi,%esi
mov    $0x4,%ecx
call   1050 <websafe_base64_encode@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movsbl -0x1(%rbp),%eax
cmp    $0xaa,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_empty_buffer_writes_nothing>:
push   %rbx
sub    $0x10,%rsp
lea    0xeb4(%rip),%rdi
call   1060 <test@plt>
lea    0xb(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xaa,%esi
mov    $0x1,%edx
call   1030 <memset@plt>
movl   $0x1,0xc(%rsp)
lea    0xc(%rsp),%rdx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x4,%ecx
call   1050 <websafe_base64_encode@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1040 <assert@plt>
xor    %edi,%edi
call   1040 <assert@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [33 x i8] c"test_empty_buffer_writes_nothing\00"
@__const.test_empty_buffer_writes_nothing.in = [1 x i32] [i32 1]
define void @test_empty_buffer_writes_nothing() {
%1 = alloca [1 x i8]
%2 = alloca [1 x i32]
%3 = call i32 @test(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds [1 x i8], [1 x i8]* %1, i64 0, i64 0
%5 = call i32 @memset(i8* %4, i32 170, i32 1)
%6 = bitcast [1 x i32]* %2 to i8*
%7 = getelementptr inbounds [1 x i8], [1 x i8]* %1, i64 0, i64 0
%8 = getelementptr inbounds [1 x i32], [1 x i32]* %2, i64 0, i64 0
%9 = call i32 @websafe_base64_encode(i8* %7, i32 0, i32* %8, i32 4)
%10 = icmp ne i32 %9, 0
%11 = xor i1 %10, true
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = getelementptr inbounds [1 x i8], [1 x i8]* %1, i64 0, i64 0
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 170
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
ret void
}

LLVM IR (-O2):
@.str = [33 x i8] c"test_empty_buffer_writes_nothing\00"
define void @test_empty_buffer_writes_nothing() {
%1 = alloca [1 x i8]
%2 = alloca [1 x i32]
%3 = tail call i32 @test(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds [1 x i8], [1 x i8]* %1, i64 0, i64 0
%5 = call i32 @memset(i8* %4, i32 170, i32 1)
%6 = bitcast [1 x i32]* %2 to i8*
%7 = getelementptr inbounds [1 x i32], [1 x i32]* %2, i64 0, i64 0
store i32 1, i32* %7
%8 = call i32 @websafe_base64_encode(i8* %4, i32 0, i32* %7, i32 4)
%9 = icmp eq i32 %8, 0
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = call i32 @assert(i32 0)
ret void
}