#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 uint64_t;
typedef scalar_t__ uint32_t;

/* Variables and functions */
void *array_container_create_range(scalar_t__, scalar_t__);
int /*<<< orphan*/ assert(int);
void *run_container_create_range(scalar_t__, scalar_t__);
void *container_range_of_ones(uint32_t range_start, uint32_t range_end,
                              uint8_t *result_type) {
  assert(range_end >= range_start);
  uint64_t cardinality = range_end - range_start + 1;
  if (cardinality <= 2) {
    *result_type = 2;
    return array_container_create_range(range_start, range_end);
  } else {
    *result_type = 3;
    return run_container_create_range(range_start, range_end);
  }
}


x86 assembly (clang, -O0):
<container_range_of_ones>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
setge  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x18(%rbp),%rax
sub    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %eax,-0x24(%rbp)
cmpl   $0x2,-0x24(%rbp)
jg     1192 <container_range_of_ones+0x62>
mov    -0x20(%rbp),%rax
movl   $0x2,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <array_container_create_range@plt>
mov    %rax,-0x8(%rbp)
jmp    11ad <container_range_of_ones+0x7d>
mov    -0x20(%rbp),%rax
movl   $0x3,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <run_container_create_range@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<container_range_of_ones>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %edi,%edi
cmp    %rbx,%rsi
setge  %dil
call   1040 <assert@plt>
mov    %r14d,%eax
sub    %ebx,%eax
add    $0x1,%eax
cmp    $0x2,%eax
jg     1170 <container_range_of_ones+0x40>
movl   $0x2,(%r15)
mov    %rbx,%rdi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <array_container_create_range@plt>
movl   $0x3,(%r15)
mov    %rbx,%rdi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <run_container_create_range@plt>

LLVM IR (-O0):
define i8* @container_range_of_ones(i64 %0, i64 %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
%7 = alloca i32*
%8 = alloca i32
store i64 %0, i64* %5
store i64 %1, i64* %6
store i32* %2, i32** %7
%9 = load i64, i64* %6
%10 = load i64, i64* %5
%11 = icmp sge i64 %9, %10
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = load i64, i64* %6
%15 = load i64, i64* %5
%16 = sub nsw i64 %14, %15
%17 = add nsw i64 %16, 1
%18 = trunc i64 %17 to i32
store i32 %18, i32* %8
%19 = load i32, i32* %8
%20 = icmp sle i32 %19, 2
br i1 %20, label %21, label %26
21: ; preds = %3
%22 = load i32*, i32** %7
store i32 2, i32* %22
%23 = load i64, i64* %5
%24 = load i64, i64* %6
%25 = call i8* @array_container_create_range(i64 %23, i64 %24)
store i8* %25, i8** %4
br label %31
26: ; preds = %3
%27 = load i32*, i32** %7
store i32 3, i32* %27
%28 = load i64, i64* %5
%29 = load i64, i64* %6
%30 = call i8* @run_container_create_range(i64 %28, i64 %29)
store i8* %30, i8** %4
br label %31
31: ; preds = %26, %21
%32 = load i8*, i8** %4
ret i8* %32
}

LLVM IR (-O2):
define i8* @container_range_of_ones(i64 %0, i64 %1, i32* nocapture writeonly %2) {
%4 = icmp sge i64 %1, %0
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = sub nsw i64 %1, %0
%8 = trunc i64 %7 to i32
%9 = add i32 %8, 1
%10 = icmp slt i32 %9, 3
br i1 %10, label %11, label %13
11: ; preds = %3
store i32 2, i32* %2
%12 = tail call i8* @array_container_create_range(i64 %0, i64 %1)
br label %15
13: ; preds = %3
store i32 3, i32* %2
%14 = tail call i8* @run_container_create_range(i64 %0, i64 %1)
br label %15
15: ; preds = %13, %11
%16 = phi i8* [ %12, %11 ], [ %14, %13 ]
ret i8* %16
}