#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*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int strlen(char const *);
bool __attribute__((nonnull, warn_unused_result))
validate_block_name(const char *name) {
  if (!name) {
    fputs("Block name cannot be NULL\n", stderr);
    return false;
  }
  if (!name[0]) {
    fputs("Empty name is not allowed\n", stderr);
    return false;
  }
  if (strlen(name) > 16) {
    fputs("Too long block name\n", stderr);
    return false;
  }
  return true;
}


x86 assembly (clang, -O0):
<validate_block_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1158 <validate_block_name+0x38>
mov    0x2ea2(%rip),%rax
mov    (%rax),%esi
lea    0xeb9(%rip),%rdi
call   1040 <fputs@plt>
movl   $0x0,-0x4(%rbp)
jmp    11c0 <validate_block_name+0xa0>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1186 <validate_block_name+0x66>
mov    0x2e74(%rip),%rax
mov    (%rax),%esi
lea    0xea6(%rip),%rdi
call   1040 <fputs@plt>
movl   $0x0,-0x4(%rbp)
jmp    11c0 <validate_block_name+0xa0>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x10,%eax
jle    11b9 <validate_block_name+0x99>
mov    0x2e41(%rip),%rax
mov    (%rax),%esi
lea    0xe8e(%rip),%rdi
call   1040 <fputs@plt>
movl   $0x0,-0x4(%rbp)
jmp    11c0 <validate_block_name+0xa0>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<validate_block_name>:
push   %rax
cmpb   $0x0,(%rdi)
je     1140 <validate_block_name+0x20>
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    $0x11,%ecx
jl     1157 <validate_block_name+0x37>
lea    0xedd(%rip),%rdi
jmp    1147 <validate_block_name+0x27>
lea    0xeb9(%rip),%rdi
mov    0x2e92(%rip),%rax
mov    (%rax),%esi
call   1040 <fputs@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Block name cannot be NULL\0A\00"
@stderr = global i32 0
@.str.1 = [27 x i8] c"Empty name is not allowed\0A\00"
@.str.2 = [21 x i8] c"Too long block name\0A\00"
define i32 @validate_block_name(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = icmp ne i8* %4, null
br i1 %5, label %9, label %6
6: ; preds = %1
%7 = load i32, i32* @stderr
%8 = call i32 @fputs(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %7)
store i32 0, i32* %2
br label %25
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = getelementptr inbounds i8, i8* %10, i64 0
%12 = load i8, i8* %11
%13 = icmp ne i8 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %9
%15 = load i32, i32* @stderr
%16 = call i32 @fputs(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %15)
store i32 0, i32* %2
br label %25
17: ; preds = %9
%18 = load i8*, i8** %3
%19 = call i32 @strlen(i8* %18)
%20 = icmp sgt i32 %19, 16
br i1 %20, label %21, label %24
21: ; preds = %17
%22 = load i32, i32* @stderr
%23 = call i32 @fputs(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %22)
store i32 0, i32* %2
br label %25
24: ; preds = %17
store i32 1, i32* %2
br label %25
25: ; preds = %24, %21, %14, %6
%26 = load i32, i32* %2
ret i32 %26
}

LLVM IR (-O2):
@stderr = global i32 0
@.str.1 = [27 x i8] c"Empty name is not allowed\0A\00"
@.str.2 = [21 x i8] c"Too long block name\0A\00"
define i32 @validate_block_name(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %7, label %4
4: ; preds = %1
%5 = tail call i32 @strlen(i8* %0)
%6 = icmp sgt i32 %5, 16
br i1 %6, label %7, label %11
7: ; preds = %4, %1
%8 = phi i8* [ getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), %1 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), %4 ]
%9 = load i32, i32* @stderr
%10 = tail call i32 @fputs(i8* %8, i32 %9)
br label %11
11: ; preds = %7, %4
%12 = phi i32 [ 1, %4 ], [ 0, %7 ]
ret i32 %12
}