#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*/ check_nl_ct(char *);
int /*<<< orphan*/ ft_strchrrplc(char *, char, char);
char *ft_strctrim(char *, char);
int is_piece(char *);
int is_valid_block(char *input) {
  int result;
  result = -1;
  if (input) {
    if (!check_nl_ct(input))
      return (result);
    ft_strchrrplc(input, '\n', '.');
    input = ft_strctrim(input, '.');
    result = is_piece(input);
  }
  return (result);
}


x86 assembly (clang, -O0):
<is_valid_block>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0xffffffff,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11ac <is_valid_block+0x6c>
mov    -0x10(%rbp),%rdi
call   1050 <check_nl_ct@plt>
cmp    $0x0,%eax
jne    117b <is_valid_block+0x3b>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11b2 <is_valid_block+0x72>
mov    -0x10(%rbp),%rdi
mov    $0xa,%esi
mov    $0x2e,%edx
call   1030 <ft_strchrrplc@plt>
mov    -0x10(%rbp),%rdi
mov    $0x2e,%esi
call   1040 <ft_strctrim@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <is_piece@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_valid_block>:
push   %rbx
test   %rdi,%rdi
je     117a <is_valid_block+0x3a>
mov    %rdi,%rbx
call   1050 <check_nl_ct@plt>
test   %eax,%eax
je     117a <is_valid_block+0x3a>
mov    %rbx,%rdi
mov    $0xa,%esi
mov    $0x2e,%edx
call   1030 <ft_strchrrplc@plt>
mov    %rbx,%rdi
mov    $0x2e,%esi
call   1040 <ft_strctrim@plt>
mov    %rax,%rdi
pop    %rbx
jmp    1060 <is_piece@plt>
mov    $0xffffffff,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @is_valid_block(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 -1, i32* %4
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %20
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = call i32 @check_nl_ct(i8* %8)
%10 = icmp ne i32 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %7
%12 = load i32, i32* %4
store i32 %12, i32* %2
br label %22
13: ; preds = %7
%14 = load i8*, i8** %3
%15 = call i32 @ft_strchrrplc(i8* %14, i8 signext 10, i8 signext 46)
%16 = load i8*, i8** %3
%17 = call i8* @ft_strctrim(i8* %16, i8 signext 46)
store i8* %17, i8** %3
%18 = load i8*, i8** %3
%19 = call i32 @is_piece(i8* %18)
store i32 %19, i32* %4
br label %20
20: ; preds = %13, %1
%21 = load i32, i32* %4
store i32 %21, i32* %2
br label %22
22: ; preds = %20, %11
%23 = load i32, i32* %2
ret i32 %23
}

LLVM IR (-O2):
define i32 @is_valid_block(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %10, label %3
3: ; preds = %1
%4 = tail call i32 @check_nl_ct(i8* %0)
%5 = icmp eq i32 %4, 0
br i1 %5, label %10, label %6
6: ; preds = %3
%7 = tail call i32 @ft_strchrrplc(i8* %0, i8 signext 10, i8 signext 46)
%8 = tail call i8* @ft_strctrim(i8* %0, i8 signext 46)
%9 = tail call i32 @is_piece(i8* %8)
br label %10
10: ; preds = %1, %6, %3
%11 = phi i32 [ -1, %3 ], [ %9, %6 ], [ -1, %1 ]
ret i32 %11
}