#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 */
struct stat {
  int /*<<< orphan*/ st_mode;
};

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ Logging__error(char *, int, char *);
int /*<<< orphan*/ Logging__errorf(char *, int, char *, char const *, ...);
int /*<<< orphan*/ R_OK;
int /*<<< orphan*/ S_ISDIR(int /*<<< orphan*/);
int access(char const *, int /*<<< orphan*/);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ stat(char const *, struct stat *);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
scalar_t__ strxnullorempty(char const *);
void checkDir(const char *dirPath) {
  struct stat st;
  if (strxnullorempty(dirPath)) {
    Logging__error(
        "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
        "2022-01-22/02-19-57/repos/kaiaie/bile/refs/heads/master/src/Bile.c",
        98, "No directory specified");
    exit(EXIT_FAILURE);
  }
  if (stat(dirPath, &st) != 0) {
    Logging__errorf(
        "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
        "2022-01-22/02-19-57/repos/kaiaie/bile/refs/heads/master/src/Bile.c",
        102, "%s: %s", dirPath, strerror(errno));
    exit(EXIT_FAILURE);
  }
  if (!S_ISDIR(st.st_mode)) {
    Logging__errorf(
        "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
        "2022-01-22/02-19-57/repos/kaiaie/bile/refs/heads/master/src/Bile.c",
        106, "%s: not a directory", dirPath);
    exit(EXIT_FAILURE);
  }
  if (access(dirPath, R_OK) == -1) {
    Logging__errorf(
        "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
        "2022-01-22/02-19-57/repos/kaiaie/bile/refs/heads/master/src/Bile.c",
        110, "%s: %s", dirPath, strerror(errno));
    exit(EXIT_FAILURE);
  }
}


