#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 */
scalar_t__ S_ISREG(int /*<<< orphan*/);
int lstat(char const *, struct stat *);
int /*<<< orphan*/ wheat_assert(char *, char *, int, int);
int isRegFile(const char *path) {
  do {
    if (!(path)) {
      wheat_assert("path",
                   "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                   "outputs/2022-01-22/02-19-57/repos/yuyuyu101/wheatserver/"
                   "refs/heads/master/src/util.c",
                   283, 1);
    }
  } while (0);
  struct stat stat;
  int ret = lstat(path, &stat);
  if (ret == -1)
    return -1;
  return S_ISREG(stat.st_mode) == 0 ? -1 : 0;
}


x86 assembly (clang, -O0):
<isRegFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1164 <isRegFile+0x34>
lea    0xeb2(%rip),%rdi
lea    0xeb0(%rip),%rsi
mov    $0x11b,%edx
mov    $0x1,%ecx
call   1040 <wheat_assert@plt>
jmp    1169 <isRegFile+0x39>
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <lstat@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    118f <isRegFile+0x5f>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ab <isRegFile+0x7b>
mov    -0x18(%rbp),%edi
call   1050 <S_ISREG@plt>
mov    %rax,%rdx
xor    %eax,%eax
mov    $0xffffffff,%ecx
cmp    $0x0,%rdx
cmove  %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isRegFile>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
test   %rdi,%rdi
jne    115a <isRegFile+0x2a>
lea    0xebc(%rip),%rdi
lea    0xeba(%rip),%rsi
mov    $0x11b,%edx
mov    $0x1,%ecx
call   1040 <wheat_assert@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1030 <lstat@plt>
cmp    $0xffffffff,%eax
je     117d <isRegFile+0x4d>
mov    0x8(%rsp),%edi
call   1050 <S_ISREG@plt>
cmp    $0x1,%rax
sbb    %eax,%eax
jmp    1182 <isRegFile+0x52>
mov    $0xffffffff,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [5 x i8] c"path\00"
@.str.1 = [141 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/yuyuyu101/wheatserver/refs/heads/master/src/util.c\00"
define i32 @isRegFile(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca %struct.stat
%5 = alloca i32
store i8* %0, i8** %3
br label %6
6: ; preds = %1
%7 = load i8*, i8** %3
%8 = icmp ne i8* %7, null
br i1 %8, label %11, label %9
9: ; preds = %6
%10 = call i32 @wheat_assert(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.1, i64 0, i64 0), i32 283, i32 1)
br label %11
11: ; preds = %9, %6
br label %12
12: ; preds = %11
%13 = load i8*, i8** %3
%14 = call i32 @lstat(i8* %13, %struct.stat* %4)
store i32 %14, i32* %5
%15 = load i32, i32* %5
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %18
17: ; preds = %12
store i32 -1, i32* %2
br label %25
18: ; preds = %12
%19 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 0
%20 = load i32, i32* %19
%21 = call i64 @S_ISREG(i32 %20)
%22 = icmp eq i64 %21, 0
%23 = zext i1 %22 to i64
%24 = select i1 %22, i32 -1, i32 0
store i32 %24, i32* %2
br label %25
25: ; preds = %18, %17
%26 = load i32, i32* %2
ret i32 %26
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [5 x i8] c"path\00"
@.str.1 = [141 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/yuyuyu101/wheatserver/refs/heads/master/src/util.c\00"
define i32 @isRegFile(i8* %0) {
%2 = alloca %struct.stat
%3 = icmp eq i8* %0, null
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @wheat_assert(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.1, i64 0, i64 0), i32 283, i32 1)
br label %6
6: ; preds = %1, %4
%7 = bitcast %struct.stat* %2 to i8*
%8 = call i32 @lstat(i8* %0, %struct.stat* %2)
%9 = icmp eq i32 %8, -1
br i1 %9, label %16, label %10
10: ; preds = %6
%11 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 0
%12 = load i32, i32* %11
%13 = tail call i64 @S_ISREG(i32 %12)
%14 = icmp eq i64 %13, 0
%15 = sext i1 %14 to i32
br label %16
16: ; preds = %6, %10
%17 = phi i32 [ %15, %10 ], [ -1, %6 ]
ret i32 %17
}