#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 S_ISREG(int /*<<< orphan*/);
int /*<<< orphan*/ handle_fatalf(char *, int, char *, char const *);
scalar_t__ stat(char const *, struct stat *);
bool file_is_regular(const char *path) {
  bool is_regular = false;
  struct stat st;
  if (stat(path, &st))
    handle_fatalf("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                  "outputs/2022-01-22/02-19-57/repos/lapesd/iore/refs/heads/"
                  "master/src/common/iore_file.c",
                  61, "Stat failed: '%s'.", path);
  else
    is_regular = S_ISREG(st.st_mode);
  return is_regular;
}


x86 assembly (clang, -O0):
<file_is_regular>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <stat@plt>
cmp    $0x0,%rax
je     117b <file_is_regular+0x4b>
mov    -0x8(%rbp),%rcx
lea    0xe9b(%rip),%rdi
mov    $0x3d,%esi
lea    0xf1e(%rip),%rdx
call   1030 <handle_fatalf@plt>
jmp    1186 <file_is_regular+0x56>
mov    -0x10(%rbp),%edi
call   1050 <S_ISREG@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<file_is_regular>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0x8(%rsp),%rsi
call   1040 <stat@plt>
test   %rax,%rax
je     1166 <file_is_regular+0x36>
lea    0xeb2(%rip),%rdi
lea    0xf3a(%rip),%rdx
mov    $0x3d,%esi
mov    %rbx,%rcx
call   1030 <handle_fatalf@plt>
xor    %eax,%eax
jmp    116f <file_is_regular+0x3f>
mov    0x8(%rsp),%edi
call   1050 <S_ISREG@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [143 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/lapesd/iore/refs/heads/master/src/common/iore_file.c\00"
@.str.1 = [19 x i8] c"Stat failed: '%s'.\00"
define i32 @file_is_regular(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca %struct.stat
store i8* %0, i8** %2
store i32 0, i32* %3
%5 = load i8*, i8** %2
%6 = call i64 @stat(i8* %5, %struct.stat* %4)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = load i8*, i8** %2
%10 = call i32 @handle_fatalf(i8* getelementptr inbounds ([143 x i8], [143 x i8]* @.str, i64 0, i64 0), i32 61, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %9)
br label %15
11: ; preds = %1
%12 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 0
%13 = load i32, i32* %12
%14 = call i32 @S_ISREG(i32 %13)
store i32 %14, i32* %3
br label %15
15: ; preds = %11, %8
%16 = load i32, i32* %3
ret i32 %16
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [143 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/lapesd/iore/refs/heads/master/src/common/iore_file.c\00"
@.str.1 = [19 x i8] c"Stat failed: '%s'.\00"
define i32 @file_is_regular(i8* %0) {
%2 = alloca %struct.stat
%3 = bitcast %struct.stat* %2 to i8*
%4 = call i64 @stat(i8* %0, %struct.stat* %2)
%5 = icmp eq i64 %4, 0
br i1 %5, label %8, label %6
6: ; preds = %1
%7 = call i32 @handle_fatalf(i8* getelementptr inbounds ([143 x i8], [143 x i8]* @.str, i64 0, i64 0), i32 61, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %12
8: ; preds = %1
%9 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 0
%10 = load i32, i32* %9
%11 = call i32 @S_ISREG(i32 %10)
br label %12
12: ; preds = %8, %6
%13 = phi i32 [ 0, %6 ], [ %11, %8 ]
ret i32 %13
}