#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*/ chaz_ConfWriter_add_def(char *, int /*<<< orphan*/ *);
scalar_t__ chaz_HeadCheck_check_header(char const *);
scalar_t__ chaz_HeadCheck_check_many_headers(char const **);
int /*<<< orphan*/ chaz_Headers_keep(char const *);
void chaz_Headers_probe_posix(void) {
  const char *posix_headers[] = {
      "cpio.h",      "dirent.h",      "fcntl.h",    "grp.h",      "pwd.h",
      "regex.h",     "sched.h",       "sys/stat.h", "sys/time.h", "sys/times.h",
      "sys/types.h", "sys/utsname.h", "sys/wait.h", "tar.h",      "termios.h",
      "unistd.h",    "utime.h",       NULL};
  int i;
  if (chaz_HeadCheck_check_many_headers((const char **)posix_headers)) {
    chaz_ConfWriter_add_def("HAS_POSIX", NULL);
    for (i = 0; posix_headers[i] != NULL; i++) {
      chaz_Headers_keep(posix_headers[i]);
    }
  } else {
    for (i = 0; posix_headers[i] != NULL; i++) {
      if (chaz_HeadCheck_check_header(posix_headers[i])) {
        chaz_Headers_keep(posix_headers[i]);
      }
    }
  }
}


