#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 uint8_t;
typedef int /*<<< orphan*/ uint16_t;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ tiff_encode_16(int *, int *, int, int /*<<< orphan*/,
                                  int /*<<< orphan*/);
int /*<<< orphan*/ tiff_encode_32(int *, int *, int, int /*<<< orphan*/,
                                  int /*<<< orphan*/);
int /*<<< orphan*/ tiff_encode_8(int *, int *, int, int /*<<< orphan*/,
                                 int /*<<< orphan*/);
int /*<<< orphan*/ tiff_encode_nibble(int *, int *, int, int /*<<< orphan*/,
                                      int /*<<< orphan*/, int);
extern void pdf_filt_predict_tiff_encode(uint8_t *in, uint8_t *out,
                                         uint8_t colors, uint8_t bpc,
                                         uint16_t columns, uint16_t rows) {
  switch (bpc) {
  case 1:
  case 2:
  case 4:
    tiff_encode_nibble(in, out, colors, columns, rows, bpc);
    break;
  case 8:
    tiff_encode_8(in, out, colors, columns, rows);
    break;
  case 16:
    tiff_encode_16(in, out, colors, columns, rows);
    break;
  case 32:
    tiff_encode_32(in, out, colors, columns, rows);
    break;
  default:
    fprintf(stderr, "%s: unhandled TIFF bpc: %d\n",
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/p6-pdf/libpdf/refs/heads/master/src/pdf/"
            "filt_predict_tiff.c",
            bpc);
  }
}


x86 assembly (clang, -O0):
<pdf_filt_predict_tiff_encode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9d,-0x20(%rbp)
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x1f,%eax
ja     120b <pdf_filt_predict_tiff_encode+0xbb>
mov    -0x28(%rbp),%rax
lea    0xe72(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
mov    -0x18(%rbp),%r9d
call   1030 <tiff_encode_nibble@plt>
jmp    122a <pdf_filt_predict_tiff_encode+0xda>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
call   1070 <tiff_encode_8@plt>
jmp    122a <pdf_filt_predict_tiff_encode+0xda>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
call   1050 <tiff_encode_16@plt>
jmp    122a <pdf_filt_predict_tiff_encode+0xda>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
call   1040 <tiff_encode_32@plt>
jmp    122a <pdf_filt_predict_tiff_encode+0xda>
mov    0x2dce(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%ecx
lea    0xe62(%rip),%rsi
lea    0xe77(%rip),%rdx
call   1060 <fprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pdf_filt_predict_tiff_encode>:
mov    %ecx,%r10d
lea    -0x1(%r10),%ecx
cmp    $0x1f,%ecx
ja     117a <pdf_filt_predict_tiff_encode+0x2a>
lea    0xe9d(%rip),%rax
movslq (%rax,%rcx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
mov    %r8d,%ecx
mov    %r9d,%r8d
mov    %r10d,%r9d
jmp    1030 <tiff_encode_nibble@plt>
mov    0x2e5f(%rip),%rax
mov    (%rax),%edi
lea    0xef6(%rip),%rsi
lea    0xf0b(%rip),%rdx
mov    %r10d,%ecx
jmp    1060 <fprintf@plt>
mov    %r8d,%ecx
mov    %r9d,%r8d
jmp    1070 <tiff_encode_8@plt>
mov    %r8d,%ecx
mov    %r9d,%r8d
jmp    1050 <tiff_encode_16@plt>
mov    %r8d,%ecx
mov    %r9d,%r8d
jmp    1040 <tiff_encode_32@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [28 x i8] c"%s: unhandled TIFF bpc: %d\0A\00"
@.str.1 = [150 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/p6-pdf/libpdf/refs/heads/master/src/pdf/filt_predict_tiff.c\00"
define void @pdf_filt_predict_tiff_encode(i32* %0, i32* %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32* %0, i32** %7
store i32* %1, i32** %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i32 %5, i32* %12
%13 = load i32, i32* %10
switch i32 %13, label %43 [
i32 1, label %14
i32 2, label %14
i32 4, label %14
i32 8, label %22
i32 16, label %29
i32 32, label %36
]
14: ; preds = %6, %6, %6
%15 = load i32*, i32** %7
%16 = load i32*, i32** %8
%17 = load i32, i32* %9
%18 = load i32, i32* %11
%19 = load i32, i32* %12
%20 = load i32, i32* %10
%21 = call i32 @tiff_encode_nibble(i32* %15, i32* %16, i32 %17, i32 %18, i32 %19, i32 %20)
br label %47
22: ; preds = %6
%23 = load i32*, i32** %7
%24 = load i32*, i32** %8
%25 = load i32, i32* %9
%26 = load i32, i32* %11
%27 = load i32, i32* %12
%28 = call i32 @tiff_encode_8(i32* %23, i32* %24, i32 %25, i32 %26, i32 %27)
br label %47
29: ; preds = %6
%30 = load i32*, i32** %7
%31 = load i32*, i32** %8
%32 = load i32, i32* %9
%33 = load i32, i32* %11
%34 = load i32, i32* %12
%35 = call i32 @tiff_encode_16(i32* %30, i32* %31, i32 %32, i32 %33, i32 %34)
br label %47
36: ; preds = %6
%37 = load i32*, i32** %7
%38 = load i32*, i32** %8
%39 = load i32, i32* %9
%40 = load i32, i32* %11
%41 = load i32, i32* %12
%42 = call i32 @tiff_encode_32(i32* %37, i32* %38, i32 %39, i32 %40, i32 %41)
br label %47
43: ; preds = %6
%44 = load i32, i32* @stderr
%45 = load i32, i32* %10
%46 = call i32 @fprintf(i32 %44, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([150 x i8], [150 x i8]* @.str.1, i64 0, i64 0), i32 %45)
br label %47
47: ; preds = %43, %36, %29, %22, %14
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [28 x i8] c"%s: unhandled TIFF bpc: %d\0A\00"
@.str.1 = [150 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/p6-pdf/libpdf/refs/heads/master/src/pdf/filt_predict_tiff.c\00"
define void @pdf_filt_predict_tiff_encode(i32* %0, i32* %1, i32 %2, i32 %3, i32 %4, i32 %5) {
switch i32 %3, label %15 [
i32 1, label %7
i32 2, label %7
i32 4, label %7
i32 8, label %9
i32 16, label %11
i32 32, label %13
]
7: ; preds = %6, %6, %6
%8 = tail call i32 @tiff_encode_nibble(i32* %0, i32* %1, i32 %2, i32 %4, i32 %5, i32 %3)
br label %18
9: ; preds = %6
%10 = tail call i32 @tiff_encode_8(i32* %0, i32* %1, i32 %2, i32 %4, i32 %5)
br label %18
11: ; preds = %6
%12 = tail call i32 @tiff_encode_16(i32* %0, i32* %1, i32 %2, i32 %4, i32 %5)
br label %18
13: ; preds = %6
%14 = tail call i32 @tiff_encode_32(i32* %0, i32* %1, i32 %2, i32 %4, i32 %5)
br label %18
15: ; preds = %6
%16 = load i32, i32* @stderr
%17 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([150 x i8], [150 x i8]* @.str.1, i64 0, i64 0), i32 %3)
br label %18
18: ; preds = %15, %13, %11, %9, %7
ret void
}