#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, int *, int);
void test_buffer_overflow_returns_false() {
  test("test_buffer_overflow_returns_false");
  char out[4];
  memset(out, 0xaa, sizeof(out));
  uint8_t in[] = {0x12, 0x34, 0x56};
  assert(!websafe_base64_encode(out, 3, in, sizeof(in)));
  assert(out[3] == 0xaa);
}


x86 assembly (clang, -O0):
<test_buffer_overflow_returns_false>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
call   1060 <test@plt>
lea    -0x4(%rbp),%rdi
mov    $0xaa,%esi
mov    $0x4,%edx
call   1030 <memset@plt>
mov    0xeb6(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xeb4(%rip),%eax
mov    %eax,-0x8(%rbp)
lea    -0x4(%rbp),%rdi
lea    -0x10(%rbp),%rdx
mov    $0x3,%esi
mov    $0xc,%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_buffer_overflow_returns_false>:
push   %rbx
sub    $0x10,%rsp
lea    0xeb4(%rip),%rdi
call   1060 <test@plt>
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xaa,%esi
mov    $0x4,%edx
call   1030 <memset@plt>
mov    0xebe(%rip),%eax
mov    %eax,0x8(%rsp)
mov    0xeab(%rip),%rax
mov    %rax,(%rsp)
mov    %rsp,%rdx
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0xc,%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 = [35 x i8] c"test_buffer_overflow_returns_false\00"
@__const.test_buffer_overflow_returns_false.in = [3 x i32] [i32 18, i32 52, i32 86]
define void @test_buffer_overflow_returns_false() {
%1 = alloca [4 x i8]
%2 = alloca [3 x i32]
%3 = call i32 @test(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 0
%5 = call i32 @memset(i8* %4, i32 170, i32 4)
%6 = bitcast [3 x i32]* %2 to i8*
%7 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 0
%8 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%9 = call i32 @websafe_base64_encode(i8* %7, i32 3, i32* %8, i32 12)
%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 [4 x i8], [4 x i8]* %1, i64 0, i64 3
%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 = [35 x i8] c"test_buffer_overflow_returns_false\00"
@__const.test_buffer_overflow_returns_false.in = [3 x i32] [i32 18, i32 52, i32 86]
define void @test_buffer_overflow_returns_false() {
%1 = alloca [4 x i8]
%2 = alloca [3 x i32]
%3 = tail call i32 @test(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 0
%5 = call i32 @memset(i8* %4, i32 170, i32 4)
%6 = bitcast [3 x i32]* %2 to i8*
%7 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%8 = call i32 @websafe_base64_encode(i8* %4, i32 3, i32* %7, i32 12)
%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
}