#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*/ __ESBMC_assert(int, char *);
size_t __ESBMC_buffer_size(void const *);
int memcmp_strabs(const void *s1, const void *s2, size_t n) {
__ESBMC_HIDE:;
  int res;
  __ESBMC_assert(__ESBMC_buffer_size(s1) >= n,
                 "memcmp buffer overflow of 1st argument");
  __ESBMC_assert(__ESBMC_buffer_size(s2) >= n,
                 "memcmp buffer overflow of 2nd argument");
  return res;
}


x86 assembly (clang, -O0):
<memcmp_strabs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <__ESBMC_buffer_size@plt>
cmp    -0x18(%rbp),%rax
setae  %al
and    $0x1,%al
movzbl %al,%edi
lea    0xeb0(%rip),%rsi
call   1030 <__ESBMC_assert@plt>
mov    -0x10(%rbp),%rdi
call   1040 <__ESBMC_buffer_size@plt>
cmp    -0x18(%rbp),%rax
setae  %al
and    $0x1,%al
movzbl %al,%edi
lea    0xeb6(%rip),%rsi
call   1030 <__ESBMC_assert@plt>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<memcmp_strabs>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rsi,%r14
call   1040 <__ESBMC_buffer_size@plt>
xor    %edi,%edi
cmp    %rbx,%rax
setae  %dil
lea    0xec1(%rip),%rsi
call   1030 <__ESBMC_assert@plt>
mov    %r14,%rdi
call   1040 <__ESBMC_buffer_size@plt>
xor    %edi,%edi
cmp    %rbx,%rax
setae  %dil
lea    0xecb(%rip),%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <__ESBMC_assert@plt>

LLVM IR (-O0):
@.str = [39 x i8] c"memcmp buffer overflow of 1st argument\00"
@.str.1 = [39 x i8] c"memcmp buffer overflow of 2nd argument\00"
define i32 @memcmp_strabs(i8* %0, i8* %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
br label %8
8: ; preds = %3
%9 = load i8*, i8** %4
%10 = call i64 @__ESBMC_buffer_size(i8* %9)
%11 = load i64, i64* %6
%12 = icmp uge i64 %10, %11
%13 = zext i1 %12 to i32
%14 = call i32 @__ESBMC_assert(i32 %13, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%15 = load i8*, i8** %5
%16 = call i64 @__ESBMC_buffer_size(i8* %15)
%17 = load i64, i64* %6
%18 = icmp uge i64 %16, %17
%19 = zext i1 %18 to i32
%20 = call i32 @__ESBMC_assert(i32 %19, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
%21 = load i32, i32* %7
ret i32 %21
}

LLVM IR (-O2):
@.str = [39 x i8] c"memcmp buffer overflow of 1st argument\00"
@.str.1 = [39 x i8] c"memcmp buffer overflow of 2nd argument\00"
define i32 @memcmp_strabs(i8* %0, i8* %1, i64 %2) {
%4 = tail call i64 @__ESBMC_buffer_size(i8* %0)
%5 = icmp uge i64 %4, %2
%6 = zext i1 %5 to i32
%7 = tail call i32 @__ESBMC_assert(i32 %6, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%8 = tail call i64 @__ESBMC_buffer_size(i8* %1)
%9 = icmp uge i64 %8, %2
%10 = zext i1 %9 to i32
%11 = tail call i32 @__ESBMC_assert(i32 %10, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
ret i32 undef
}