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

/* Variables and functions */
int /*<<< orphan*/ _disp_stat(struct stat *);
int /*<<< orphan*/ _exit(int /*<<< orphan*/);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ free(struct stat *);
scalar_t__ malloc(int);
int /*<<< orphan*/ puts(int /*<<< orphan*/);
int stat(char *, struct stat *);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  struct stat *statbuf = (struct stat *)malloc(sizeof(*statbuf));
  if (!stat) {
    puts(strerror(errno));
    _exit(0);
  }
  int retval = stat("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                    "outputs/2022-01-22/02-19-57/repos/mapleez/eztip/refs/"
                    "heads/master/c/syscall_stat.c",
                    statbuf);
  if (retval < 0) {
    puts(strerror(errno));
    _exit(0);
  }
  _disp_stat(statbuf);
  free(statbuf);
  _exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x4,%edi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe61(%rip),%rdi
call   1060 <stat@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    11cd <main+0x5d>
mov    0x2e28(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    %eax,%edi
call   1050 <puts@plt>
xor    %edi,%edi
call   1040 <_exit@plt>
mov    -0x18(%rbp),%rdi
call   1080 <_disp_stat@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
xor    %edi,%edi
call   1040 <_exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x4,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
lea    0xe7b(%rip),%rdi
mov    %rax,%rsi
call   1060 <stat@plt>
test   %eax,%eax
jns    11ad <main+0x3d>
mov    0x2e48(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    %eax,%edi
call   1050 <puts@plt>
xor    %edi,%edi
call   1040 <_exit@plt>
mov    %rbx,%rdi
call   1080 <_disp_stat@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %edi,%edi
call   1040 <_exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [139 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/mapleez/eztip/refs/heads/master/c/syscall_stat.c\00"
@errno = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.stat*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i64 @malloc(i32 4)
%9 = inttoptr i64 %8 to %struct.stat*
store %struct.stat* %9, %struct.stat** %6
%10 = load %struct.stat*, %struct.stat** %6
%11 = call i32 @stat(i8* getelementptr inbounds ([139 x i8], [139 x i8]* @.str, i64 0, i64 0), %struct.stat* %10)
store i32 %11, i32* %7
%12 = load i32, i32* %7
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %2
%15 = load i32, i32* @errno
%16 = call i32 @strerror(i32 %15)
%17 = call i32 @puts(i32 %16)
%18 = call i32 @_exit(i32 0)
unreachable
19: ; preds = %2
%20 = load %struct.stat*, %struct.stat** %6
%21 = call i32 @_disp_stat(%struct.stat* %20)
%22 = load %struct.stat*, %struct.stat** %6
%23 = call i32 @free(%struct.stat* %22)
%24 = call i32 @_exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [139 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/mapleez/eztip/refs/heads/master/c/syscall_stat.c\00"
@errno = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i64 @malloc(i32 4)
%4 = inttoptr i64 %3 to %struct.stat*
%5 = tail call i32 @stat(i8* getelementptr inbounds ([139 x i8], [139 x i8]* @.str, i64 0, i64 0), %struct.stat* %4)
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %12
7: ; preds = %2
%8 = load i32, i32* @errno
%9 = tail call i32 @strerror(i32 %8)
%10 = tail call i32 @puts(i32 %9)
%11 = tail call i32 @_exit(i32 0)
unreachable
12: ; preds = %2
%13 = tail call i32 @_disp_stat(%struct.stat* %4)
%14 = tail call i32 @free(%struct.stat* %4)
%15 = tail call i32 @_exit(i32 0)
unreachable
}