#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 scalar_t__ off_t;
typedef int /*<<< orphan*/ intmax_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void printpositions(off_t *positions, int c) {
  int i;
  c -= 1;
  if (c) {
    printf("%jd-%jd", (intmax_t)positions[0], (intmax_t)positions[1]);
    for (i = 2; i < c; i += 2)
      printf(",%jd-%jd", (intmax_t)positions[i], (intmax_t)positions[i + 1]);
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<printpositions>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     11b1 <printpositions+0xa1>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %eax,%esi
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %eax,%edx
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x2,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11a3 <printpositions+0x93>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %eax,%esi
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %eax,%edx
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x10(%rbp)
jmp    115a <printpositions+0x4a>
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printpositions>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r15d
add    $0xffffffff,%r15d
je     118e <printpositions+0x6e>
mov    %esi,%r14d
mov    %rdi,%rbx
mov    (%rdi),%esi
mov    0x8(%rdi),%edx
lea    0xebf(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x4,%r14d
jl     117a <printpositions+0x5a>
mov    $0x2,%ebp
lea    0xea5(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    (%rbx,%rbp,8),%esi
mov    0x8(%rbx,%rbp,8),%edx
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x2,%rbp
cmp    %ebp,%r15d
jg     1160 <printpositions+0x40>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"%jd-%jd\00"
@.str.1 = [9 x i8] c",%jd-%jd\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @printpositions(i64* %0, i32 %1) {
%3 = alloca i64*
%4 = alloca i32
%5 = alloca i32
store i64* %0, i64** %3
store i32 %1, i32* %4
%6 = load i32, i32* %4
%7 = sub nsw i32 %6, 1
store i32 %7, i32* %4
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %44
10: ; preds = %2
%11 = load i64*, i64** %3
%12 = getelementptr inbounds i64, i64* %11, i64 0
%13 = load i64, i64* %12
%14 = trunc i64 %13 to i32
%15 = load i64*, i64** %3
%16 = getelementptr inbounds i64, i64* %15, i64 1
%17 = load i64, i64* %16
%18 = trunc i64 %17 to i32
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %14, i32 %18)
store i32 2, i32* %5
br label %20
20: ; preds = %39, %10
%21 = load i32, i32* %5
%22 = load i32, i32* %4
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %42
24: ; preds = %20
%25 = load i64*, i64** %3
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i64, i64* %25, i64 %27
%29 = load i64, i64* %28
%30 = trunc i64 %29 to i32
%31 = load i64*, i64** %3
%32 = load i32, i32* %5
%33 = add nsw i32 %32, 1
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i64, i64* %31, i64 %34
%36 = load i64, i64* %35
%37 = trunc i64 %36 to i32
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %30, i32 %37)
br label %39
39: ; preds = %24
%40 = load i32, i32* %5
%41 = add nsw i32 %40, 2
store i32 %41, i32* %5
br label %20
42: ; preds = %20
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %44
44: ; preds = %42, %2
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"%jd-%jd\00"
@.str.1 = [9 x i8] c",%jd-%jd\00"
define void @printpositions(i64* nocapture %0, i32 %1) {
%3 = add nsw i32 %1, -1
%4 = icmp eq i32 %3, 0
br i1 %4, label %28, label %5
5: ; preds = %2
%6 = load i64, i64* %0
%7 = trunc i64 %6 to i32
%8 = getelementptr inbounds i64, i64* %0, i64 1
%9 = load i64, i64* %8
%10 = trunc i64 %9 to i32
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %10)
%12 = icmp sgt i32 %1, 3
br i1 %12, label %13, label %26
13: ; preds = %5, %13
%14 = phi i64 [ %23, %13 ], [ 2, %5 ]
%15 = getelementptr inbounds i64, i64* %0, i64 %14
%16 = load i64, i64* %15
%17 = trunc i64 %16 to i32
%18 = or i64 %14, 1
%19 = getelementptr inbounds i64, i64* %0, i64 %18
%20 = load i64, i64* %19
%21 = trunc i64 %20 to i32
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %17, i32 %21)
%23 = add nuw i64 %14, 2
%24 = trunc i64 %23 to i32
%25 = icmp sgt i32 %3, %24
br i1 %25, label %13, label %26
26: ; preds = %13, %5
%27 = tail call i32 @putchar(i32 10)
br label %28
28: ; preds = %26, %2
ret void
}