#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int,
                           char const *);
size_t get_str_from_stream(char **, size_t, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
size_t get_str_from_path(char **strptr, size_t sz, const char *fpath) {
  FILE *stream;
  if ((stream = fopen(fpath, "r")) == NULL) {
    do {
      fprintf(stderr,
              ""
              "\x1b[33;1m"
              "[%s:%d]\x1b[0m "
              "Unable to read from %s"
              "\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/methusael13/weather-wiz/refs/heads/"
              "master/src/util.c",
              97, fpath);
    } while (0);
    return 0;
  }
  size_t size;
  size = get_str_from_stream(strptr, sz, stream);
  fclose(stream);
  return size;
}


x86 assembly (clang, -O0):
<get_str_from_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xea1(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    11a9 <get_str_from_path+0x69>
jmp    1177 <get_str_from_path+0x37>
mov    0x2e62(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%r8
lea    0xe77(%rip),%rsi
lea    0xe9b(%rip),%rdx
mov    $0x61,%ecx
call   1050 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    11cf <get_str_from_path+0x8f>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1040 <get_str_from_stream@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_str_from_path>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r12
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xea8(%rip),%rsi
mov    %rdx,%rdi
call   1060 <fopen@plt>
test   %rax,%rax
je     1186 <get_str_from_path+0x46>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rax,%rdx
call   1040 <get_str_from_stream@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    %r14,%rax
jmp    11ac <get_str_from_path+0x6c>
mov    0x2e53(%rip),%rax
mov    (%rax),%edi
lea    0xe6c(%rip),%rsi
lea    0xe90(%rip),%rdx
mov    $0x61,%ecx
mov    %r12,%r8
call   1050 <fprintf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [43 x i8] c"\1B[33;1m[%s:%d]\1B[0m Unable to read from %s\0A\00"
@.str.2 = [143 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/methusael13/weather-wiz/refs/heads/master/src/util.c\00"
define i64 @get_str_from_path(i8** %0, i64 %1, i8* %2) {
%4 = alloca i64
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i64
store i8** %0, i8*** %5
store i64 %1, i64* %6
store i8* %2, i8** %7
%10 = load i8*, i8** %7
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %11, i32** %8
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %19
13: ; preds = %3
br label %14
14: ; preds = %13
%15 = load i32, i32* @stderr
%16 = load i8*, i8** %7
%17 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([143 x i8], [143 x i8]* @.str.2, i64 0, i64 0), i32 97, i8* %16)
br label %18
18: ; preds = %14
store i64 0, i64* %4
br label %27
19: ; preds = %3
%20 = load i8**, i8*** %5
%21 = load i64, i64* %6
%22 = load i32*, i32** %8
%23 = call i64 @get_str_from_stream(i8** %20, i64 %21, i32* %22)
store i64 %23, i64* %9
%24 = load i32*, i32** %8
%25 = call i32 @fclose(i32* %24)
%26 = load i64, i64* %9
store i64 %26, i64* %4
br label %27
27: ; preds = %19, %18
%28 = load i64, i64* %4
ret i64 %28
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [43 x i8] c"\1B[33;1m[%s:%d]\1B[0m Unable to read from %s\0A\00"
@.str.2 = [143 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/methusael13/weather-wiz/refs/heads/master/src/util.c\00"
define i64 @get_str_from_path(i8** %0, i64 %1, i8* %2) {
%4 = tail call i32* @fopen(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %9
6: ; preds = %3
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([143 x i8], [143 x i8]* @.str.2, i64 0, i64 0), i32 97, i8* %2)
br label %12
9: ; preds = %3
%10 = tail call i64 @get_str_from_stream(i8** %0, i64 %1, i32* %4)
%11 = tail call i32 @fclose(i32* %4)
br label %12
12: ; preds = %9, %6
%13 = phi i64 [ 0, %6 ], [ %10, %9 ]
ret i64 %13
}