#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 scalar_t__ ssize_t;

/* Variables and functions */
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, char *);
scalar_t__ splice(int, int /*<<< orphan*/ *, int, int /*<<< orphan*/ *,
                  unsigned int, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int consume(int in, int out, unsigned int len) {
  ssize_t written = 0;
  while (len) {
    written = splice(in, NULL, out, NULL, len, 0);
    if (written <= 0) {
      fprintf(stderr, "%s|%d\t%s\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/florianl/sequitur/refs/heads/master/"
              "sequitur.c",
              51, strerror(errno));
      return -1;
    }
    len -= written;
  }
  return 0;
}


x86 assembly (clang, -O0):
<consume>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     11d1 <consume+0xa1>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%ecx
xor    %r9d,%r9d
mov    %rcx,%rsi
call   1030 <splice@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jg     11bf <consume+0x8f>
mov    0x2e5e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2e4a(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    -0x1c(%rbp),%edi
mov    %rax,%r8
lea    0xe5e(%rip),%rsi
lea    0xe61(%rip),%rdx
mov    $0x33,%ecx
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d8 <consume+0xa8>
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%eax
sub    %rcx,%rax
mov    %eax,-0x10(%rbp)
jmp    1149 <consume+0x19>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<consume>:
push   %rbp
push   %r14
push   %rbx
test   %edx,%edx
je     115d <consume+0x2d>
mov    %edx,%ebx
mov    %esi,%r14d
mov    %edi,%ebp
nop
mov    %ebp,%edi
xor    %esi,%esi
mov    %r14d,%edx
xor    %ecx,%ecx
mov    %ebx,%r8d
xor    %r9d,%r9d
call   1030 <splice@plt>
test   %rax,%rax
jle    1161 <consume+0x31>
sub    %eax,%ebx
jne    1140 <consume+0x10>
xor    %eax,%eax
jmp    119a <consume+0x6a>
mov    0x2e78(%rip),%rax
mov    (%rax),%ebx
mov    0x2e67(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
lea    0xe81(%rip),%rsi
lea    0xe84(%rip),%rdx
mov    %ebx,%edi
mov    $0x33,%ecx
mov    %rax,%r8
call   1040 <fprintf@plt>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [10 x i8] c"%s|%d\09%s\0A\00"
@.str.1 = [137 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/florianl/sequitur/refs/heads/master/sequitur.c\00"
@errno = global i32 0
define i32 @consume(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i64
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i64 0, i64* %8
br label %9
9: ; preds = %24, %3
%10 = load i32, i32* %7
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %30
12: ; preds = %9
%13 = load i32, i32* %5
%14 = load i32, i32* %6
%15 = load i32, i32* %7
%16 = call i64 @splice(i32 %13, i32* null, i32 %14, i32* null, i32 %15, i32 0)
store i64 %16, i64* %8
%17 = load i64, i64* %8
%18 = icmp sle i64 %17, 0
br i1 %18, label %19, label %24
19: ; preds = %12
%20 = load i32, i32* @stderr
%21 = load i32, i32* @errno
%22 = call i8* @strerror(i32 %21)
%23 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str.1, i64 0, i64 0), i32 51, i8* %22)
store i32 -1, i32* %4
br label %31
24: ; preds = %12
%25 = load i64, i64* %8
%26 = load i32, i32* %7
%27 = zext i32 %26 to i64
%28 = sub nsw i64 %27, %25
%29 = trunc i64 %28 to i32
store i32 %29, i32* %7
br label %9
30: ; preds = %9
store i32 0, i32* %4
br label %31
31: ; preds = %30, %19
%32 = load i32, i32* %4
ret i32 %32
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [10 x i8] c"%s|%d\09%s\0A\00"
@.str.1 = [137 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/florianl/sequitur/refs/heads/master/sequitur.c\00"
@errno = global i32 0
define i32 @consume(i32 %0, i32 %1, i32 %2) {
%4 = icmp eq i32 %2, 0
br i1 %4, label %18, label %7
5: ; preds = %7
%6 = icmp eq i32 %12, 0
br i1 %6, label %18, label %7
7: ; preds = %3, %5
%8 = phi i32 [ %12, %5 ], [ %2, %3 ]
%9 = tail call i64 @splice(i32 %0, i32* null, i32 %1, i32* null, i32 %8, i32 0)
%10 = icmp slt i64 %9, 1
%11 = trunc i64 %9 to i32
%12 = sub i32 %8, %11
br i1 %10, label %13, label %5
13: ; preds = %7
%14 = load i32, i32* @stderr
%15 = load i32, i32* @errno
%16 = tail call i8* @strerror(i32 %15)
%17 = tail call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str.1, i64 0, i64 0), i32 51, i8* %16)
br label %18
18: ; preds = %5, %3, %13
%19 = phi i32 [ -1, %13 ], [ 0, %3 ], [ 0, %5 ]
ret i32 %19
}