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

/* Variables and functions */
int /*<<< orphan*/ flush_large(struct coder *, int *, int *, int, int *,
                               int const, unsigned char *, unsigned char **);
void buffer_large(struct coder *coder, int *has_large, int *has_large_ints,
                  int *new_large_ints, int *large_index, const int large_nbits,
                  unsigned char *compress_buffer, unsigned char **output_ptr) {
  if (*has_large == 18)
    flush_large(coder, has_large, has_large_ints, *has_large, large_index,
                large_nbits, compress_buffer, output_ptr);
  has_large_ints[(*has_large) * 3] = new_large_ints[0];
  has_large_ints[(*has_large) * 3 + 1] = new_large_ints[1];
  has_large_ints[(*has_large) * 3 + 2] = new_large_ints[2];
  *has_large = (*has_large) + 1;
}


x86 assembly (clang, -O0):
<buffer_large>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
cmpl   $0x12,(%rax)
jne    1175 <buffer_large+0x65>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
mov    -0x28(%rbp),%r8
mov    -0x2c(%rbp),%r9d
mov    0x10(%rbp),%r10
mov    0x18(%rbp),%rax
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1030 <flush_large@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%edx
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
imul   $0x3,(%rcx),%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%rax
mov    0x4(%rax),%edx
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
imul   $0x3,(%rcx),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%edx
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
imul   $0x3,(%rcx),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<buffer_large>:
push   %r15
push   %r14
push   %rbx
mov    %rcx,%r15
mov    %rdx,%r14
mov    %rsi,%rbx
mov    (%rsi),%eax
cmp    $0x12,%eax
jne    1143 <buffer_large+0x33>
mov    %rbx,%rsi
mov    %r14,%rdx
mov    $0x12,%ecx
push   0x28(%rsp)
push   0x28(%rsp)
call   1030 <flush_large@plt>
add    $0x10,%rsp
mov    (%rbx),%eax
mov    (%r15),%ecx
lea    (%rax,%rax,2),%eax
cltq
mov    %ecx,(%r14,%rax,4)
mov    0x4(%r15),%eax
movslq (%rbx),%rcx
lea    (%rcx,%rcx,2),%rcx
mov    %eax,0x4(%r14,%rcx,4)
mov    0x8(%r15),%eax
movslq (%rbx),%rcx
lea    (%rcx,%rcx,2),%rcx
mov    %eax,0x8(%r14,%rcx,4)
addl   $0x1,(%rbx)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.coder = type { i32 }
define void @buffer_large(%struct.coder* %0, i32* %1, i32* %2, i32* %3, i32* %4, i32 %5, i8* %6, i8** %7) {
%9 = alloca %struct.coder*
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i8**
store %struct.coder* %0, %struct.coder** %9
store i32* %1, i32** %10
store i32* %2, i32** %11
store i32* %3, i32** %12
store i32* %4, i32** %13
store i32 %5, i32* %14
store i8* %6, i8** %15
store i8** %7, i8*** %16
%17 = load i32*, i32** %10
%18 = load i32, i32* %17
%19 = icmp eq i32 %18, 18
br i1 %19, label %20, label %31
20: ; preds = %8
%21 = load %struct.coder*, %struct.coder** %9
%22 = load i32*, i32** %10
%23 = load i32*, i32** %11
%24 = load i32*, i32** %10
%25 = load i32, i32* %24
%26 = load i32*, i32** %13
%27 = load i32, i32* %14
%28 = load i8*, i8** %15
%29 = load i8**, i8*** %16
%30 = call i32 @flush_large(%struct.coder* %21, i32* %22, i32* %23, i32 %25, i32* %26, i32 %27, i8* %28, i8** %29)
br label %31
31: ; preds = %20, %8
%32 = load i32*, i32** %12
%33 = getelementptr inbounds i32, i32* %32, i64 0
%34 = load i32, i32* %33
%35 = load i32*, i32** %11
%36 = load i32*, i32** %10
%37 = load i32, i32* %36
%38 = mul nsw i32 %37, 3
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i32, i32* %35, i64 %39
store i32 %34, i32* %40
%41 = load i32*, i32** %12
%42 = getelementptr inbounds i32, i32* %41, i64 1
%43 = load i32, i32* %42
%44 = load i32*, i32** %11
%45 = load i32*, i32** %10
%46 = load i32, i32* %45
%47 = mul nsw i32 %46, 3
%48 = add nsw i32 %47, 1
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i32, i32* %44, i64 %49
store i32 %43, i32* %50
%51 = load i32*, i32** %12
%52 = getelementptr inbounds i32, i32* %51, i64 2
%53 = load i32, i32* %52
%54 = load i32*, i32** %11
%55 = load i32*, i32** %10
%56 = load i32, i32* %55
%57 = mul nsw i32 %56, 3
%58 = add nsw i32 %57, 2
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i32, i32* %54, i64 %59
store i32 %53, i32* %60
%61 = load i32*, i32** %10
%62 = load i32, i32* %61
%63 = add nsw i32 %62, 1
%64 = load i32*, i32** %10
store i32 %63, i32* %64
ret void
}

LLVM IR (-O2):
%struct.coder = type { i32 }
define void @buffer_large(%struct.coder* %0, i32* %1, i32* %2, i32* nocapture %3, i32* %4, i32 %5, i8* %6, i8** %7) {
%9 = load i32, i32* %1
%10 = icmp eq i32 %9, 18
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = tail call i32 @flush_large(%struct.coder* %0, i32* %1, i32* %2, i32 18, i32* %4, i32 %5, i8* %6, i8** %7)
%13 = load i32, i32* %1
br label %14
14: ; preds = %11, %8
%15 = phi i32 [ %13, %11 ], [ %9, %8 ]
%16 = load i32, i32* %3
%17 = mul nsw i32 %15, 3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i32, i32* %2, i64 %18
store i32 %16, i32* %19
%20 = getelementptr inbounds i32, i32* %3, i64 1
%21 = load i32, i32* %20
%22 = load i32, i32* %1
%23 = mul nsw i32 %22, 3
%24 = add nsw i32 %23, 1
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i32, i32* %2, i64 %25
store i32 %21, i32* %26
%27 = getelementptr inbounds i32, i32* %3, i64 2
%28 = load i32, i32* %27
%29 = load i32, i32* %1
%30 = mul nsw i32 %29, 3
%31 = add nsw i32 %30, 2
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %2, i64 %32
store i32 %28, i32* %33
%34 = load i32, i32* %1
%35 = add nsw i32 %34, 1
store i32 %35, i32* %1
ret void
}