#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*/ snprintf(char *, int, char *, char const *);
int sscanf(char const *, char *, int *, int *);
char *strchr(char const *, char);
int read_make(const char *line, char *buf, int buflen, int *l, int *c) {
  const char *start = strchr(line, ':');
  if (start && sscanf(start, ":%d:%d:", l, c) == 2) {
    snprintf(buf,
             ((start - line + 1) > (buflen) ? (buflen) : (start - line + 1)),
             "%s", line);
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<read_make>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x3a,%esi
call   1030 <strchr@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     11f3 <read_make+0xc3>
mov    -0x38(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
lea    0xe85(%rip),%rsi
call   1050 <sscanf@plt>
cmp    $0x2,%eax
jne    11f3 <read_make+0xc3>
mov    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
add    $0x1,%rax
movslq -0x1c(%rbp),%rcx
cmp    %rcx,%rax
jle    11ba <read_make+0x8a>
movslq -0x1c(%rbp),%rax
mov    %rax,-0x48(%rbp)
jmp    11cd <read_make+0x9d>
mov    -0x38(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rax
mov    %eax,%esi
mov    -0x10(%rbp),%rcx
lea    0xe26(%rip),%rdx
call   1040 <snprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11fa <read_make+0xca>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_make>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r13
mov    %rcx,%r14
mov    %edx,%r15d
mov    %rsi,(%rsp)
mov    %rdi,%r12
mov    $0x3a,%esi
call   1030 <strchr@plt>
xor    %ebx,%ebx
test   %rax,%rax
je     11a0 <read_make+0x70>
mov    %rax,%rbp
lea    0xe9a(%rip),%rsi
mov    %rax,%rdi
mov    %r14,%rdx
mov    %r13,%rcx
call   1050 <sscanf@plt>
cmp    $0x2,%eax
jne    11a0 <read_make+0x70>
sub    %r12,%rbp
movslq %r15d,%rsi
lea    0x1(%rbp),%eax
cmp    %rsi,%rbp
cmovl  %eax,%esi
lea    0xe79(%rip),%rdx
mov    (%rsp),%rdi
mov    %r12,%rcx
call   1040 <snprintf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [8 x i8] c":%d:%d:\00"
@.str.1 = [3 x i8] c"%s\00"
define i32 @read_make(i8* %0, i8* %1, i32 %2, i32* %3, i32* %4) {
%6 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 58)
%7 = icmp eq i8* %6, null
br i1 %7, label %21, label %8
8: ; preds = %5
%9 = tail call i32 @sscanf(i8* %6, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32* %3, i32* %4)
%10 = icmp eq i32 %9, 2
br i1 %10, label %11, label %21
11: ; preds = %8
%12 = ptrtoint i8* %6 to i64
%13 = ptrtoint i8* %0 to i64
%14 = sub i64 %12, %13
%15 = sext i32 %2 to i64
%16 = icmp slt i64 %14, %15
%17 = add nsw i64 %14, 1
%18 = select i1 %16, i64 %17, i64 %15
%19 = trunc i64 %18 to i32
%20 = tail call i32 @snprintf(i8* %1, i32 %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %21
21: ; preds = %5, %8, %11
%22 = phi i32 [ 1, %11 ], [ 0, %8 ], [ 0, %5 ]
ret i32 %22
}