#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 */
long atol(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ memcpy(long *, long *, int);
char *strchr(char *, char);
int /*<<< orphan*/ strcspn(char *, char *);
int _cfg_read_pair(char **buf, long **val) {
  char *ptr, *col;
  long ret[2];
  ptr = *buf;
  *buf += strcspn(*buf, " \t\r\n");
  *((*buf)++) = 0;
  col = strchr(ptr, ':');
  if (col) {
    *(col++) = 0;
    ret[1] = atol(col);
  } else {
    ret[1] = 1;
  }
  ret[0] = atol(ptr);
  if (ret[0] || ret[1]) {
    *val = (long *)malloc(sizeof(long) * 2);
    memcpy(*val, ret, sizeof(long) * 2);
  } else {
    *val = 0;
  }
  return 0;
}


x86 assembly (clang, -O0):
<_cfg_read_pair>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
lea    0xe87(%rip),%rsi
call   1040 <strcspn@plt>
mov    %eax,%edx
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
movslq %edx,%rdx
add    %rdx,%rcx
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rcx
mov    (%rcx),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,(%rcx)
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rdi
mov    $0x3a,%esi
call   1030 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11e5 <_cfg_read_pair+0x95>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rdi
call   1070 <atol@plt>
mov    %rax,-0x28(%rbp)
jmp    11ed <_cfg_read_pair+0x9d>
movq   $0x1,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <atol@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1210 <_cfg_read_pair+0xc0>
cmpq   $0x0,-0x28(%rbp)
je     123e <_cfg_read_pair+0xee>
mov    $0x10,%edi
call   1060 <malloc@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    -0x30(%rbp),%rsi
mov    $0x10,%edx
call   1050 <memcpy@plt>
jmp    1249 <_cfg_read_pair+0xf9>
mov    -0x10(%rbp),%rax
movq   $0x0,(%rax)
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_cfg_read_pair>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
mov    (%rdi),%rbx
lea    0xe97(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcspn@plt>
cltq
lea    (%rbx,%rax,1),%rcx
add    $0x1,%rcx
mov    %rcx,(%r15)
movb   $0x0,(%rbx,%rax,1)
mov    %rbx,%rdi
mov    $0x3a,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     11a8 <_cfg_read_pair+0x58>
mov    %rax,%rdi
add    $0x1,%rdi
movb   $0x0,(%rax)
call   1070 <atol@plt>
mov    %rax,%r15
jmp    11ae <_cfg_read_pair+0x5e>
mov    $0x1,%r15d
mov    %r15,0x8(%rsp)
mov    %rbx,%rdi
call   1070 <atol@plt>
mov    %rax,(%rsp)
or     %r15,%rax
je     11e3 <_cfg_read_pair+0x93>
mov    $0x10,%edi
call   1060 <malloc@plt>
mov    %rax,(%r14)
mov    %rsp,%rsi
mov    %rax,%rdi
mov    $0x10,%edx
call   1050 <memcpy@plt>
jmp    11ea <_cfg_read_pair+0x9a>
movq   $0x0,(%r14)
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c" \09\0D\0A\00"
define i32 @_cfg_read_pair(i8** %0, i64** %1) {
%3 = alloca i8**
%4 = alloca i64**
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca [2 x i64]
store i8** %0, i8*** %3
store i64** %1, i64*** %4
%8 = load i8**, i8*** %3
%9 = load i8*, i8** %8
store i8* %9, i8** %5
%10 = load i8**, i8*** %3
%11 = load i8*, i8** %10
%12 = call i32 @strcspn(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%13 = load i8**, i8*** %3
%14 = load i8*, i8** %13
%15 = sext i32 %12 to i64
%16 = getelementptr inbounds i8, i8* %14, i64 %15
store i8* %16, i8** %13
%17 = load i8**, i8*** %3
%18 = load i8*, i8** %17
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %17
store i8 0, i8* %18
%20 = load i8*, i8** %5
%21 = call i8* @strchr(i8* %20, i8 signext 58)
store i8* %21, i8** %6
%22 = load i8*, i8** %6
%23 = icmp ne i8* %22, null
br i1 %23, label %24, label %30
24: ; preds = %2
%25 = load i8*, i8** %6
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %6
store i8 0, i8* %25
%27 = load i8*, i8** %6
%28 = call i64 @atol(i8* %27)
%29 = getelementptr inbounds [2 x i64], [2 x i64]* %7, i64 0, i64 1
store i64 %28, i64* %29
br label %32
30: ; preds = %2
%31 = getelementptr inbounds [2 x i64], [2 x i64]* %7, i64 0, i64 1
store i64 1, i64* %31
br label %32
32: ; preds = %30, %24
%33 = load i8*, i8** %5
%34 = call i64 @atol(i8* %33)
%35 = getelementptr inbounds [2 x i64], [2 x i64]* %7, i64 0, i64 0
store i64 %34, i64* %35
%36 = getelementptr inbounds [2 x i64], [2 x i64]* %7, i64 0, i64 0
%37 = load i64, i64* %36
%38 = icmp ne i64 %37, 0
br i1 %38, label %43, label %39
39: ; preds = %32
%40 = getelementptr inbounds [2 x i64], [2 x i64]* %7, i64 0, i64 1
%41 = load i64, i64* %40
%42 = icmp ne i64 %41, 0
br i1 %42, label %43, label %51
43: ; preds = %39, %32
%44 = call i64 @malloc(i32 16)
%45 = inttoptr i64 %44 to i64*
%46 = load i64**, i64*** %4
store i64* %45, i64** %46
%47 = load i64**, i64*** %4
%48 = load i64*, i64** %47
%49 = getelementptr inbounds [2 x i64], [2 x i64]* %7, i64 0, i64 0
%50 = call i32 @memcpy(i64* %48, i64* %49, i32 16)
br label %53
51: ; preds = %39
%52 = load i64**, i64*** %4
store i64* null, i64** %52
br label %53
53: ; preds = %51, %43
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c" \09\0D\0A\00"
define i32 @_cfg_read_pair(i8** nocapture %0, i64** nocapture writeonly %1) {
%3 = alloca [2 x i64]
%4 = bitcast [2 x i64]* %3 to i8*
%5 = load i8*, i8** %0
%6 = tail call i32 @strcspn(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i8, i8* %5, i64 %7
%9 = getelementptr inbounds i8, i8* %8, i64 1
store i8* %9, i8** %0
store i8 0, i8* %8
%10 = tail call i8* @strchr(i8* dereferenceable(1) %5, i8 signext 58)
%11 = icmp eq i8* %10, null
br i1 %11, label %15, label %12
12: ; preds = %2
%13 = getelementptr inbounds i8, i8* %10, i64 1
store i8 0, i8* %10
%14 = tail call i64 @atol(i8* %13)
br label %15
15: ; preds = %2, %12
%16 = phi i64 [ %14, %12 ], [ 1, %2 ]
%17 = getelementptr inbounds [2 x i64], [2 x i64]* %3, i64 0, i64 1
store i64 %16, i64* %17
%18 = tail call i64 @atol(i8* %5)
%19 = getelementptr inbounds [2 x i64], [2 x i64]* %3, i64 0, i64 0
store i64 %18, i64* %19
%20 = icmp ne i64 %18, 0
%21 = icmp ne i64 %16, 0
%22 = select i1 %20, i1 true, i1 %21
br i1 %22, label %23, label %27
23: ; preds = %15
%24 = tail call i64 @malloc(i32 16)
%25 = inttoptr i64 %24 to i64*
store i64* %25, i64** %1
%26 = call i32 @memcpy(i64* %25, i64* %19, i32 16)
br label %28
27: ; preds = %15
store i64* null, i64** %1
br label %28
28: ; preds = %27, %23
ret i32 0
}