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

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int STDIN_FILENO;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ error_func(char *, int, char *);
int /*<<< orphan*/ file_read_fdes(struct file_data *, int);
int open(char const *, int /*<<< orphan*/);
int /*<<< orphan*/ strcmp(char const *, char *);
void file_read(struct file_data *fp, const char *path) {
  int fd;
  if (!strcmp(path, "-")) {
    file_read_fdes(fp, STDIN_FILENO);
  } else {
    fd = open(path, O_RDONLY);
    if (fd < 0)
      error_func("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                 "outputs/2022-01-22/02-19-57/repos/depp/libfresample/refs/"
                 "heads/master/src/file.c",
                 96, "open failed");
    file_read_fdes(fp, fd);
    close(fd);
  }
}


x86 assembly (clang, -O0):
<file_read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe95(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    1190 <file_read+0x40>
mov    -0x8(%rbp),%rdi
mov    0x2e54(%rip),%rax
mov    (%rax),%esi
call   1030 <file_read_fdes@plt>
jmp    11db <file_read+0x8b>
mov    -0x10(%rbp),%rdi
mov    0x2e4d(%rip),%rax
mov    (%rax),%esi
call   1070 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    11c7 <file_read+0x77>
lea    0xe4c(%rip),%rdi
mov    $0x60,%esi
lea    0xec9(%rip),%rdx
call   1040 <error_func@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <file_read_fdes@plt>
mov    -0x14(%rbp),%edi
call   1050 <close@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<file_read>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbp
mov    %rdi,%rbx
lea    0xea0(%rip),%rsi
mov    %rbp,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
je     11b2 <file_read+0x62>
mov    0x2e75(%rip),%rax
mov    (%rax),%esi
mov    %rbp,%rdi
call   1070 <open@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    119b <file_read+0x4b>
lea    0xe78(%rip),%rdi
lea    0xefa(%rip),%rdx
mov    $0x60,%esi
call   1040 <error_func@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <file_read_fdes@plt>
mov    %ebp,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <close@plt>
mov    0x2e1f(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <file_read_fdes@plt>

LLVM IR (-O0):
%struct.file_data = type { i32 }
@.str = [2 x i8] c"-\00"
@STDIN_FILENO = global i32 0
@O_RDONLY = global i32 0
@.str.1 = [137 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/depp/libfresample/refs/heads/master/src/file.c\00"
@.str.2 = [12 x i8] c"open failed\00"
define void @file_read(%struct.file_data* %0, i8* %1) {
%3 = alloca %struct.file_data*
%4 = alloca i8*
%5 = alloca i32
store %struct.file_data* %0, %struct.file_data** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %4
%7 = call i32 @strcmp(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp ne i32 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %2
%10 = load %struct.file_data*, %struct.file_data** %3
%11 = load i32, i32* @STDIN_FILENO
%12 = call i32 @file_read_fdes(%struct.file_data* %10, i32 %11)
br label %27
13: ; preds = %2
%14 = load i8*, i8** %4
%15 = load i32, i32* @O_RDONLY
%16 = call i32 @open(i8* %14, i32 %15)
store i32 %16, i32* %5
%17 = load i32, i32* %5
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %13
%20 = call i32 @error_func(i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str.1, i64 0, i64 0), i32 96, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %21
21: ; preds = %19, %13
%22 = load %struct.file_data*, %struct.file_data** %3
%23 = load i32, i32* %5
%24 = call i32 @file_read_fdes(%struct.file_data* %22, i32 %23)
%25 = load i32, i32* %5
%26 = call i32 @close(i32 %25)
br label %27
27: ; preds = %21, %9
ret void
}

LLVM IR (-O2):
%struct.file_data = type { i32 }
@.str = [2 x i8] c"-\00"
@STDIN_FILENO = global i32 0
@O_RDONLY = global i32 0
@.str.1 = [137 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/depp/libfresample/refs/heads/master/src/file.c\00"
@.str.2 = [12 x i8] c"open failed\00"
define void @file_read(%struct.file_data* %0, i8* nocapture %1) {
%3 = tail call i32 @strcmp(i8* dereferenceable(1) %1, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = load i32, i32* @STDIN_FILENO
%7 = tail call i32 @file_read_fdes(%struct.file_data* %0, i32 %6)
br label %17
8: ; preds = %2
%9 = load i32, i32* @O_RDONLY
%10 = tail call i32 @open(i8* %1, i32 %9)
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = tail call i32 @error_func(i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str.1, i64 0, i64 0), i32 96, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %14
14: ; preds = %12, %8
%15 = tail call i32 @file_read_fdes(%struct.file_data* %0, i32 %10)
%16 = tail call i32 @close(i32 %10)
br label %17
17: ; preds = %14, %5
ret void
}