#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*/ free(char **);
char **my_str_to_wordtab(char *, char);
scalar_t__ my_strncmp(char *, char *);
int check_built(char **save) {
  int i;
  char *str;
  char **tab;
  i = 0;
  str = "cd .. env exit setenv unsetenv";
  tab = my_str_to_wordtab(str, ' ');
  if (save == NULL)
    return (0);
  while (tab[i]) {
    if ((my_strncmp(tab[i], save[0])) == 0)
      return (1);
    i++;
  }
  free(tab);
  return (0);
}


x86 assembly (clang, -O0):
<check_built>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xeb6(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x20,%esi
call   1040 <my_str_to_wordtab@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1177 <check_built+0x47>
movl   $0x0,-0x4(%rbp)
jmp    11db <check_built+0xab>
jmp    117c <check_built+0x4c>
mov    -0x28(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     11cb <check_built+0x9b>
mov    -0x28(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
call   1050 <my_strncmp@plt>
cmp    $0x0,%rax
jne    11bd <check_built+0x8d>
movl   $0x1,-0x4(%rbp)
jmp    11db <check_built+0xab>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117c <check_built+0x4c>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_built>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xebf(%rip),%rdi
mov    $0x20,%esi
call   1040 <my_str_to_wordtab@plt>
xor    %r14d,%r14d
test   %rbx,%rbx
je     119a <check_built+0x6a>
mov    %rax,%r15
mov    (%rax),%rdi
test   %rdi,%rdi
je     118a <check_built+0x5a>
mov    %r15,%rbp
add    $0x8,%rbp
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%rbx),%rsi
call   1050 <my_strncmp@plt>
test   %rax,%rax
je     1194 <check_built+0x64>
mov    0x0(%rbp),%rdi
add    $0x8,%rbp
test   %rdi,%rdi
jne    1170 <check_built+0x40>
mov    %r15,%rdi
call   1030 <free@plt>
jmp    119a <check_built+0x6a>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [31 x i8] c"cd .. env exit setenv unsetenv\00"
define i32 @check_built(i8** %0) {
%2 = alloca i32
%3 = alloca i8**
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8**
store i8** %0, i8*** %3
store i32 0, i32* %4
store i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8** %5
%7 = load i8*, i8** %5
%8 = call i8** @my_str_to_wordtab(i8* %7, i8 signext 32)
store i8** %8, i8*** %6
%9 = load i8**, i8*** %3
%10 = icmp eq i8** %9, null
br i1 %10, label %11, label %12
11: ; preds = %1
store i32 0, i32* %2
br label %38
12: ; preds = %1
br label %13
13: ; preds = %32, %12
%14 = load i8**, i8*** %6
%15 = load i32, i32* %4
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8*, i8** %14, i64 %16
%18 = load i8*, i8** %17
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %35
20: ; preds = %13
%21 = load i8**, i8*** %6
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8*, i8** %21, i64 %23
%25 = load i8*, i8** %24
%26 = load i8**, i8*** %3
%27 = getelementptr inbounds i8*, i8** %26, i64 0
%28 = load i8*, i8** %27
%29 = call i64 @my_strncmp(i8* %25, i8* %28)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %20
store i32 1, i32* %2
br label %38
32: ; preds = %20
%33 = load i32, i32* %4
%34 = add nsw i32 %33, 1
store i32 %34, i32* %4
br label %13
35: ; preds = %13
%36 = load i8**, i8*** %6
%37 = call i32 @free(i8** %36)
store i32 0, i32* %2
br label %38
38: ; preds = %35, %31, %11
%39 = load i32, i32* %2
ret i32 %39
}

LLVM IR (-O2):
@.str = [31 x i8] c"cd .. env exit setenv unsetenv\00"
define i32 @check_built(i8** %0) {
%2 = tail call i8** @my_str_to_wordtab(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8 signext 32)
%3 = icmp eq i8** %0, null
br i1 %3, label %20, label %4
4: ; preds = %1
%5 = load i8*, i8** %2
%6 = icmp eq i8* %5, null
br i1 %6, label %18, label %11
7: ; preds = %11
%8 = getelementptr inbounds i8*, i8** %2, i64 %17
%9 = load i8*, i8** %8
%10 = icmp eq i8* %9, null
br i1 %10, label %18, label %11
11: ; preds = %4, %7
%12 = phi i64 [ %17, %7 ], [ 0, %4 ]
%13 = phi i8* [ %9, %7 ], [ %5, %4 ]
%14 = load i8*, i8** %0
%15 = tail call i64 @my_strncmp(i8* %13, i8* %14)
%16 = icmp eq i64 %15, 0
%17 = add nuw i64 %12, 1
br i1 %16, label %20, label %7
18: ; preds = %7, %4
%19 = tail call i32 @free(i8** %2)
br label %20
20: ; preds = %11, %1, %18
%21 = phi i32 [ 0, %18 ], [ 0, %1 ], [ 1, %11 ]
ret i32 %21
}