#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 st_mode;
};

/* Variables and functions */
int S_IFDIR;
int /*<<< orphan*/ err_log(int, int, char *, char *);
scalar_t__ os_stat(char *, struct stat *);
int _conf_existdir(char *path) {
  struct stat sb;
  err_log(9, 0x00000001, "Checking existence of %s\n", path);
  if (os_stat(path, &sb)) {
    return 0;
  }
  if (sb.st_mode & S_IFDIR)
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<_conf_existdir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rcx
mov    $0x9,%edi
mov    $0x1,%esi
lea    0xebf(%rip),%rdx
call   1040 <err_log@plt>
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <os_stat@plt>
cmp    $0x0,%rax
je     1169 <_conf_existdir+0x49>
movl   $0x0,-0x4(%rbp)
jmp    1191 <_conf_existdir+0x71>
mov    -0x18(%rbp),%eax
mov    0x2e65(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     118a <_conf_existdir+0x6a>
movl   $0x1,-0x4(%rbp)
jmp    1191 <_conf_existdir+0x71>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_conf_existdir>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0xed1(%rip),%rdx
mov    $0x9,%edi
mov    $0x1,%esi
mov    %rbx,%rcx
call   1040 <err_log@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1030 <os_stat@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jne    116a <_conf_existdir+0x4a>
mov    0x2e79(%rip),%rax
mov    (%rax),%ecx
xor    %eax,%eax
test   %ecx,0x8(%rsp)
setne  %al
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [26 x i8] c"Checking existence of %s\0A\00"
@S_IFDIR = global i32 0
define i32 @_conf_existdir(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca %struct.stat
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i32 @err_log(i32 9, i32 1, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = load i8*, i8** %3
%8 = call i64 @os_stat(i8* %7, %struct.stat* %4)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %1
store i32 0, i32* %2
br label %19
11: ; preds = %1
%12 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 0
%13 = load i32, i32* %12
%14 = load i32, i32* @S_IFDIR
%15 = and i32 %13, %14
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %11
store i32 1, i32* %2
br label %19
18: ; preds = %11
store i32 0, i32* %2
br label %19
19: ; preds = %18, %17, %10
%20 = load i32, i32* %2
ret i32 %20
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [26 x i8] c"Checking existence of %s\0A\00"
@S_IFDIR = global i32 0
define i32 @_conf_existdir(i8* %0) {
%2 = alloca %struct.stat
%3 = bitcast %struct.stat* %2 to i8*
%4 = tail call i32 @err_log(i32 9, i32 1, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = call i64 @os_stat(i8* %0, %struct.stat* %2)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %14
7: ; preds = %1
%8 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 0
%9 = load i32, i32* %8
%10 = load i32, i32* @S_IFDIR
%11 = and i32 %10, %9
%12 = icmp ne i32 %11, 0
%13 = zext i1 %12 to i32
br label %14
14: ; preds = %7, %1
%15 = phi i32 [ 0, %1 ], [ %13, %7 ]
ret i32 %15
}