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

/* Variables and functions */
int /*<<< orphan*/ LOGGER_log(char *, char *, int, ...);
int O_CREAT;
int /*<<< orphan*/ O_RDONLY;
int O_WRONLY;
int STDIN_FILENO;
int S_IRUSR;
int S_IWUSR;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ free(char *);
char *malloc(size_t);
int open(char *, int, ...);
size_t read(int, char *, size_t);
size_t strerror(int /*<<< orphan*/);
size_t write(int, char *, size_t);
size_t MIME_read_raw(char *src_mpname, char *dest_mpname,
                     size_t rw_buffer_size) {
  size_t readcount, writecount;
  size_t fsize = -1;
  char *rw_buffer;
  int fin;
  int fout;
  rw_buffer = NULL;
  if (*src_mpname == '\0') {
    fin = STDIN_FILENO;
  } else {
    fin = open(src_mpname, O_RDONLY);
    if (fin == -1) {
      LOGGER_log(
          "%s:%d:MIME_read_raw:ERROR: Cannot open '%s' for reading (%s)",
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/inflex/ripMIME/refs/heads/master/mime.c",
          2168, src_mpname, strerror(errno));
      return -1;
    }
  }
  rw_buffer = malloc((rw_buffer_size + 1) * sizeof(char));
  if (!rw_buffer) {
    LOGGER_log(
        "%s:%d:MIME_read:ERROR: could not allocate %d of memory for file read "
        "buffer\n",
        "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
        "2022-01-22/02-19-57/repos/inflex/ripMIME/refs/heads/master/mime.c",
        2176, rw_buffer_size);
    return -1;
  }
  fout = open(dest_mpname, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR);
  if (fout == -1) {
    LOGGER_log(
        "%s:%d:MIME_read_raw:ERROR: Cannot open '%s' for writing. (%s)",
        "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
        "2022-01-22/02-19-57/repos/inflex/ripMIME/refs/heads/master/mime.c",
        2183, dest_mpname, strerror(errno));
    return -1;
  }
  fsize = 0;
  do {
    readcount = read(fin, rw_buffer, rw_buffer_size);
    if (readcount > 0) {
      writecount = write(fout, rw_buffer, readcount);
      if (writecount == -1) {
        LOGGER_log(
            "%s:%d:MIME_read_raw:ERROR: While attempting to write data to '%s' "
            "(%s)",
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/inflex/ripMIME/refs/heads/master/mime.c",
            2195, dest_mpname, strerror(errno));
        return -1;
      }
      if (readcount != writecount) {
        LOGGER_log(
            "%s:%d:MIME_read_raw:ERROR: Attempted to write %d bytes, but only "
            "managed %d to file '%s'",
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/inflex/ripMIME/refs/heads/master/mime.c",
            2201, readcount, writecount, dest_mpname);
      }
      fsize += writecount;
    }
  } while (readcount > 0);
  if ((*src_mpname != '\0') && (readcount >= 0)) {
    close(fin);
  }
  if (readcount == -1) {
    LOGGER_log(
        "%s:%d:MIME_read_raw:ERROR: read() '%s'",
        "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
        "2022-01-22/02-19-57/repos/inflex/ripMIME/refs/heads/master/mime.c",
        2213, strerror(errno));
    return -1;
  }
  close(fout);
  if (rw_buffer != NULL)
    free(rw_buffer);
  return (size_t)(fsize);
}


