#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 /*<<< orphan*/ int32_t;

/* Variables and functions */
int sscanf(char const *, char *, int /*<<< orphan*/ *, ...);
int ion_parse_range(const char *str, int32_t *start, int32_t *end) {
  if (2 == sscanf(str, "%d-%d", start, end)) {
    return 1;
  } else if (1 == sscanf(str, "%d", start)) {
    (*end) = (*start);
    return 1;
  }
  return -1;
}


x86 assembly (clang, -O0):
<ion_parse_range>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xec9(%rip),%rsi
mov    $0x0,%al
call   1030 <sscanf@plt>
mov    %eax,%ecx
mov    $0x2,%eax
cmp    %ecx,%eax
jne    1159 <ion_parse_range+0x49>
movl   $0x1,-0x4(%rbp)
jmp    11a2 <ion_parse_range+0x92>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe9b(%rip),%rsi
mov    $0x0,%al
call   1030 <sscanf@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
jne    1196 <ion_parse_range+0x86>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    11a2 <ion_parse_range+0x92>
jmp    119b <ion_parse_range+0x8b>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ion_parse_range>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xedb(%rip),%rsi
mov    %r15,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1030 <sscanf@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    $0x2,%ecx
je     1169 <ion_parse_range+0x59>
lea    0xebe(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   1030 <sscanf@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    $0x1,%ecx
jne    1169 <ion_parse_range+0x59>
mov    (%r15),%eax
mov    %eax,(%r14)
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%d-%d\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @ion_parse_range(i8* %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32*
store i8* %0, i8** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
%8 = load i8*, i8** %5
%9 = load i32*, i32** %6
%10 = load i32*, i32** %7
%11 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %9, i32* %10)
%12 = icmp eq i32 2, %11
br i1 %12, label %13, label %14
13: ; preds = %3
store i32 1, i32* %4
br label %25
14: ; preds = %3
%15 = load i8*, i8** %5
%16 = load i32*, i32** %6
%17 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %16)
%18 = icmp eq i32 1, %17
br i1 %18, label %19, label %23
19: ; preds = %14
%20 = load i32*, i32** %6
%21 = load i32, i32* %20
%22 = load i32*, i32** %7
store i32 %21, i32* %22
store i32 1, i32* %4
br label %25
23: ; preds = %14
br label %24
24: ; preds = %23
store i32 -1, i32* %4
br label %25
25: ; preds = %24, %19, %13
%26 = load i32, i32* %4
ret i32 %26
}

LLVM IR (-O2):
@.str = [6 x i8] c"%d-%d\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @ion_parse_range(i8* nocapture %0, i32* %1, i32* %2) {
%4 = tail call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%5 = icmp eq i32 %4, 2
br i1 %5, label %11, label %6
6: ; preds = %3
%7 = tail call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = load i32, i32* %1
store i32 %10, i32* %2
br label %11
11: ; preds = %6, %3, %9
%12 = phi i32 [ 1, %9 ], [ 1, %3 ], [ -1, %6 ]
ret i32 %12
}