#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 */
unsigned long new_num_lines(char const *);
unsigned long orig_num_lines(char const *);
char *strchr(char const *, char);
unsigned long strtoul(char *, char **, int);
int read_atatline(const char *atatline, unsigned long *orig_offset,
                  unsigned long *orig_count, unsigned long *new_offset,
                  unsigned long *new_count) {
  char *endptr;
  unsigned long res;
  char *p;
  if (orig_offset) {
    p = strchr(atatline, '-');
    if (!p)
      return 1;
    p++;
    res = strtoul(p, &endptr, 10);
    if (p == endptr)
      return 1;
    *orig_offset = res;
  }
  if (orig_count)
    *orig_count = orig_num_lines(atatline);
  if (new_offset) {
    p = strchr(atatline, '+');
    if (!p)
      return 1;
    p++;
    res = strtoul(p, &endptr, 10);
    if (p == endptr)
      return 1;
    *new_offset = res;
  }
  if (new_count)
    *new_count = new_num_lines(atatline);
  return 0;
}


x86 assembly (clang, -O0):
<read_atatline>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11d7 <read_atatline+0x97>
mov    -0x10(%rbp),%rdi
mov    $0x2d,%esi
call   1030 <strchr@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    1190 <read_atatline+0x50>
movl   $0x1,-0x4(%rbp)
jmp    1295 <read_atatline+0x155>
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
lea    -0x38(%rbp),%rsi
mov    $0xa,%edx
call   1050 <strtoul@plt>
mov    %rax,-0x40(%rbp)
mov    -0x48(%rbp),%rax
cmp    -0x38(%rbp),%rax
jne    11cc <read_atatline+0x8c>
movl   $0x1,-0x4(%rbp)
jmp    1295 <read_atatline+0x155>
mov    -0x40(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
cmpq   $0x0,-0x20(%rbp)
je     11f5 <read_atatline+0xb5>
mov    -0x10(%rbp),%rdi
call   1060 <orig_num_lines@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
cmpq   $0x0,-0x28(%rbp)
je     1270 <read_atatline+0x130>
mov    -0x10(%rbp),%rdi
mov    $0x2b,%esi
call   1030 <strchr@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    1229 <read_atatline+0xe9>
movl   $0x1,-0x4(%rbp)
jmp    1295 <read_atatline+0x155>
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
lea    -0x38(%rbp),%rsi
mov    $0xa,%edx
call   1050 <strtoul@plt>
mov    %rax,-0x40(%rbp)
mov    -0x48(%rbp),%rax
cmp    -0x38(%rbp),%rax
jne    1265 <read_atatline+0x125>
movl   $0x1,-0x4(%rbp)
jmp    1295 <read_atatline+0x155>
mov    -0x40(%rbp),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
cmpq   $0x0,-0x30(%rbp)
je     128e <read_atatline+0x14e>
mov    -0x10(%rbp),%rdi
call   1040 <new_num_lines@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_atatline>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,%rbx
mov    %rdi,%r12
test   %rsi,%rsi
je     11b2 <read_atatline+0x72>
mov    %rsi,%rbp
mov    %r15,0x10(%rsp)
mov    %r14,%r15
mov    %r12,%rdi
mov    $0x2d,%esi
call   1030 <strchr@plt>
mov    $0x1,%r13d
test   %rax,%rax
je     1215 <read_atatline+0xd5>
mov    %rax,%r14
add    $0x1,%r14
lea    0x8(%rsp),%rsi
mov    %r14,%rdi
mov    $0xa,%edx
call   1050 <strtoul@plt>
cmp    0x8(%rsp),%r14
mov    %r15,%r14
mov    0x10(%rsp),%r15
je     1215 <read_atatline+0xd5>
mov    %rax,0x0(%rbp)
test   %rbx,%rbx
je     11c2 <read_atatline+0x82>
mov    %r12,%rdi
call   1060 <orig_num_lines@plt>
mov    %rax,(%rbx)
test   %r15,%r15
je     1202 <read_atatline+0xc2>
mov    %r12,%rdi
mov    $0x2b,%esi
call   1030 <strchr@plt>
mov    $0x1,%r13d
test   %rax,%rax
je     1215 <read_atatline+0xd5>
mov    %rax,%rbx
add    $0x1,%rbx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
mov    $0xa,%edx
call   1050 <strtoul@plt>
cmp    0x8(%rsp),%rbx
je     1215 <read_atatline+0xd5>
mov    %rax,(%r15)
xor    %r13d,%r13d
test   %r14,%r14
je     1215 <read_atatline+0xd5>
mov    %r12,%rdi
call   1040 <new_num_lines@plt>
mov    %rax,(%r14)
mov    %r13d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @read_atatline(i8* %0, i64* %1, i64* %2, i64* %3, i64* %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64*
%9 = alloca i64*
%10 = alloca i64*
%11 = alloca i64*
%12 = alloca i8*
%13 = alloca i64
%14 = alloca i8*
store i8* %0, i8** %7
store i64* %1, i64** %8
store i64* %2, i64** %9
store i64* %3, i64** %10
store i64* %4, i64** %11
%15 = load i64*, i64** %8
%16 = icmp ne i64* %15, null
br i1 %16, label %17, label %35
17: ; preds = %5
%18 = load i8*, i8** %7
%19 = call i8* @strchr(i8* %18, i8 signext 45)
store i8* %19, i8** %14
%20 = load i8*, i8** %14
%21 = icmp ne i8* %20, null
br i1 %21, label %23, label %22
22: ; preds = %17
store i32 1, i32* %6
br label %71
23: ; preds = %17
%24 = load i8*, i8** %14
%25 = getelementptr inbounds i8, i8* %24, i32 1
store i8* %25, i8** %14
%26 = load i8*, i8** %14
%27 = call i64 @strtoul(i8* %26, i8** %12, i32 10)
store i64 %27, i64* %13
%28 = load i8*, i8** %14
%29 = load i8*, i8** %12
%30 = icmp eq i8* %28, %29
br i1 %30, label %31, label %32
31: ; preds = %23
store i32 1, i32* %6
br label %71
32: ; preds = %23
%33 = load i64, i64* %13
%34 = load i64*, i64** %8
store i64 %33, i64* %34
br label %35
35: ; preds = %32, %5
%36 = load i64*, i64** %9
%37 = icmp ne i64* %36, null
br i1 %37, label %38, label %42
38: ; preds = %35
%39 = load i8*, i8** %7
%40 = call i64 @orig_num_lines(i8* %39)
%41 = load i64*, i64** %9
store i64 %40, i64* %41
br label %42
42: ; preds = %38, %35
%43 = load i64*, i64** %10
%44 = icmp ne i64* %43, null
br i1 %44, label %45, label %63
45: ; preds = %42
%46 = load i8*, i8** %7
%47 = call i8* @strchr(i8* %46, i8 signext 43)
store i8* %47, i8** %14
%48 = load i8*, i8** %14
%49 = icmp ne i8* %48, null
br i1 %49, label %51, label %50
50: ; preds = %45
store i32 1, i32* %6
br label %71
51: ; preds = %45
%52 = load i8*, i8** %14
%53 = getelementptr inbounds i8, i8* %52, i32 1
store i8* %53, i8** %14
%54 = load i8*, i8** %14
%55 = call i64 @strtoul(i8* %54, i8** %12, i32 10)
store i64 %55, i64* %13
%56 = load i8*, i8** %14
%57 = load i8*, i8** %12
%58 = icmp eq i8* %56, %57
br i1 %58, label %59, label %60
59: ; preds = %51
store i32 1, i32* %6
br label %71
60: ; preds = %51
%61 = load i64, i64* %13
%62 = load i64*, i64** %10
store i64 %61, i64* %62
br label %63
63: ; preds = %60, %42
%64 = load i64*, i64** %11
%65 = icmp ne i64* %64, null
br i1 %65, label %66, label %70
66: ; preds = %63
%67 = load i8*, i8** %7
%68 = call i64 @new_num_lines(i8* %67)
%69 = load i64*, i64** %11
store i64 %68, i64* %69
br label %70
70: ; preds = %66, %63
store i32 0, i32* %6
br label %71
71: ; preds = %70, %59, %50, %31, %22
%72 = load i32, i32* %6
ret i32 %72
}

LLVM IR (-O2):
define i32 @read_atatline(i8* %0, i64* writeonly %1, i64* writeonly %2, i64* writeonly %3, i64* writeonly %4) {
%6 = alloca i8*
%7 = bitcast i8** %6 to i8*
%8 = icmp eq i64* %1, null
br i1 %8, label %18, label %9
9: ; preds = %5
%10 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 45)
%11 = icmp eq i8* %10, null
br i1 %11, label %37, label %12
12: ; preds = %9
%13 = getelementptr inbounds i8, i8* %10, i64 1
%14 = call i64 @strtoul(i8* %13, i8** %6, i32 10)
%15 = load i8*, i8** %6
%16 = icmp eq i8* %13, %15
br i1 %16, label %37, label %17
17: ; preds = %12
store i64 %14, i64* %1
br label %18
18: ; preds = %17, %5
%19 = icmp eq i64* %2, null
br i1 %19, label %22, label %20
20: ; preds = %18
%21 = tail call i64 @orig_num_lines(i8* %0)
store i64 %21, i64* %2
br label %22
22: ; preds = %20, %18
%23 = icmp eq i64* %3, null
br i1 %23, label %33, label %24
24: ; preds = %22
%25 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 43)
%26 = icmp eq i8* %25, null
br i1 %26, label %37, label %27
27: ; preds = %24
%28 = getelementptr inbounds i8, i8* %25, i64 1
%29 = call i64 @strtoul(i8* %28, i8** %6, i32 10)
%30 = load i8*, i8** %6
%31 = icmp eq i8* %28, %30
br i1 %31, label %37, label %32
32: ; preds = %27
store i64 %29, i64* %3
br label %33
33: ; preds = %32, %22
%34 = icmp eq i64* %4, null
br i1 %34, label %37, label %35
35: ; preds = %33
%36 = tail call i64 @new_num_lines(i8* %0)
store i64 %36, i64* %4
br label %37
37: ; preds = %33, %35, %27, %24, %12, %9
%38 = phi i32 [ 1, %9 ], [ 1, %12 ], [ 1, %24 ], [ 1, %27 ], [ 0, %35 ], [ 0, %33 ]
ret i32 %38
}