x86 assembly (clang, -O0):
<MIME_read_raw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movq   $0xffffffffffffffff,-0x38(%rbp)
ff
movq   $0x0,-0x40(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11c5 <MIME_read_raw+0x45>
mov    0x2dfd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
jmp    122f <MIME_read_raw+0xaf>
mov    -0x10(%rbp),%rdi
mov    0x2e10(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1080 <open@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0xffffffff,-0x44(%rbp)
jne    122a <MIME_read_raw+0xaa>
mov    -0x10(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    0x2dd3(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x50(%rbp),%rcx
mov    %rax,%r8
lea    0xdf6(%rip),%rdi
lea    0xe2c(%rip),%rsi
mov    $0x878,%edx
mov    $0x0,%al
call   10a0 <LOGGER_log@plt>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    145e <MIME_read_raw+0x2de>
jmp    122f <MIME_read_raw+0xaf>
mov    -0x20(%rbp),%rdi
add    $0x1,%rdi
shl    $0x0,%rdi
call   1070 <malloc@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    127a <MIME_read_raw+0xfa>
mov    -0x20(%rbp),%rcx
lea    0xe65(%rip),%rdi
lea    0xddc(%rip),%rsi
mov    $0x880,%edx
mov    $0x0,%al
call   10a0 <LOGGER_log@plt>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    145e <MIME_read_raw+0x2de>
mov    -0x18(%rbp),%rdi
mov    0x2d23(%rip),%rax
mov    (%rax),%esi
mov    0x2d6a(%rip),%rax
or     (%rax),%esi
mov    0x2d29(%rip),%rax
mov    (%rax),%edx
mov    0x2d38(%rip),%rax
or     (%rax),%edx
mov    $0x0,%al
call   1080 <open@plt>
mov    %eax,-0x48(%rbp)
cmpl   $0xffffffff,-0x48(%rbp)
jne    12fa <MIME_read_raw+0x17a>
mov    -0x18(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    0x2d03(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x58(%rbp),%rcx
mov    %rax,%r8
lea    0xe32(%rip),%rdi
lea    0xd5c(%rip),%rsi
mov    $0x887,%edx
mov    $0x0,%al
call   10a0 <LOGGER_log@plt>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    145e <MIME_read_raw+0x2de>
movq   $0x0,-0x38(%rbp)
mov    -0x44(%rbp),%edi
mov    -0x40(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1060 <read@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jbe    13c4 <MIME_read_raw+0x244>
mov    -0x48(%rbp),%edi
mov    -0x40(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1040 <write@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0xffffffffffffffff,-0x30(%rbp)
jne    1384 <MIME_read_raw+0x204>
mov    -0x18(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    0x2c79(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x60(%rbp),%rcx
mov    %rax,%r8
lea    0xde6(%rip),%rdi
lea    0xcd2(%rip),%rsi
mov    $0x893,%edx
mov    $0x0,%al
call   10a0 <LOGGER_log@plt>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    145e <MIME_read_raw+0x2de>
mov    -0x28(%rbp),%rax
cmp    -0x30(%rbp),%rax
je     13b8 <MIME_read_raw+0x238>
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0x18(%rbp),%r9
lea    0xdec(%rip),%rdi
lea    0xc91(%rip),%rsi
mov    $0x899,%edx
mov    $0x0,%al
call   10a0 <LOGGER_log@plt>
mov    -0x30(%rbp),%rax
add    -0x38(%rbp),%rax
mov    %rax,-0x38(%rbp)
jmp    13c9 <MIME_read_raw+0x249>
cmpq   $0x0,-0x28(%rbp)
ja     1302 <MIME_read_raw+0x182>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     13f7 <MIME_read_raw+0x277>
cmpq   $0x0,-0x28(%rbp)
jb     13f7 <MIME_read_raw+0x277>
mov    -0x44(%rbp),%edi
call   1050 <close@plt>
cmpq   $0xffffffffffffffff,-0x28(%rbp)
jne    143a <MIME_read_raw+0x2ba>
mov    0x2bbf(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    %rax,%rcx
lea    0xdd0(%rip),%rdi
lea    0xc1c(%rip),%rsi
mov    $0x8a5,%edx
mov    $0x0,%al
call   10a0 <LOGGER_log@plt>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    145e <MIME_read_raw+0x2de>
mov    -0x48(%rbp),%edi
call   1050 <close@plt>
cmpq   $0x0,-0x40(%rbp)
je     1456 <MIME_read_raw+0x2d6>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MIME_read_raw>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%r12
cmpb   $0x0,(%rdi)
je     11e1 <MIME_read_raw+0x61>
mov    0x2e3d(%rip),%rax
mov    (%rax),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1080 <open@plt>
mov    %eax,0x4(%rsp)
cmp    $0xffffffff,%eax
jne    11ee <MIME_read_raw+0x6e>
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xe33(%rip),%rdi
lea    0xe69(%rip),%rsi
mov    $0x878,%edx
mov    %r12,%rcx
jmp    1366 <MIME_read_raw+0x1e6>
mov    0x2dd0(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x4(%rsp)
lea    0x1(%r15),%rdi
call   1070 <malloc@plt>
test   %rax,%rax
je     12d4 <MIME_read_raw+0x154>
mov    %rax,%rbx
mov    0x2d9e(%rip),%rax
mov    0x2de7(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2da4(%rip),%rax
mov    0x2db5(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    %r14,%rdi
xor    %eax,%eax
call   1080 <open@plt>
cmp    $0xffffffff,%eax
je     12f3 <MIME_read_raw+0x173>
mov    %eax,%ebp
mov    0x4(%rsp),%edi
mov    %rbx,%rsi
mov    %r15,%r13
mov    %r15,%rdx
call   1060 <read@plt>
test   %rax,%rax
mov    %r12,0x10(%rsp)
je     1319 <MIME_read_raw+0x199>
mov    %rax,%r15
mov    %r14,0x8(%rsp)
xor    %r14d,%r14d
jmp    128e <MIME_read_raw+0x10e>
nopl   0x0(%rax)
add    %r12,%r14
mov    0x4(%rsp),%edi
mov    %rbx,%rsi
mov    %r13,%rdx
call   1060 <read@plt>
mov    %rax,%r15
test   %rax,%rax
je     131c <MIME_read_raw+0x19c>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1040 <write@plt>
cmp    $0xffffffffffffffff,%rax
je     1340 <MIME_read_raw+0x1c0>
mov    %rax,%r12
cmp    %rax,%r15
je     1270 <MIME_read_raw+0xf0>
lea    0xedd(%rip),%rdi
lea    0xd82(%rip),%rsi
mov    $0x899,%edx
mov    %r15,%rcx
mov    %r12,%r8
mov    0x8(%rsp),%r9
xor    %eax,%eax
call   10a0 <LOGGER_log@plt>
jmp    1270 <MIME_read_raw+0xf0>
lea    0xde4(%rip),%rdi
lea    0xd5b(%rip),%rsi
mov    $0x880,%edx
mov    %r15,%rcx
xor    %eax,%eax
call   10a0 <LOGGER_log@plt>
jmp    1370 <MIME_read_raw+0x1f0>
mov    0x2cce(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xe04(%rip),%rdi
lea    0xd2e(%rip),%rsi
mov    $0x887,%edx
mov    %r14,%rcx
jmp    1366 <MIME_read_raw+0x1e6>
xor    %r14d,%r14d
mov    0x10(%rsp),%rax
cmpb   $0x0,(%rax)
je     132f <MIME_read_raw+0x1af>
mov    0x4(%rsp),%edi
call   1050 <close@plt>
mov    %ebp,%edi
call   1050 <close@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
jmp    1377 <MIME_read_raw+0x1f7>
mov    0x2c81(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xdf5(%rip),%rdi
lea    0xce1(%rip),%rsi
mov    $0x893,%edx
mov    0x8(%rsp),%rcx
mov    %rax,%r8
xor    %eax,%eax
call   10a0 <LOGGER_log@plt>
mov    $0xffffffffffffffff,%r14
mov    %r14,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@STDIN_FILENO = global i32 0
@O_RDONLY = global i32 0
@.str = [61 x i8] c"%s:%d:MIME_read_raw:ERROR: Cannot open '%s' for reading (%s)\00"
@.str.1 = [130 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/inflex/ripMIME/refs/heads/master/mime.c\00"
@errno = global i32 0
@.str.2 = [77 x i8] c"%s:%d:MIME_read:ERROR: could not allocate %d of memory for file read buffer\0A\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@.str.3 = [62 x i8] c"%s:%d:MIME_read_raw:ERROR: Cannot open '%s' for writing. (%s)\00"
@.str.4 = [71 x i8] c"%s:%d:MIME_read_raw:ERROR: While attempting to write data to '%s' (%s)\00"
@.str.5 = [89 x i8] c"%s:%d:MIME_read_raw:ERROR: Attempted to write %d bytes, but only managed %d to file '%s'\00"
@.str.6 = [39 x i8] c"%s:%d:MIME_read_raw:ERROR: read() '%s'\00"
define i64 @MIME_read_raw(i8* %0, i8* %1, i64 %2) {
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i64 %2, i64* %7
store i64 -1, i64* %10
store i8* null, i8** %11
%14 = load i8*, i8** %5
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %3
%19 = load i32, i32* @STDIN_FILENO
store i32 %19, i32* %12
br label %32
20: ; preds = %3
%21 = load i8*, i8** %5
%22 = load i32, i32* @O_RDONLY
%23 = call i32 (i8*, i32, ...) @open(i8* %21, i32 %22)
store i32 %23, i32* %12
%24 = load i32, i32* %12
%25 = icmp eq i32 %24, -1
br i1 %25, label %26, label %31
26: ; preds = %20
%27 = load i8*, i8** %5
%28 = load i32, i32* @errno
%29 = call i64 @strerror(i32 %28)
%30 = call i32 (i8*, i8*, i32, ...) @LOGGER_log(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([130 x i8], [130 x i8]* @.str.1, i64 0, i64 0), i32 2168, i8* %27, i64 %29)
store i64 -1, i64* %4
br label %123
31: ; preds = %20
br label %32
32: ; preds = %31, %18
%33 = load i64, i64* %7
%34 = add i64 %33, 1
%35 = mul i64 %34, 1
%36 = call i8* @malloc(i64 %35)
store i8* %36, i8** %11
%37 = load i8*, i8** %11
%38 = icmp ne i8* %37, null
br i1 %38, label %42, label %39
39: ; preds = %32
%40 = load i64, i64* %7
%41 = call i32 (i8*, i8*, i32, ...) @LOGGER_log(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([130 x i8], [130 x i8]* @.str.1, i64 0, i64 0), i32 2176, i64 %40)
store i64 -1, i64* %4
br label %123
42: ; preds = %32
%43 = load i8*, i8** %6
%44 = load i32, i32* @O_WRONLY
%45 = load i32, i32* @O_CREAT
%46 = or i32 %44, %45
%47 = load i32, i32* @S_IRUSR
%48 = load i32, i32* @S_IWUSR
%49 = or i32 %47, %48
%50 = call i32 (i8*, i32, ...) @open(i8* %43, i32 %46, i32 %49)
store i32 %50, i32* %13
%51 = load i32, i32* %13
%52 = icmp eq i32 %51, -1
br i1 %52, label %53, label %58
53: ; preds = %42
%54 = load i8*, i8** %6
%55 = load i32, i32* @errno
%56 = call i64 @strerror(i32 %55)
%57 = call i32 (i8*, i8*, i32, ...) @LOGGER_log(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([130 x i8], [130 x i8]* @.str.1, i64 0, i64 0), i32 2183, i8* %54, i64 %56)
store i64 -1, i64* %4
br label %123
58: ; preds = %42
store i64 0, i64* %10
br label %59
59: ; preds = %92, %58
%60 = load i32, i32* %12
%61 = load i8*, i8** %11
%62 = load i64, i64* %7
%63 = call i64 @read(i32 %60, i8* %61, i64 %62)
store i64 %63, i64* %8
%64 = load i64, i64* %8
%65 = icmp ugt i64 %64, 0
br i1 %65, label %66, label %91
66: ; preds = %59
%67 = load i32, i32* %13
%68 = load i8*, i8** %11
%69 = load i64, i64* %8
%70 = call i64 @write(i32 %67, i8* %68, i64 %69)
store i64 %70, i64* %9
%71 = load i64, i64* %9
%72 = icmp eq i64 %71, -1
br i1 %72, label %73, label %78
73: ; preds = %66
%74 = load i8*, i8** %6
%75 = load i32, i32* @errno
%76 = call i64 @strerror(i32 %75)
%77 = call i32 (i8*, i8*, i32, ...) @LOGGER_log(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([130 x i8], [130 x i8]* @.str.1, i64 0, i64 0), i32 2195, i8* %74, i64 %76)
store i64 -1, i64* %4
br label %123
78: ; preds = %66
%79 = load i64, i64* %8
%80 = load i64, i64* %9
%81 = icmp ne i64 %79, %80
br i1 %81, label %82, label %87
82: ; preds = %78
%83 = load i64, i64* %8
%84 = load i64, i64* %9
%85 = load i8*, i8** %6
%86 = call i32 (i8*, i8*, i32, ...) @LOGGER_log(i8* getelementptr inbounds ([89 x i8], [89 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([130 x i8], [130 x i8]* @.str.1, i64 0, i64 0), i32 2201, i64 %83, i64 %84, i8* %85)
br label %87
87: ; preds = %82, %78
%88 = load i64, i64* %9
%89 = load i64, i64* %10
%90 = add i64 %89, %88
store i64 %90, i64* %10
br label %91
91: ; preds = %87, %59
br label %92
92: ; preds = %91
%93 = load i64, i64* %8
%94 = icmp ugt i64 %93, 0
br i1 %94, label %59, label %95
95: ; preds = %92
%96 = load i8*, i8** %5
%97 = load i8, i8* %96
%98 = sext i8 %97 to i32
%99 = icmp ne i32 %98, 0
br i1 %99, label %100, label %106
100: ; preds = %95
%101 = load i64, i64* %8
%102 = icmp uge i64 %101, 0
br i1 %102, label %103, label %106
103: ; preds = %100
%104 = load i32, i32* %12
%105 = call i32 @close(i32 %104)
br label %106
106: ; preds = %103, %100, %95
%107 = load i64, i64* %8
%108 = icmp eq i64 %107, -1
br i1 %108, label %109, label %113
109: ; preds = %106
%110 = load i32, i32* @errno
%111 = call i64 @strerror(i32 %110)
%112 = call i32 (i8*, i8*, i32, ...) @LOGGER_log(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([130 x i8], [130 x i8]* @.str.1, i64 0, i64 0), i32 2213, i64 %111)
store i64 -1, i64* %4
br label %123
113: ; preds = %106
%114 = load i32, i32* %13
%115 = call i32 @close(i32 %114)
%116 = load i8*, i8** %11
%117 = icmp ne i8* %116, null
br i1 %117, label %118, label %121
118: ; preds = %113
%119 = load i8*, i8** %11
%120 = call i32 @free(i8* %119)
br label %121
121: ; preds = %118, %113
%122 = load i64, i64* %10
store i64 %122, i64* %4
br label %123
123: ; preds = %121, %109, %73, %53, %39, %26
%124 = load i64, i64* %4
ret i64 %124
}

LLVM IR (-O2):
@STDIN_FILENO = global i32 0
@O_RDONLY = global i32 0
@.str = [61 x i8] c"%s:%d:MIME_read_raw:ERROR: Cannot open '%s' for reading (%s)\00"
@.str.1 = [130 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/inflex/ripMIME/refs/heads/master/mime.c\00"
@errno = global i32 0
@.str.2 = [77 x i8] c"%s:%d:MIME_read:ERROR: could not allocate %d of memory for file read buffer\0A\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@.str.3 = [62 x i8] c"%s:%d:MIME_read_raw:ERROR: Cannot open '%s' for writing. (%s)\00"
@.str.4 = [71 x i8] c"%s:%d:MIME_read_raw:ERROR: While attempting to write data to '%s' (%s)\00"
@.str.5 = [89 x i8] c"%s:%d:MIME_read_raw:ERROR: Attempted to write %d bytes, but only managed %d to file '%s'\00"
define i64 @MIME_read_raw(i8* %0, i8* %1, i64 %2) {
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = load i32, i32* @STDIN_FILENO
br label %16
8: ; preds = %3
%9 = load i32, i32* @O_RDONLY
%10 = tail call i32 (i8*, i32, ...) @open(i8* %0, i32 %9)
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %16
12: ; preds = %8
%13 = load i32, i32* @errno
%14 = tail call i64 @strerror(i32 %13)
%15 = tail call i32 (i8*, i8*, i32, ...) @LOGGER_log(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([130 x i8], [130 x i8]* @.str.1, i64 0, i64 0), i32 2168, i8* %0, i64 %14)
br label %65
16: ; preds = %8, %6
%17 = phi i32 [ %7, %6 ], [ %10, %8 ]
%18 = add i64 %2, 1
%19 = tail call i8* @malloc(i64 %18)
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %23
21: ; preds = %16
%22 = tail call i32 (i8*, i8*, i32, ...) @LOGGER_log(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([130 x i8], [130 x i8]* @.str.1, i64 0, i64 0), i32 2176, i64 %2)
br label %65
23: ; preds = %16
%24 = load i32, i32* @O_WRONLY
%25 = load i32, i32* @O_CREAT
%26 = or i32 %25, %24
%27 = load i32, i32* @S_IRUSR
%28 = load i32, i32* @S_IWUSR
%29 = or i32 %28, %27
%30 = tail call i32 (i8*, i32, ...) @open(i8* %1, i32 %26, i32 %29)
%31 = icmp eq i32 %30, -1
br i1 %31, label %35, label %32
32: ; preds = %23
%33 = tail call i64 @read(i32 %17, i8* %19, i64 %2)
%34 = icmp eq i64 %33, 0
br i1 %34, label %56, label %39
35: ; preds = %23
%36 = load i32, i32* @errno
%37 = tail call i64 @strerror(i32 %36)
%38 = tail call i32 (i8*, i8*, i32, ...) @LOGGER_log(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([130 x i8], [130 x i8]* @.str.1, i64 0, i64 0), i32 2183, i8* %1, i64 %37)
br label %65
39: ; preds = %32, %52
%40 = phi i64 [ %54, %52 ], [ %33, %32 ]
%41 = phi i64 [ %53, %52 ], [ 0, %32 ]
%42 = tail call i64 @write(i32 %30, i8* %19, i64 %40)
%43 = icmp eq i64 %42, -1
br i1 %43, label %44, label %48
44: ; preds = %39
%45 = load i32, i32* @errno
%46 = tail call i64 @strerror(i32 %45)
%47 = tail call i32 (i8*, i8*, i32, ...) @LOGGER_log(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([130 x i8], [130 x i8]* @.str.1, i64 0, i64 0), i32 2195, i8* %1, i64 %46)
br label %65
48: ; preds = %39
%49 = icmp eq i64 %40, %42
br i1 %49, label %52, label %50
50: ; preds = %48
%51 = tail call i32 (i8*, i8*, i32, ...) @LOGGER_log(i8* getelementptr inbounds ([89 x i8], [89 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([130 x i8], [130 x i8]* @.str.1, i64 0, i64 0), i32 2201, i64 %40, i64 %42, i8* %1)
br label %52
52: ; preds = %48, %50
%53 = add i64 %42, %41
%54 = tail call i64 @read(i32 %17, i8* %19, i64 %2)
%55 = icmp eq i64 %54, 0
br i1 %55, label %56, label %39
56: ; preds = %52, %32
%57 = phi i64 [ 0, %32 ], [ %53, %52 ]
%58 = load i8, i8* %0
%59 = icmp eq i8 %58, 0
br i1 %59, label %62, label %60
60: ; preds = %56
%61 = tail call i32 @close(i32 %17)
br label %62
62: ; preds = %56, %60
%63 = tail call i32 @close(i32 %30)
%64 = tail call i32 @free(i8* %19)
br label %65
65: ; preds = %62, %44, %35, %21, %12
%66 = phi i64 [ -1, %35 ], [ -1, %44 ], [ %57, %62 ], [ -1, %21 ], [ -1, %12 ]
ret i64 %66
}