#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 */
int write_string(char **, size_t *, char *);
scalar_t__ write_uint(char **, size_t *, unsigned int);
bool write_range(char **string, size_t *length, unsigned int start,
                 unsigned int end, bool first) {
  return ((!first) ? (write_string(string, length, ",")) : true) &&
         write_uint(string, length, start) &&
         ((end > start) ? (write_string(string, length, "-") &&
                           write_uint(string, length, end))
                        : true);
}


x86 assembly (clang, -O0):
<write_range>:
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)
cmpl   $0x0,-0x1c(%rbp)
jne    116d <write_range+0x4d>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    0xead(%rip),%rdx
call   1030 <write_string@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x1d(%rbp)
jne    1182 <write_range+0x62>
jmp    1217 <write_range+0xf7>
xor    %eax,%eax
mov    $0x1,%cl
test   $0x1,%cl
mov    %al,-0x1d(%rbp)
jne    1182 <write_range+0x62>
jmp    1217 <write_range+0xf7>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1040 <write_uint@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x1d(%rbp)
je     1217 <write_range+0xf7>
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jbe    11fe <write_range+0xde>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    0xe43(%rip),%rdx
call   1030 <write_string@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x1e(%rbp)
je     11ee <write_range+0xce>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%edx
call   1040 <write_uint@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x1e(%rbp)
mov    -0x1e(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x24(%rbp)
jmp    120b <write_range+0xeb>
mov    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    120b <write_range+0xeb>
mov    -0x24(%rbp),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_range>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %edx,%ebx
mov    %rsi,%r15
mov    %rdi,%rbp
test   %r8d,%r8d
jne    114d <write_range+0x2d>
lea    0xec2(%rip),%rdx
mov    %rbp,%rdi
mov    %r15,%rsi
call   1030 <write_string@plt>
test   %eax,%eax
je     11a6 <write_range+0x86>
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
call   1040 <write_uint@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
je     11a8 <write_range+0x88>
mov    $0x1,%eax
cmp    %ebx,%r14d
jbe    11a8 <write_range+0x88>
lea    0xe8d(%rip),%rdx
mov    %rbp,%rdi
mov    %r15,%rsi
call   1030 <write_string@plt>
mov    %eax,%ecx
mov    $0x0,%eax
test   %ecx,%ecx
je     11a8 <write_range+0x88>
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %r14d,%edx
call   1040 <write_uint@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
setne  %al
jmp    11a8 <write_range+0x88>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c",\00"
@.str.1 = [2 x i8] c"-\00"
define i32 @write_range(i8** %0, i64* %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i8**
%7 = alloca i64*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i8** %0, i8*** %6
store i64* %1, i64** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%11 = load i32, i32* %10
%12 = icmp ne i32 %11, 0
br i1 %12, label %18, label %13
13: ; preds = %5
%14 = load i8**, i8*** %6
%15 = load i64*, i64** %7
%16 = call i32 @write_string(i8** %14, i64* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%17 = icmp ne i32 %16, 0
br i1 %17, label %19, label %47
18: ; preds = %5
br i1 true, label %19, label %47
19: ; preds = %18, %13
%20 = load i8**, i8*** %6
%21 = load i64*, i64** %7
%22 = load i32, i32* %8
%23 = call i64 @write_uint(i8** %20, i64* %21, i32 %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %47
25: ; preds = %19
%26 = load i32, i32* %9
%27 = load i32, i32* %8
%28 = icmp ugt i32 %26, %27
br i1 %28, label %29, label %43
29: ; preds = %25
%30 = load i8**, i8*** %6
%31 = load i64*, i64** %7
%32 = call i32 @write_string(i8** %30, i64* %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %40
34: ; preds = %29
%35 = load i8**, i8*** %6
%36 = load i64*, i64** %7
%37 = load i32, i32* %9
%38 = call i64 @write_uint(i8** %35, i64* %36, i32 %37)
%39 = icmp ne i64 %38, 0
br label %40
40: ; preds = %34, %29
%41 = phi i1 [ false, %29 ], [ %39, %34 ]
%42 = zext i1 %41 to i32
br label %44
43: ; preds = %25
br label %44
44: ; preds = %43, %40
%45 = phi i32 [ %42, %40 ], [ 1, %43 ]
%46 = icmp ne i32 %45, 0
br label %47
47: ; preds = %44, %19, %18, %13
%48 = phi i1 [ false, %19 ], [ false, %18 ], [ false, %13 ], [ %46, %44 ]
%49 = zext i1 %48 to i32
ret i32 %49
}

LLVM IR (-O2):
@.str = [2 x i8] c",\00"
@.str.1 = [2 x i8] c"-\00"
define i32 @write_range(i8** %0, i64* %1, i32 %2, i32 %3, i32 %4) {
%6 = icmp eq i32 %4, 0
br i1 %6, label %7, label %10
7: ; preds = %5
%8 = tail call i32 @write_string(i8** %0, i64* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32 %8, 0
br i1 %9, label %22, label %10
10: ; preds = %5, %7
%11 = tail call i64 @write_uint(i8** %0, i64* %1, i32 %2)
%12 = icmp eq i64 %11, 0
br i1 %12, label %22, label %13
13: ; preds = %10
%14 = icmp ugt i32 %3, %2
br i1 %14, label %15, label %22
15: ; preds = %13
%16 = tail call i32 @write_string(i8** %0, i64* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i32 %16, 0
br i1 %17, label %22, label %18
18: ; preds = %15
%19 = tail call i64 @write_uint(i8** %0, i64* %1, i32 %3)
%20 = icmp ne i64 %19, 0
%21 = zext i1 %20 to i32
br label %22
22: ; preds = %13, %18, %15, %10, %7
%23 = phi i32 [ 0, %10 ], [ 0, %7 ], [ 1, %13 ], [ 0, %15 ], [ %21, %18 ]
ret i32 %23
}