#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 */
size_t env_get_size(char const **);
int ft_print(char *, int, int /*<<< orphan*/);
int valid_input_or_die(const char **args) {
  size_t args_size;
  args_size = env_get_size(args);
  if (!args)
    return (ft_print("ft_minishell2 :\t"
                     "An error occured.\n",
                     2, 0));
  if (args_size > 2)
    return (ft_print("exit :\t"
                     "E_TOO_MANY_ARGS",
                     2, 0));
  return (1);
}


x86 assembly (clang, -O0):
<valid_input_or_die>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <env_get_size@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    115f <valid_input_or_die+0x3f>
lea    0xeb5(%rip),%rdi
mov    $0x2,%esi
xor    %edx,%edx
call   1040 <ft_print@plt>
mov    %eax,-0x4(%rbp)
jmp    118c <valid_input_or_die+0x6c>
cmpq   $0x2,-0x18(%rbp)
jbe    1185 <valid_input_or_die+0x65>
lea    0xeb2(%rip),%rdi
mov    $0x2,%esi
xor    %edx,%edx
call   1040 <ft_print@plt>
mov    %eax,-0x4(%rbp)
jmp    118c <valid_input_or_die+0x6c>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<valid_input_or_die>:
push   %rbx
mov    %rdi,%rbx
call   1030 <env_get_size@plt>
test   %rbx,%rbx
je     113d <valid_input_or_die+0x1d>
cmp    $0x3,%rax
jb     1151 <valid_input_or_die+0x31>
lea    0xee8(%rip),%rdi
jmp    1144 <valid_input_or_die+0x24>
lea    0xebc(%rip),%rdi
mov    $0x2,%esi
xor    %edx,%edx
pop    %rbx
jmp    1040 <ft_print@plt>
mov    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [35 x i8] c"ft_minishell2 :\09An error occured.\0A\00"
@.str.1 = [23 x i8] c"exit :\09E_TOO_MANY_ARGS\00"
define i32 @valid_input_or_die(i8** %0) {
%2 = alloca i32
%3 = alloca i8**
%4 = alloca i64
store i8** %0, i8*** %3
%5 = load i8**, i8*** %3
%6 = call i64 @env_get_size(i8** %5)
store i64 %6, i64* %4
%7 = load i8**, i8*** %3
%8 = icmp ne i8** %7, null
br i1 %8, label %11, label %9
9: ; preds = %1
%10 = call i32 @ft_print(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 2, i32 0)
store i32 %10, i32* %2
br label %17
11: ; preds = %1
%12 = load i64, i64* %4
%13 = icmp ugt i64 %12, 2
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = call i32 @ft_print(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 2, i32 0)
store i32 %15, i32* %2
br label %17
16: ; preds = %11
store i32 1, i32* %2
br label %17
17: ; preds = %16, %14, %9
%18 = load i32, i32* %2
ret i32 %18
}

LLVM IR (-O2):
@.str = [35 x i8] c"ft_minishell2 :\09An error occured.\0A\00"
@.str.1 = [23 x i8] c"exit :\09E_TOO_MANY_ARGS\00"
define i32 @valid_input_or_die(i8** %0) {
%2 = tail call i64 @env_get_size(i8** %0)
%3 = icmp eq i8** %0, null
br i1 %3, label %6, label %4
4: ; preds = %1
%5 = icmp ugt i64 %2, 2
br i1 %5, label %6, label %9
6: ; preds = %4, %1
%7 = phi i8* [ getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), %4 ]
%8 = tail call i32 @ft_print(i8* %7, i32 2, i32 0)
br label %9
9: ; preds = %6, %4
%10 = phi i32 [ 1, %4 ], [ %8, %6 ]
ret i32 %10
}