#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 */
size_t ceil(size_t const);
size_t encoded_dest_size(const size_t src_len, const size_t line_size) {
  size_t dest_size = (size_t)4 * ceil(src_len / 3.0);
  if (line_size) {
    dest_size += dest_size / line_size;
    if (dest_size % line_size)
      ++dest_size;
  }
  return ++dest_size;
}


x86 assembly (clang, -O0):
<encoded_dest_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movaps 0xed9(%rip),%xmm1
movq   -0x8(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xed8(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xed1(%rip),%xmm1
divsd  %xmm1,%xmm0
movaps %xmm0,%xmm1
cvttsd2si %xmm1,%rdi
mov    %rdi,%rcx
sar    $0x3f,%rcx
movsd  0xebe(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
and    %rcx,%rax
or     %rax,%rdi
call   1030 <ceil@plt>
shl    $0x2,%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11cc <encoded_dest_size+0xbc>
mov    -0x18(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x10(%rbp)
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x10(%rbp)
cmp    $0x0,%rdx
je     11c7 <encoded_dest_size+0xb7>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11cc <encoded_dest_size+0xbc>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<encoded_dest_size>:
push   %rbx
movq   %rdi,%xmm0
punpckldq 0xee2(%rip),%xmm0
subpd  0xeea(%rip),%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
addsd  %xmm0,%xmm1
divsd  0xee6(%rip),%xmm1
cvttsd2si %xmm1,%rax
mov    %rsi,%rbx
mov    %rax,%rcx
sar    $0x3f,%rcx
subsd  0xed7(%rip),%xmm1
cvttsd2si %xmm1,%rdi
and    %rcx,%rdi
or     %rax,%rdi
call   1030 <ceil@plt>
mov    %rax,%rcx
shl    $0x2,%rcx
test   %rbx,%rbx
je     11b8 <encoded_dest_size+0xa8>
mov    %rcx,%rax
or     %rbx,%rax
shr    $0x20,%rax
je     1186 <encoded_dest_size+0x76>
mov    %rcx,%rax
xor    %edx,%edx
div    %rbx
mov    %rax,%rsi
jmp    118e <encoded_dest_size+0x7e>
mov    %ecx,%eax
xor    %edx,%edx
div    %ebx
mov    %eax,%esi
add    %rcx,%rsi
mov    %rsi,%rax
or     %rbx,%rax
shr    $0x20,%rax
je     11a7 <encoded_dest_size+0x97>
mov    %rsi,%rax
xor    %edx,%edx
div    %rbx
jmp    11ad <encoded_dest_size+0x9d>
mov    %esi,%eax
xor    %edx,%edx
div    %ebx
cmp    $0x1,%rdx
sbb    $0xffffffffffffffff,%rsi
mov    %rsi,%rcx
add    $0x1,%rcx
mov    %rcx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i64 @encoded_dest_size(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
store i64 %0, i64* %3
store i64 %1, i64* %4
%6 = load i64, i64* %3
%7 = uitofp i64 %6 to double
%8 = fdiv double %7, 3.000000e+00
%9 = fptoui double %8 to i64
%10 = call i64 @ceil(i64 %9)
%11 = mul i64 4, %10
store i64 %11, i64* %5
%12 = load i64, i64* %4
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %28
14: ; preds = %2
%15 = load i64, i64* %5
%16 = load i64, i64* %4
%17 = udiv i64 %15, %16
%18 = load i64, i64* %5
%19 = add i64 %18, %17
store i64 %19, i64* %5
%20 = load i64, i64* %5
%21 = load i64, i64* %4
%22 = urem i64 %20, %21
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %14
%25 = load i64, i64* %5
%26 = add i64 %25, 1
store i64 %26, i64* %5
br label %27
27: ; preds = %24, %14
br label %28
28: ; preds = %27, %2
%29 = load i64, i64* %5
%30 = add i64 %29, 1
store i64 %30, i64* %5
ret i64 %30
}

LLVM IR (-O2):
define i64 @encoded_dest_size(i64 %0, i64 %1) {
%3 = uitofp i64 %0 to double
%4 = fdiv double %3, 3.000000e+00
%5 = fptoui double %4 to i64
%6 = tail call i64 @ceil(i64 %5)
%7 = shl i64 %6, 2
%8 = icmp eq i64 %1, 0
br i1 %8, label %16, label %9
9: ; preds = %2
%10 = udiv i64 %7, %1
%11 = add i64 %10, %7
%12 = urem i64 %11, %1
%13 = icmp ne i64 %12, 0
%14 = zext i1 %13 to i64
%15 = add i64 %11, %14
br label %16
16: ; preds = %9, %2
%17 = phi i64 [ %7, %2 ], [ %15, %9 ]
%18 = add i64 %17, 1
ret i64 %18
}