#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*/ assert(int);
int /*<<< orphan*/ basic_memset(void *, int, size_t);
int /*<<< orphan*/ effective_memset(void *, unsigned long, size_t);
int /*<<< orphan*/ free(void *);
void *malloc(size_t);
scalar_t__ memcmp(void *, void *, size_t);
int main(int argc, char *argv[]) {
  size_t space = sizeof(char) * 65537;
  void *basic_space = malloc(space);
  void *effective_space = malloc(space);
  int basic_fill = 0xFF;
  unsigned long effective_fill = ~0;
  basic_memset(basic_space, basic_fill, space);
  effective_memset(effective_space, effective_fill, space);
  assert(memcmp(basic_space, effective_space, space) == 0);
  free(basic_space);
  free(effective_space);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x10001,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <malloc@plt>
mov    %rax,-0x28(%rbp)
movl   $0xff,-0x2c(%rbp)
movq   $0xffffffffffffffff,-0x38(%rbp)
ff
mov    -0x20(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0x18(%rbp),%rdx
call   1040 <basic_memset@plt>
mov    -0x28(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1080 <effective_memset@plt>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x10001,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
mov    $0x10001,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    $0x10001,%edx
mov    %r14,%rdi
mov    $0xff,%esi
call   1040 <basic_memset@plt>
mov    $0x10001,%edx
mov    %rbx,%rdi
mov    $0xffffffffffffffff,%rsi
call   1080 <effective_memset@plt>
mov    $0x10001,%edx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <memcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1060 <assert@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 65537, i64* %6
%11 = load i64, i64* %6
%12 = call i8* @malloc(i64 %11)
store i8* %12, i8** %7
%13 = load i64, i64* %6
%14 = call i8* @malloc(i64 %13)
store i8* %14, i8** %8
store i32 255, i32* %9
store i64 -1, i64* %10
%15 = load i8*, i8** %7
%16 = load i32, i32* %9
%17 = load i64, i64* %6
%18 = call i32 @basic_memset(i8* %15, i32 %16, i64 %17)
%19 = load i8*, i8** %8
%20 = load i64, i64* %10
%21 = load i64, i64* %6
%22 = call i32 @effective_memset(i8* %19, i64 %20, i64 %21)
%23 = load i8*, i8** %7
%24 = load i8*, i8** %8
%25 = load i64, i64* %6
%26 = call i64 @memcmp(i8* %23, i8* %24, i64 %25)
%27 = icmp eq i64 %26, 0
%28 = zext i1 %27 to i32
%29 = call i32 @assert(i32 %28)
%30 = load i8*, i8** %7
%31 = call i32 @free(i8* %30)
%32 = load i8*, i8** %8
%33 = call i32 @free(i8* %32)
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call dereferenceable_or_null(65537) i8* @malloc(i64 65537)
%4 = tail call dereferenceable_or_null(65537) i8* @malloc(i64 65537)
%5 = tail call i32 @basic_memset(i8* %3, i32 255, i64 65537)
%6 = tail call i32 @effective_memset(i8* %4, i64 -1, i64 65537)
%7 = tail call i64 @memcmp(i8* %3, i8* %4, i64 65537)
%8 = icmp eq i64 %7, 0
%9 = zext i1 %8 to i32
%10 = tail call i32 @assert(i32 %9)
%11 = tail call i32 @free(i8* %3)
%12 = tail call i32 @free(i8* %4)
ret i32 0
}