x86 assembly (clang, -O0):
<checkDir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strxnullorempty@plt>
cmp    $0x0,%rax
je     11c5 <checkDir+0x45>
lea    0xe5a(%rip),%rdi
mov    $0x62,%esi
lea    0xed1(%rip),%rdx
call   1060 <Logging__error@plt>
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <stat@plt>
cmp    $0x0,%rax
je     1221 <checkDir+0xa1>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    0x2df5(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x18(%rbp),%rcx
mov    %eax,%r8d
lea    0xe00(%rip),%rdi
mov    $0x66,%esi
lea    0xe8e(%rip),%rdx
mov    $0x0,%al
call   10a0 <Logging__errorf@plt>
mov    0x2dbe(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%edi
call   1040 <S_ISDIR@plt>
cmp    $0x0,%eax
jne    125e <checkDir+0xde>
mov    -0x8(%rbp),%rcx
lea    0xdc3(%rip),%rdi
mov    $0x6a,%esi
lea    0xe58(%rip),%rdx
mov    $0x0,%al
call   10a0 <Logging__errorf@plt>
mov    0x2d81(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x8(%rbp),%rdi
mov    0x2d67(%rip),%rax
mov    (%rax),%esi
call   1070 <access@plt>
cmp    $0xffffffff,%eax
jne    12be <checkDir+0x13e>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    0x2d58(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x20(%rbp),%rcx
mov    %eax,%r8d
lea    0xd63(%rip),%rdi
mov    $0x6e,%esi
lea    0xdf1(%rip),%rdx
mov    $0x0,%al
call   10a0 <Logging__errorf@plt>
mov    0x2d21(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkDir>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
call   1030 <strxnullorempty@plt>
test   %rax,%rax
jne    11cd <checkDir+0x4d>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <stat@plt>
test   %rax,%rax
jne    11e7 <checkDir+0x67>
mov    0x8(%rsp),%edi
call   1040 <S_ISDIR@plt>
test   %eax,%eax
je     120a <checkDir+0x8a>
mov    0x2e18(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1070 <access@plt>
cmp    $0xffffffff,%eax
je     1229 <checkDir+0xa9>
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe2c(%rip),%rdi
lea    0xea8(%rip),%rdx
mov    $0x62,%esi
call   1060 <Logging__error@plt>
jmp    1257 <checkDir+0xd7>
mov    0x2df2(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xe04(%rip),%rdi
lea    0xe97(%rip),%rdx
mov    $0x66,%esi
jmp    124a <checkDir+0xca>
lea    0xdef(%rip),%rdi
lea    0xe89(%rip),%rdx
mov    $0x6a,%esi
mov    %rbx,%rcx
xor    %eax,%eax
call   10a0 <Logging__errorf@plt>
jmp    1257 <checkDir+0xd7>
mov    0x2db0(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xdc2(%rip),%rdi
lea    0xe55(%rip),%rdx
mov    $0x6e,%esi
mov    %rbx,%rcx
mov    %eax,%r8d
xor    %eax,%eax
call   10a0 <Logging__errorf@plt>
mov    0x2d7a(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [131 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/kaiaie/bile/refs/heads/master/src/Bile.c\00"
@.str.1 = [23 x i8] c"No directory specified\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [7 x i8] c"%s: %s\00"
@errno = global i32 0
@.str.3 = [20 x i8] c"%s: not a directory\00"
@R_OK = global i32 0
define void @checkDir(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.stat
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i64 @strxnullorempty(i8* %4)
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %1
%8 = call i32 @Logging__error(i8* getelementptr inbounds ([131 x i8], [131 x i8]* @.str, i64 0, i64 0), i32 98, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%9 = load i32, i32* @EXIT_FAILURE
%10 = call i32 @exit(i32 %9)
unreachable
11: ; preds = %1
%12 = load i8*, i8** %2
%13 = call i64 @stat(i8* %12, %struct.stat* %3)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %22
15: ; preds = %11
%16 = load i8*, i8** %2
%17 = load i32, i32* @errno
%18 = call i32 @strerror(i32 %17)
%19 = call i32 (i8*, i32, i8*, i8*, ...) @Logging__errorf(i8* getelementptr inbounds ([131 x i8], [131 x i8]* @.str, i64 0, i64 0), i32 102, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %16, i32 %18)
%20 = load i32, i32* @EXIT_FAILURE
%21 = call i32 @exit(i32 %20)
unreachable
22: ; preds = %11
%23 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 0
%24 = load i32, i32* %23
%25 = call i32 @S_ISDIR(i32 %24)
%26 = icmp ne i32 %25, 0
br i1 %26, label %32, label %27
27: ; preds = %22
%28 = load i8*, i8** %2
%29 = call i32 (i8*, i32, i8*, i8*, ...) @Logging__errorf(i8* getelementptr inbounds ([131 x i8], [131 x i8]* @.str, i64 0, i64 0), i32 106, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i8* %28)
%30 = load i32, i32* @EXIT_FAILURE
%31 = call i32 @exit(i32 %30)
unreachable
32: ; preds = %22
%33 = load i8*, i8** %2
%34 = load i32, i32* @R_OK
%35 = call i32 @access(i8* %33, i32 %34)
%36 = icmp eq i32 %35, -1
br i1 %36, label %37, label %44
37: ; preds = %32
%38 = load i8*, i8** %2
%39 = load i32, i32* @errno
%40 = call i32 @strerror(i32 %39)
%41 = call i32 (i8*, i32, i8*, i8*, ...) @Logging__errorf(i8* getelementptr inbounds ([131 x i8], [131 x i8]* @.str, i64 0, i64 0), i32 110, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %38, i32 %40)
%42 = load i32, i32* @EXIT_FAILURE
%43 = call i32 @exit(i32 %42)
unreachable
44: ; preds = %32
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [131 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/kaiaie/bile/refs/heads/master/src/Bile.c\00"
@.str.1 = [23 x i8] c"No directory specified\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [7 x i8] c"%s: %s\00"
@errno = global i32 0
@.str.3 = [20 x i8] c"%s: not a directory\00"
@R_OK = global i32 0
define void @checkDir(i8* %0) {
%2 = alloca %struct.stat
%3 = bitcast %struct.stat* %2 to i8*
%4 = tail call i64 @strxnullorempty(i8* %0)
%5 = icmp eq i64 %4, 0
br i1 %5, label %10, label %6
6: ; preds = %1
%7 = tail call i32 @Logging__error(i8* getelementptr inbounds ([131 x i8], [131 x i8]* @.str, i64 0, i64 0), i32 98, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%8 = load i32, i32* @EXIT_FAILURE
%9 = tail call i32 @exit(i32 %8)
unreachable
10: ; preds = %1
%11 = call i64 @stat(i8* %0, %struct.stat* %2)
%12 = icmp eq i64 %11, 0
br i1 %12, label %19, label %13
13: ; preds = %10
%14 = load i32, i32* @errno
%15 = call i32 @strerror(i32 %14)
%16 = call i32 (i8*, i32, i8*, i8*, ...) @Logging__errorf(i8* getelementptr inbounds ([131 x i8], [131 x i8]* @.str, i64 0, i64 0), i32 102, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %0, i32 %15)
%17 = load i32, i32* @EXIT_FAILURE
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %10
%20 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 0
%21 = load i32, i32* %20
%22 = call i32 @S_ISDIR(i32 %21)
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %28
24: ; preds = %19
%25 = call i32 (i8*, i32, i8*, i8*, ...) @Logging__errorf(i8* getelementptr inbounds ([131 x i8], [131 x i8]* @.str, i64 0, i64 0), i32 106, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i8* %0)
%26 = load i32, i32* @EXIT_FAILURE
%27 = call i32 @exit(i32 %26)
unreachable
28: ; preds = %19
%29 = load i32, i32* @R_OK
%30 = call i32 @access(i8* %0, i32 %29)
%31 = icmp eq i32 %30, -1
br i1 %31, label %32, label %38
32: ; preds = %28
%33 = load i32, i32* @errno
%34 = call i32 @strerror(i32 %33)
%35 = call i32 (i8*, i32, i8*, i8*, ...) @Logging__errorf(i8* getelementptr inbounds ([131 x i8], [131 x i8]* @.str, i64 0, i64 0), i32 110, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %0, i32 %34)
%36 = load i32, i32* @EXIT_FAILURE
%37 = call i32 @exit(i32 %36)
unreachable
38: ; preds = %28
ret void
}