#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(unsigned char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
unsigned char *malloc(size_t);
int /*<<< orphan*/ memset(unsigned char *, unsigned char, long long);
int /*<<< orphan*/ printf(char *, long long);
unsigned char *create_filled_block(long long block_size, unsigned char filler) {
  unsigned char *retval;
  if (block_size > 1048576)
    exit(printf("requested block (%I64d bytes) is too large\n", block_size));
  retval = malloc((size_t)block_size);
  assert(retval);
  memset(retval, filler, block_size);
  return retval;
}


x86 assembly (clang, -O0):
<create_filled_block>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
cmpq   $0x100000,-0x8(%rbp)
jle    1187 <create_filled_block+0x37>
mov    -0x8(%rbp),%rsi
lea    0xe85(%rip),%rdi
call   1030 <printf@plt>
mov    %eax,%edi
call   1070 <exit@plt>
mov    -0x8(%rbp),%rdi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <assert@plt>
mov    -0x18(%rbp),%rdi
mov    -0x9(%rbp),%al
mov    -0x8(%rbp),%rdx
movzbl %al,%esi
call   1040 <memset@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_filled_block>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
cmp    $0x100001,%rdi
jge    118d <create_filled_block+0x3d>
mov    %esi,%r14d
mov    %rbx,%rdi
call   1060 <malloc@plt>
mov    %rax,%rbp
mov    %rax,%rdi
call   1050 <assert@plt>
movzbl %r14b,%esi
mov    %rbp,%rdi
mov    %rbx,%rdx
call   1040 <memset@plt>
mov    %rbp,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xe6c(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    %eax,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [44 x i8] c"requested block (%I64d bytes) is too large\0A\00"
define i8* @create_filled_block(i64 %0, i8 zeroext %1) {
%3 = alloca i64
%4 = alloca i8
%5 = alloca i8*
store i64 %0, i64* %3
store i8 %1, i8* %4
%6 = load i64, i64* %3
%7 = icmp sgt i64 %6, 1048576
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = load i64, i64* %3
%10 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i64 %9)
%11 = call i32 @exit(i32 %10)
unreachable
12: ; preds = %2
%13 = load i64, i64* %3
%14 = call i8* @malloc(i64 %13)
store i8* %14, i8** %5
%15 = load i8*, i8** %5
%16 = call i32 @assert(i8* %15)
%17 = load i8*, i8** %5
%18 = load i8, i8* %4
%19 = load i64, i64* %3
%20 = call i32 @memset(i8* %17, i8 zeroext %18, i64 %19)
%21 = load i8*, i8** %5
ret i8* %21
}

LLVM IR (-O2):
@.str = [44 x i8] c"requested block (%I64d bytes) is too large\0A\00"
define i8* @create_filled_block(i64 %0, i8 zeroext %1) {
%3 = icmp sgt i64 %0, 1048576
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = tail call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i64 %0)
%6 = tail call i32 @exit(i32 %5)
unreachable
7: ; preds = %2
%8 = tail call i8* @malloc(i64 %0)
%9 = tail call i32 @assert(i8* %8)
%10 = tail call i32 @memset(i8* %8, i8 zeroext %1, i64 %0)
ret i8* %8
}