#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 */
scalar_t__ check_hash(char *);
int ft_strlen(char *);
scalar_t__ legal_char(char *);
scalar_t__ main_check(char *);
int check_if_valid(char *str) {
  int len;
  len = ft_strlen(str);
  if (legal_char(str))
    return (1);
  if (main_check(str))
    return (1);
  if (check_hash(str))
    return (1);
  else
    return (0);
}


x86 assembly (clang, -O0):
<check_if_valid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <ft_strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <legal_char@plt>
cmp    $0x0,%rax
je     1177 <check_if_valid+0x37>
movl   $0x1,-0x4(%rbp)
jmp    11bc <check_if_valid+0x7c>
mov    -0x10(%rbp),%rdi
call   1060 <main_check@plt>
cmp    $0x0,%rax
je     1196 <check_if_valid+0x56>
movl   $0x1,-0x4(%rbp)
jmp    11bc <check_if_valid+0x7c>
mov    -0x10(%rbp),%rdi
call   1050 <check_hash@plt>
cmp    $0x0,%rax
je     11b5 <check_if_valid+0x75>
movl   $0x1,-0x4(%rbp)
jmp    11bc <check_if_valid+0x7c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_if_valid>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <ft_strlen@plt>
mov    %rbx,%rdi
call   1040 <legal_char@plt>
mov    $0x1,%ebp
test   %rax,%rax
jne    117b <check_if_valid+0x3b>
mov    %rbx,%rdi
call   1060 <main_check@plt>
test   %rax,%rax
jne    117b <check_if_valid+0x3b>
mov    %rbx,%rdi
call   1050 <check_hash@plt>
xor    %ebp,%ebp
test   %rax,%rax
setne  %bpl
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @check_if_valid(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i32 @ft_strlen(i8* %5)
store i32 %6, i32* %4
%7 = load i8*, i8** %3
%8 = call i64 @legal_char(i8* %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %1
store i32 1, i32* %2
br label %22
11: ; preds = %1
%12 = load i8*, i8** %3
%13 = call i64 @main_check(i8* %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %11
store i32 1, i32* %2
br label %22
16: ; preds = %11
%17 = load i8*, i8** %3
%18 = call i64 @check_hash(i8* %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %16
store i32 1, i32* %2
br label %22
21: ; preds = %16
store i32 0, i32* %2
br label %22
22: ; preds = %21, %20, %15, %10
%23 = load i32, i32* %2
ret i32 %23
}

LLVM IR (-O2):
define i32 @check_if_valid(i8* %0) {
%2 = tail call i32 @ft_strlen(i8* %0)
%3 = tail call i64 @legal_char(i8* %0)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %12
5: ; preds = %1
%6 = tail call i64 @main_check(i8* %0)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %5
%9 = tail call i64 @check_hash(i8* %0)
%10 = icmp ne i64 %9, 0
%11 = zext i1 %10 to i32
br label %12
12: ; preds = %8, %5, %1
%13 = phi i32 [ 1, %1 ], [ 1, %5 ], [ %11, %8 ]
ret i32 %13
}