#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 */
typedef int /*<<< orphan*/ time_t;
struct stat {
  int /*<<< orphan*/ st_mtime;
  int /*<<< orphan*/ st_size;
};
typedef int /*<<< orphan*/ off_t;

/* Variables and functions */
int fstat(int, struct stat *);
int /*<<< orphan*/ wheat_assert(char *, char *, int, int);
int getFileSizeAndMtime(int fd, off_t *len, time_t *m_time) {
  do {
    if (!(fd > 0)) {
      wheat_assert("fd > 0",
                   "/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",
                   270, 1);
    }
  } while (0);
  struct stat stat;
  int ret = fstat(fd, &stat);
  if (ret == -1)
    return -1;
  if (len)
    *len = stat.st_size;
  if (m_time)
    *m_time = stat.st_mtime;
  return 0;
}


x86 assembly (clang, -O0):
<getFileSizeAndMtime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x0,-0x8(%rbp)
jg     115a <getFileSizeAndMtime+0x3a>
lea    0xebc(%rip),%rdi
lea    0xebc(%rip),%rsi
mov    $0x10e,%edx
mov    $0x1,%ecx
call   1030 <wheat_assert@plt>
jmp    115f <getFileSizeAndMtime+0x3f>
mov    -0x8(%rbp),%edi
lea    -0x20(%rbp),%rsi
call   1040 <fstat@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    1184 <getFileSizeAndMtime+0x64>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b3 <getFileSizeAndMtime+0x93>
cmpq   $0x0,-0x10(%rbp)
je     1198 <getFileSizeAndMtime+0x78>
mov    -0x1c(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
cmpq   $0x0,-0x18(%rbp)
je     11ac <getFileSizeAndMtime+0x8c>
mov    -0x20(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getFileSizeAndMtime>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %edi,%ebp
test   %edi,%edi
jg     1151 <getFileSizeAndMtime+0x31>
lea    0xec5(%rip),%rdi
lea    0xec5(%rip),%rsi
mov    $0x10e,%edx
mov    $0x1,%ecx
call   1030 <wheat_assert@plt>
lea    0x8(%rsp),%rsi
mov    %ebp,%edi
call   1040 <fstat@plt>
cmp    $0xffffffff,%eax
je     117d <getFileSizeAndMtime+0x5d>
test   %rbx,%rbx
je     116d <getFileSizeAndMtime+0x4d>
mov    0xc(%rsp),%eax
mov    %eax,(%rbx)
xor    %eax,%eax
test   %r14,%r14
je     1182 <getFileSizeAndMtime+0x62>
mov    0x8(%rsp),%ecx
mov    %ecx,(%r14)
jmp    1182 <getFileSizeAndMtime+0x62>
mov    $0xffffffff,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i32, i32 }
@.str = [7 x i8] c"fd > 0\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 @getFileSizeAndMtime(i32 %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca %struct.stat
%9 = alloca i32
store i32 %0, i32* %5
store i32* %1, i32** %6
store i32* %2, i32** %7
br label %10
10: ; preds = %3
%11 = load i32, i32* %5
%12 = icmp sgt i32 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %10
%14 = call i32 @wheat_assert(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.1, i64 0, i64 0), i32 270, i32 1)
br label %15
15: ; preds = %13, %10
br label %16
16: ; preds = %15
%17 = load i32, i32* %5
%18 = call i32 @fstat(i32 %17, %struct.stat* %8)
store i32 %18, i32* %9
%19 = load i32, i32* %9
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %22
21: ; preds = %16
store i32 -1, i32* %4
br label %37
22: ; preds = %16
%23 = load i32*, i32** %6
%24 = icmp ne i32* %23, null
br i1 %24, label %25, label %29
25: ; preds = %22
%26 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 1
%27 = load i32, i32* %26
%28 = load i32*, i32** %6
store i32 %27, i32* %28
br label %29
29: ; preds = %25, %22
%30 = load i32*, i32** %7
%31 = icmp ne i32* %30, null
br i1 %31, label %32, label %36
32: ; preds = %29
%33 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 0
%34 = load i32, i32* %33
%35 = load i32*, i32** %7
store i32 %34, i32* %35
br label %36
36: ; preds = %32, %29
store i32 0, i32* %4
br label %37
37: ; preds = %36, %21
%38 = load i32, i32* %4
ret i32 %38
}

LLVM IR (-O2):
%struct.stat = type { i32, i32 }
@.str = [7 x i8] c"fd > 0\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 @getFileSizeAndMtime(i32 %0, i32* writeonly %1, i32* writeonly %2) {
%4 = alloca %struct.stat
%5 = icmp sgt i32 %0, 0
br i1 %5, label %8, label %6
6: ; preds = %3
%7 = tail call i32 @wheat_assert(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.1, i64 0, i64 0), i32 270, i32 1)
br label %8
8: ; preds = %3, %6
%9 = bitcast %struct.stat* %4 to i8*
%10 = call i32 @fstat(i32 %0, %struct.stat* %4)
%11 = icmp eq i32 %10, -1
br i1 %11, label %22, label %12
12: ; preds = %8
%13 = icmp eq i32* %1, null
br i1 %13, label %17, label %14
14: ; preds = %12
%15 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 1
%16 = load i32, i32* %15
store i32 %16, i32* %1
br label %17
17: ; preds = %14, %12
%18 = icmp eq i32* %2, null
br i1 %18, label %22, label %19
19: ; preds = %17
%20 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 0
%21 = load i32, i32* %20
store i32 %21, i32* %2
br label %22
22: ; preds = %17, %19, %8
%23 = phi i32 [ -1, %8 ], [ 0, %19 ], [ 0, %17 ]
ret i32 %23
}