x86 assembly (clang, -O0):
<chaz_Headers_probe_posix>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
lea    -0x90(%rbp),%rdi
lea    0x2c27(%rip),%rsi
mov    $0x90,%edx
call   1050 <memcpy@plt>
lea    -0x90(%rbp),%rdi
call   1030 <chaz_HeadCheck_check_many_headers@plt>
cmp    $0x0,%rax
je     11e6 <chaz_Headers_probe_posix+0x96>
lea    0xf0c(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <chaz_ConfWriter_add_def@plt>
movl   $0x0,-0x94(%rbp)
movslq -0x94(%rbp),%rax
cmpq   $0x0,-0x90(%rbp,%rax,8)
je     11e1 <chaz_Headers_probe_posix+0x91>
movslq -0x94(%rbp),%rax
mov    -0x90(%rbp,%rax,8),%rdi
ff
call   1070 <chaz_Headers_keep@plt>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    11a3 <chaz_Headers_probe_posix+0x53>
jmp    1256 <chaz_Headers_probe_posix+0x106>
movl   $0x0,-0x94(%rbp)
movslq -0x94(%rbp),%rax
cmpq   $0x0,-0x90(%rbp,%rax,8)
je     1251 <chaz_Headers_probe_posix+0x101>
movslq -0x94(%rbp),%rax
mov    -0x90(%rbp,%rax,8),%rdi
ff
call   1060 <chaz_HeadCheck_check_header@plt>
cmp    $0x0,%rax
je     1238 <chaz_Headers_probe_posix+0xe8>
movslq -0x94(%rbp),%rax
mov    -0x90(%rbp,%rax,8),%rdi
ff
call   1070 <chaz_Headers_keep@plt>
jmp    123d <chaz_Headers_probe_posix+0xed>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    11f0 <chaz_Headers_probe_posix+0xa0>
jmp    1256 <chaz_Headers_probe_posix+0x106>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chaz_Headers_probe_posix>:
push   %rbx
sub    $0x90,%rsp
lea    0x2c31(%rip),%rsi
mov    %rsp,%rbx
mov    $0x90,%edx
mov    %rbx,%rdi
call   1050 <memcpy@plt>
mov    %rbx,%rdi
call   1030 <chaz_HeadCheck_check_many_headers@plt>
test   %rax,%rax
je     11b3 <chaz_Headers_probe_posix+0x63>
lea    0xf19(%rip),%rdi
xor    %esi,%esi
call   1040 <chaz_ConfWriter_add_def@plt>
mov    (%rsp),%rdi
test   %rdi,%rdi
je     11f1 <chaz_Headers_probe_posix+0xa1>
lea    0x8(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
call   1070 <chaz_Headers_keep@plt>
mov    (%rbx),%rdi
add    $0x8,%rbx
test   %rdi,%rdi
jne    11a0 <chaz_Headers_probe_posix+0x50>
jmp    11f1 <chaz_Headers_probe_posix+0xa1>
mov    (%rsp),%rdi
test   %rdi,%rdi
je     11f1 <chaz_Headers_probe_posix+0xa1>
lea    0x8(%rsp),%rbx
jmp    11dc <chaz_Headers_probe_posix+0x8c>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%rbx),%rdi
add    $0x8,%rbx
test   %rdi,%rdi
je     11f1 <chaz_Headers_probe_posix+0xa1>
call   1060 <chaz_HeadCheck_check_header@plt>
test   %rax,%rax
je     11d0 <chaz_Headers_probe_posix+0x80>
mov    -0x8(%rbx),%rdi
call   1070 <chaz_Headers_keep@plt>
jmp    11d0 <chaz_Headers_probe_posix+0x80>
add    $0x90,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"cpio.h\00"
@.str.1 = [9 x i8] c"dirent.h\00"
@.str.2 = [8 x i8] c"fcntl.h\00"
@.str.3 = [6 x i8] c"grp.h\00"
@.str.4 = [6 x i8] c"pwd.h\00"
@.str.5 = [8 x i8] c"regex.h\00"
@.str.6 = [8 x i8] c"sched.h\00"
@.str.7 = [11 x i8] c"sys/stat.h\00"
@.str.8 = [11 x i8] c"sys/time.h\00"
@.str.9 = [12 x i8] c"sys/times.h\00"
@.str.10 = [12 x i8] c"sys/types.h\00"
@.str.11 = [14 x i8] c"sys/utsname.h\00"
@.str.12 = [11 x i8] c"sys/wait.h\00"
@.str.13 = [6 x i8] c"tar.h\00"
@.str.14 = [10 x i8] c"termios.h\00"
@.str.15 = [9 x i8] c"unistd.h\00"
@.str.16 = [8 x i8] c"utime.h\00"
@__const.chaz_Headers_probe_posix.posix_headers = [18 x i8*] [i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.15, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.16, i32 0, i32 0), i8* null]
@.str.17 = [10 x i8] c"HAS_POSIX\00"
define void @chaz_Headers_probe_posix() {
%1 = alloca [18 x i8*]
%2 = alloca i32
%3 = bitcast [18 x i8*]* %1 to i8*
%4 = getelementptr inbounds [18 x i8*], [18 x i8*]* %1, i64 0, i64 0
%5 = call i64 @chaz_HeadCheck_check_many_headers(i8** %4)
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %25
7: ; preds = %0
%8 = call i32 @chaz_ConfWriter_add_def(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.17, i64 0, i64 0), i32* null)
store i32 0, i32* %2
br label %9
9: ; preds = %21, %7
%10 = load i32, i32* %2
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [18 x i8*], [18 x i8*]* %1, i64 0, i64 %11
%13 = load i8*, i8** %12
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %24
15: ; preds = %9
%16 = load i32, i32* %2
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [18 x i8*], [18 x i8*]* %1, i64 0, i64 %17
%19 = load i8*, i8** %18
%20 = call i32 @chaz_Headers_keep(i8* %19)
br label %21
21: ; preds = %15
%22 = load i32, i32* %2
%23 = add nsw i32 %22, 1
store i32 %23, i32* %2
br label %9
24: ; preds = %9
br label %50
25: ; preds = %0
store i32 0, i32* %2
br label %26
26: ; preds = %46, %25
%27 = load i32, i32* %2
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [18 x i8*], [18 x i8*]* %1, i64 0, i64 %28
%30 = load i8*, i8** %29
%31 = icmp ne i8* %30, null
br i1 %31, label %32, label %49
32: ; preds = %26
%33 = load i32, i32* %2
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [18 x i8*], [18 x i8*]* %1, i64 0, i64 %34
%36 = load i8*, i8** %35
%37 = call i64 @chaz_HeadCheck_check_header(i8* %36)
%38 = icmp ne i64 %37, 0
br i1 %38, label %39, label %45
39: ; preds = %32
%40 = load i32, i32* %2
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [18 x i8*], [18 x i8*]* %1, i64 0, i64 %41
%43 = load i8*, i8** %42
%44 = call i32 @chaz_Headers_keep(i8* %43)
br label %45
45: ; preds = %39, %32
br label %46
46: ; preds = %45
%47 = load i32, i32* %2
%48 = add nsw i32 %47, 1
store i32 %48, i32* %2
br label %26
49: ; preds = %26
br label %50
50: ; preds = %49, %24
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"cpio.h\00"
@.str.1 = [9 x i8] c"dirent.h\00"
@.str.2 = [8 x i8] c"fcntl.h\00"
@.str.3 = [6 x i8] c"grp.h\00"
@.str.4 = [6 x i8] c"pwd.h\00"
@.str.5 = [8 x i8] c"regex.h\00"
@.str.6 = [8 x i8] c"sched.h\00"
@.str.7 = [11 x i8] c"sys/stat.h\00"
@.str.8 = [11 x i8] c"sys/time.h\00"
@.str.9 = [12 x i8] c"sys/times.h\00"
@.str.10 = [12 x i8] c"sys/types.h\00"
@.str.11 = [14 x i8] c"sys/utsname.h\00"
@.str.12 = [11 x i8] c"sys/wait.h\00"
@.str.13 = [6 x i8] c"tar.h\00"
@.str.14 = [10 x i8] c"termios.h\00"
@.str.15 = [9 x i8] c"unistd.h\00"
@.str.16 = [8 x i8] c"utime.h\00"
@__const.chaz_Headers_probe_posix.posix_headers = [18 x i8*] [i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.15, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.16, i32 0, i32 0), i8* null]
@.str.17 = [10 x i8] c"HAS_POSIX\00"
define void @chaz_Headers_probe_posix() {
%1 = alloca [18 x i8*]
%2 = bitcast [18 x i8*]* %1 to i8*
%3 = getelementptr inbounds [18 x i8*], [18 x i8*]* %1, i64 0, i64 0
%4 = call i64 @chaz_HeadCheck_check_many_headers(i8** %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %0
%7 = load i8*, i8** %3
%8 = icmp eq i8* %7, null
br i1 %8, label %35, label %21
9: ; preds = %0
%10 = call i32 @chaz_ConfWriter_add_def(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.17, i64 0, i64 0), i32* null)
%11 = load i8*, i8** %3
%12 = icmp eq i8* %11, null
br i1 %12, label %35, label %13
13: ; preds = %9, %13
%14 = phi i64 [ %17, %13 ], [ 0, %9 ]
%15 = phi i8* [ %19, %13 ], [ %11, %9 ]
%16 = call i32 @chaz_Headers_keep(i8* %15)
%17 = add nuw i64 %14, 1
%18 = getelementptr inbounds [18 x i8*], [18 x i8*]* %1, i64 0, i64 %17
%19 = load i8*, i8** %18
%20 = icmp eq i8* %19, null
br i1 %20, label %35, label %13
21: ; preds = %6, %30
%22 = phi i64 [ %31, %30 ], [ 0, %6 ]
%23 = phi i8* [ %33, %30 ], [ %7, %6 ]
%24 = phi i8** [ %32, %30 ], [ %3, %6 ]
%25 = call i64 @chaz_HeadCheck_check_header(i8* %23)
%26 = icmp eq i64 %25, 0
br i1 %26, label %30, label %27
27: ; preds = %21
%28 = load i8*, i8** %24
%29 = call i32 @chaz_Headers_keep(i8* %28)
br label %30
30: ; preds = %21, %27
%31 = add nuw i64 %22, 1
%32 = getelementptr inbounds [18 x i8*], [18 x i8*]* %1, i64 0, i64 %31
%33 = load i8*, i8** %32
%34 = icmp eq i8* %33, null
br i1 %34, label %35, label %21
35: ; preds = %13, %30, %9, %6
ret void
}