#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 /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ strcpy(char *, char const *);
int strlen(char const *);
char *strtok(char *, char *);
bool split_range(const char *r, char **ip_from, char **ip_to) {
  char *range = malloc((strlen(r) + 1) * sizeof(char));
  char *r_ptr = range;
  bool status = false;
  strcpy(r_ptr, r);
  r_ptr = strtok(range, "-");
  if (r_ptr != NULL) {
    strcpy(*ip_from, r_ptr);
    r_ptr = strtok(NULL, "-");
    if (r_ptr != NULL) {
      strcpy(*ip_to, r_ptr);
      status = true;
    }
  }
  free(range);
  return status;
}


x86 assembly (clang, -O0):
<split_range>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x20(%rbp),%rdi
lea    0xe58(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1207 <split_range+0xb7>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <strcpy@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe29(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1202 <split_range+0xb2>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <strcpy@plt>
movl   $0x1,-0x2c(%rbp)
jmp    1207 <split_range+0xb7>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<split_range>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
call   1050 <strlen@plt>
lea    0x1(%rax),%edi
call   1060 <malloc@plt>
mov    %rax,%r12
mov    %rax,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
lea    0xe7d(%rip),%rsi
mov    %r12,%rdi
call   1070 <strtok@plt>
test   %rax,%rax
je     11c2 <split_range+0x72>
mov    (%r15),%rdi
mov    %rax,%rsi
call   1040 <strcpy@plt>
lea    0xe5e(%rip),%rsi
xor    %ebx,%ebx
xor    %edi,%edi
call   1070 <strtok@plt>
test   %rax,%rax
je     11c4 <split_range+0x74>
mov    (%r14),%rdi
mov    %rax,%rsi
call   1040 <strcpy@plt>
mov    $0x1,%ebx
jmp    11c4 <split_range+0x74>
xor    %ebx,%ebx
mov    %r12,%rdi
call   1030 <free@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c"-\00"
define i32 @split_range(i8* %0, i8** nocapture %1, i8** nocapture %2) {
%4 = tail call i32 @strlen(i8* %0)
%5 = add nsw i32 %4, 1
%6 = tail call i8* @malloc(i32 %5)
%7 = tail call i32 @strcpy(i8* %6, i8* %0)
%8 = tail call i8* @strtok(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i8* %8, null
br i1 %9, label %18, label %10
10: ; preds = %3
%11 = load i8*, i8** %1
%12 = tail call i32 @strcpy(i8* %11, i8* %8)
%13 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i8* %13, null
br i1 %14, label %18, label %15
15: ; preds = %10
%16 = load i8*, i8** %2
%17 = tail call i32 @strcpy(i8* %16, i8* %13)
br label %18
18: ; preds = %10, %15, %3
%19 = phi i32 [ 1, %15 ], [ 0, %10 ], [ 0, %3 ]
%20 = tail call i32 @free(i8* %6)
ret i32 %19
}