#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*/ ft_cmd_env_dropone(int);
int ft_cmd_env_srch(char *);
int ft_sh_error(char *);
size_t ft_sh_tablen(char **);
int ft_cmd_unsetenv(char **argv) {
  size_t argv_len;
  int foundid;
  size_t i;
  argv_len = ft_sh_tablen(argv);
  if (argv_len < 2)
    return (ft_sh_error("42sh: unsetenv: Too few arguments."));
  i = 1;
  while (i < argv_len) {
    if ((foundid = ft_cmd_env_srch(argv[i])) != -1)
      ft_cmd_env_dropone(foundid);
    i++;
  }
  return (1);
}


x86 assembly (clang, -O0):
<ft_cmd_unsetenv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <ft_sh_tablen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x2,-0x18(%rbp)
jae    1178 <ft_cmd_unsetenv+0x38>
lea    0xe95(%rip),%rdi
call   1040 <ft_sh_error@plt>
mov    %eax,-0x4(%rbp)
jmp    11cb <ft_cmd_unsetenv+0x8b>
movq   $0x1,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11c4 <ft_cmd_unsetenv+0x84>
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1060 <ft_cmd_env_srch@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
je     11b3 <ft_cmd_unsetenv+0x73>
mov    -0x1c(%rbp),%edi
call   1050 <ft_cmd_env_dropone@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1180 <ft_cmd_unsetenv+0x40>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_cmd_unsetenv>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
call   1030 <ft_sh_tablen@plt>
cmp    $0x2,%rax
jae    1164 <ft_cmd_unsetenv+0x24>
lea    0xea6(%rip),%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <ft_sh_error@plt>
mov    %rax,%r15
mov    $0x1,%ebx
jmp    1179 <ft_cmd_unsetenv+0x39>
xchg   %ax,%ax
add    $0x1,%rbx
cmp    %rbx,%r15
je     1190 <ft_cmd_unsetenv+0x50>
mov    (%r14,%rbx,8),%rdi
call   1060 <ft_cmd_env_srch@plt>
cmp    $0xffffffff,%eax
je     1170 <ft_cmd_unsetenv+0x30>
mov    %eax,%edi
call   1050 <ft_cmd_env_dropone@plt>
jmp    1170 <ft_cmd_unsetenv+0x30>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [35 x i8] c"42sh: unsetenv: Too few arguments.\00"
define i32 @ft_cmd_unsetenv(i8** %0) {
%2 = alloca i32
%3 = alloca i8**
%4 = alloca i64
%5 = alloca i32
%6 = alloca i64
store i8** %0, i8*** %3
%7 = load i8**, i8*** %3
%8 = call i64 @ft_sh_tablen(i8** %7)
store i64 %8, i64* %4
%9 = load i64, i64* %4
%10 = icmp ult i64 %9, 2
br i1 %10, label %11, label %13
11: ; preds = %1
%12 = call i32 @ft_sh_error(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
store i32 %12, i32* %2
br label %32
13: ; preds = %1
store i64 1, i64* %6
br label %14
14: ; preds = %28, %13
%15 = load i64, i64* %6
%16 = load i64, i64* %4
%17 = icmp ult i64 %15, %16
br i1 %17, label %18, label %31
18: ; preds = %14
%19 = load i8**, i8*** %3
%20 = load i64, i64* %6
%21 = getelementptr inbounds i8*, i8** %19, i64 %20
%22 = load i8*, i8** %21
%23 = call i32 @ft_cmd_env_srch(i8* %22)
store i32 %23, i32* %5
%24 = icmp ne i32 %23, -1
br i1 %24, label %25, label %28
25: ; preds = %18
%26 = load i32, i32* %5
%27 = call i32 @ft_cmd_env_dropone(i32 %26)
br label %28
28: ; preds = %25, %18
%29 = load i64, i64* %6
%30 = add i64 %29, 1
store i64 %30, i64* %6
br label %14
31: ; preds = %14
store i32 1, i32* %2
br label %32
32: ; preds = %31, %11
%33 = load i32, i32* %2
ret i32 %33
}

LLVM IR (-O2):
@.str = [35 x i8] c"42sh: unsetenv: Too few arguments.\00"
define i32 @ft_cmd_unsetenv(i8** %0) {
%2 = tail call i64 @ft_sh_tablen(i8** %0)
%3 = icmp ult i64 %2, 2
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @ft_sh_error(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
br label %17
6: ; preds = %1, %14
%7 = phi i64 [ %15, %14 ], [ 1, %1 ]
%8 = getelementptr inbounds i8*, i8** %0, i64 %7
%9 = load i8*, i8** %8
%10 = tail call i32 @ft_cmd_env_srch(i8* %9)
%11 = icmp eq i32 %10, -1
br i1 %11, label %14, label %12
12: ; preds = %6
%13 = tail call i32 @ft_cmd_env_dropone(i32 %10)
br label %14
14: ; preds = %12, %6
%15 = add nuw i64 %7, 1
%16 = icmp eq i64 %15, %2
br i1 %16, label %17, label %6
17: ; preds = %14, %4
%18 = phi i32 [ %5, %4 ], [ 1, %14 ]
ret i32 %18
}