#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",       "sys/stat.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    $0x90,%rsp
lea    -0x80(%rbp),%rdi
lea    0x2c3a(%rip),%rsi
mov    $0x80,%edx
call   1050 <memcpy@plt>
lea    -0x80(%rbp),%rdi
call   1030 <chaz_HeadCheck_check_many_headers@plt>
cmp    $0x0,%rax
je     11da <chaz_Headers_probe_posix+0x8a>
lea    0xeff(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <chaz_ConfWriter_add_def@plt>
movl   $0x0,-0x84(%rbp)
movslq -0x84(%rbp),%rax
cmpq   $0x0,-0x80(%rbp,%rax,8)
je     11d5 <chaz_Headers_probe_posix+0x85>
movslq -0x84(%rbp),%rax
mov    -0x80(%rbp,%rax,8),%rdi
call   1070 <chaz_Headers_keep@plt>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    119d <chaz_Headers_probe_posix+0x4d>
jmp    1241 <chaz_Headers_probe_posix+0xf1>
movl   $0x0,-0x84(%rbp)
movslq -0x84(%rbp),%rax
cmpq   $0x0,-0x80(%rbp,%rax,8)
je     123c <chaz_Headers_probe_posix+0xec>
movslq -0x84(%rbp),%rax
mov    -0x80(%rbp,%rax,8),%rdi
call   1060 <chaz_HeadCheck_check_header@plt>
cmp    $0x0,%rax
je     1223 <chaz_Headers_probe_posix+0xd3>
movslq -0x84(%rbp),%rax
mov    -0x80(%rbp,%rax,8),%rdi
call   1070 <chaz_Headers_keep@plt>
jmp    1228 <chaz_Headers_probe_posix+0xd8>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    11e4 <chaz_Headers_probe_posix+0x94>
jmp    1241 <chaz_Headers_probe_posix+0xf1>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chaz_Headers_probe_posix>:
push   %rbx
sub    $0x80,%rsp
movaps 0x2cc1(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0x2ca5(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0x2c89(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0x2c6d(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0x2c51(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0x2c35(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0x2c19(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0x2bfd(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
call   1030 <chaz_HeadCheck_check_many_headers@plt>
test   %rax,%rax
je     11e3 <chaz_Headers_probe_posix+0xa3>
lea    0xece(%rip),%rdi
xor    %esi,%esi
call   1040 <chaz_ConfWriter_add_def@plt>
mov    (%rsp),%rdi
test   %rdi,%rdi
je     1221 <chaz_Headers_probe_posix+0xe1>
lea    0x8(%rsp),%rbx
call   1060 <chaz_Headers_keep@plt>
mov    (%rbx),%rdi
add    $0x8,%rbx
test   %rdi,%rdi
jne    11d0 <chaz_Headers_probe_posix+0x90>
jmp    1221 <chaz_Headers_probe_posix+0xe1>
mov    (%rsp),%rdi
test   %rdi,%rdi
je     1221 <chaz_Headers_probe_posix+0xe1>
lea    0x8(%rsp),%rbx
jmp    120c <chaz_Headers_probe_posix+0xcc>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%rbx),%rdi
add    $0x8,%rbx
test   %rdi,%rdi
je     1221 <chaz_Headers_probe_posix+0xe1>
call   1050 <chaz_HeadCheck_check_header@plt>
test   %rax,%rax
je     1200 <chaz_Headers_probe_posix+0xc0>
mov    -0x8(%rbx),%rdi
call   1060 <chaz_Headers_keep@plt>
jmp    1200 <chaz_Headers_probe_posix+0xc0>
add    $0x80,%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 = [11 x i8] c"sys/stat.h\00"
@.str.7 = [12 x i8] c"sys/times.h\00"
@.str.8 = [12 x i8] c"sys/types.h\00"
@.str.9 = [14 x i8] c"sys/utsname.h\00"
@.str.10 = [11 x i8] c"sys/wait.h\00"
@.str.11 = [6 x i8] c"tar.h\00"
@.str.12 = [10 x i8] c"termios.h\00"
@.str.13 = [9 x i8] c"unistd.h\00"
@.str.14 = [8 x i8] c"utime.h\00"
@__const.chaz_Headers_probe_posix.posix_headers = [16 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 ([11 x i8], [11 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.14, i32 0, i32 0), i8* null]
@.str.15 = [10 x i8] c"HAS_POSIX\00"
define void @chaz_Headers_probe_posix() {
%1 = alloca [16 x i8*]
%2 = alloca i32
%3 = bitcast [16 x i8*]* %1 to i8*
%4 = getelementptr inbounds [16 x i8*], [16 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.15, 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 [16 x i8*], [16 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 [16 x i8*], [16 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 [16 x i8*], [16 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 [16 x i8*], [16 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 [16 x i8*], [16 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 = [11 x i8] c"sys/stat.h\00"
@.str.7 = [12 x i8] c"sys/times.h\00"
@.str.8 = [12 x i8] c"sys/types.h\00"
@.str.9 = [14 x i8] c"sys/utsname.h\00"
@.str.10 = [11 x i8] c"sys/wait.h\00"
@.str.11 = [6 x i8] c"tar.h\00"
@.str.12 = [10 x i8] c"termios.h\00"
@.str.13 = [9 x i8] c"unistd.h\00"
@.str.14 = [8 x i8] c"utime.h\00"
@__const.chaz_Headers_probe_posix.posix_headers = [16 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 ([11 x i8], [11 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.14, i32 0, i32 0), i8* null]
@.str.15 = [10 x i8] c"HAS_POSIX\00"
define void @chaz_Headers_probe_posix() {
%1 = alloca [16 x i8*]
%2 = bitcast [16 x i8*]* %1 to i8*
%3 = getelementptr inbounds [16 x i8*], [16 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.15, 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 [16 x i8*], [16 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 [16 x i8*], [16 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
}