#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*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ parse_double(char *, double *);
int /*<<< orphan*/ parse_long(char *, long *);
int /*<<< orphan*/ parse_month(char *, long *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ substr(char *, char const *, int, int);
int parse_line(const char *linebuf, int *year, int *month, int *day,
               double *delta) {
  char s[0x100];
  long tmp;
  substr(s, linebuf, 1, 4);
  if (!parse_long(s, &tmp)) {
    fprintf(stderr, "cannot parse year: \"%s\"\n", s);
    return 0;
  }
  *year = (int)tmp;
  substr(s, linebuf, 6, 3);
  if (!parse_month(s, &tmp)) {
    fprintf(stderr, "cannot parse month: \"%s\"\n", s);
    return 0;
  }
  *month = (int)tmp;
  substr(s, linebuf, 10, 2);
  if (!parse_long(s, &tmp)) {
    fprintf(stderr, "cannot parse day: \"%s\"\n", s);
    return 0;
  }
  *day = (int)tmp;
  substr(s, linebuf, 36, 13);
  if (!parse_double(s, delta)) {
    fprintf(stderr, "cannot parse delta: %s\n", s);
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<parse_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
lea    -0x130(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x1,%edx
mov    $0x4,%ecx
call   1030 <substr@plt>
lea    -0x130(%rbp),%rdi
lea    -0x138(%rbp),%rsi
call   1050 <parse_long@plt>
cmp    $0x0,%eax
jne    11cd <parse_line+0x7d>
mov    0x2e34(%rip),%rax
mov    (%rax),%edi
lea    -0x130(%rbp),%rdx
lea    0xe44(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1318 <parse_line+0x1c8>
mov    -0x138(%rbp),%rax
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
lea    -0x130(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x6,%edx
mov    $0x3,%ecx
call   1030 <substr@plt>
lea    -0x130(%rbp),%rdi
lea    -0x138(%rbp),%rsi
call   1070 <parse_month@plt>
cmp    $0x0,%eax
jne    123a <parse_line+0xea>
mov    0x2dc7(%rip),%rax
mov    (%rax),%edi
lea    -0x130(%rbp),%rdx
lea    0xdf0(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1318 <parse_line+0x1c8>
mov    -0x138(%rbp),%rax
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
lea    -0x130(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0xa,%edx
mov    $0x2,%ecx
call   1030 <substr@plt>
lea    -0x130(%rbp),%rdi
lea    -0x138(%rbp),%rsi
call   1050 <parse_long@plt>
cmp    $0x0,%eax
jne    12a7 <parse_line+0x157>
mov    0x2d5a(%rip),%rax
mov    (%rax),%edi
lea    -0x130(%rbp),%rdx
lea    0xd9d(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1318 <parse_line+0x1c8>
mov    -0x138(%rbp),%rax
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
lea    -0x130(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x24,%edx
mov    $0xd,%ecx
call   1030 <substr@plt>
lea    -0x130(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1060 <parse_double@plt>
cmp    $0x0,%eax
jne    1311 <parse_line+0x1c1>
mov    0x2cf0(%rip),%rax
mov    (%rax),%edi
lea    -0x130(%rbp),%rdx
lea    0xd4b(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1318 <parse_line+0x1c8>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_line>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%rbx
mov    %rdi,%r13
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    %r13,%rsi
mov    $0x1,%edx
mov    $0x4,%ecx
call   1030 <substr@plt>
lea    0x8(%rsp),%rsi
mov    %rbp,%rdi
call   1050 <parse_long@plt>
test   %eax,%eax
je     1243 <parse_line+0xf3>
mov    0x8(%rsp),%eax
mov    %eax,(%rbx)
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %r13,%rsi
mov    $0x6,%edx
mov    $0x3,%ecx
call   1030 <substr@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <parse_month@plt>
test   %eax,%eax
je     124c <parse_line+0xfc>
mov    0x8(%rsp),%eax
mov    %eax,(%r12)
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %r13,%rsi
mov    $0xa,%edx
mov    $0x2,%ecx
call   1030 <substr@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <parse_long@plt>
test   %eax,%eax
je     1255 <parse_line+0x105>
mov    0x8(%rsp),%eax
mov    %eax,(%r15)
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %r13,%rsi
mov    $0x24,%edx
mov    $0xd,%ecx
call   1030 <substr@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <parse_double@plt>
mov    %eax,%ecx
mov    $0x1,%eax
test   %ecx,%ecx
jne    1271 <parse_line+0x121>
lea    0xe0a(%rip),%rsi
jmp    125c <parse_line+0x10c>
lea    0xdb6(%rip),%rsi
jmp    125c <parse_line+0x10c>
lea    0xdc6(%rip),%rsi
jmp    125c <parse_line+0x10c>
lea    0xdd7(%rip),%rsi
mov    0x2d7d(%rip),%rax
mov    (%rax),%edi
lea    0x10(%rsp),%rdx
call   1040 <fprintf@plt>
xor    %eax,%eax
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [25 x i8] c"cannot parse year: \22%s\22\0A\00"
@.str.1 = [26 x i8] c"cannot parse month: \22%s\22\0A\00"
@.str.2 = [24 x i8] c"cannot parse day: \22%s\22\0A\00"
@.str.3 = [24 x i8] c"cannot parse delta: %s\0A\00"
define i32 @parse_line(i8* %0, i32* %1, i32* %2, i32* %3, double* %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca double*
%12 = alloca [256 x i8]
%13 = alloca i64
store i8* %0, i8** %7
store i32* %1, i32** %8
store i32* %2, i32** %9
store i32* %3, i32** %10
store double* %4, double** %11
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%15 = load i8*, i8** %7
%16 = call i32 @substr(i8* %14, i8* %15, i32 1, i32 4)
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%18 = call i32 @parse_long(i8* %17, i64* %13)
%19 = icmp ne i32 %18, 0
br i1 %19, label %24, label %20
20: ; preds = %5
%21 = load i32, i32* @stderr
%22 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%23 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %22)
store i32 0, i32* %6
br label %68
24: ; preds = %5
%25 = load i64, i64* %13
%26 = trunc i64 %25 to i32
%27 = load i32*, i32** %8
store i32 %26, i32* %27
%28 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%29 = load i8*, i8** %7
%30 = call i32 @substr(i8* %28, i8* %29, i32 6, i32 3)
%31 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%32 = call i32 @parse_month(i8* %31, i64* %13)
%33 = icmp ne i32 %32, 0
br i1 %33, label %38, label %34
34: ; preds = %24
%35 = load i32, i32* @stderr
%36 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%37 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %36)
store i32 0, i32* %6
br label %68
38: ; preds = %24
%39 = load i64, i64* %13
%40 = trunc i64 %39 to i32
%41 = load i32*, i32** %9
store i32 %40, i32* %41
%42 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%43 = load i8*, i8** %7
%44 = call i32 @substr(i8* %42, i8* %43, i32 10, i32 2)
%45 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%46 = call i32 @parse_long(i8* %45, i64* %13)
%47 = icmp ne i32 %46, 0
br i1 %47, label %52, label %48
48: ; preds = %38
%49 = load i32, i32* @stderr
%50 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%51 = call i32 @fprintf(i32 %49, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %50)
store i32 0, i32* %6
br label %68
52: ; preds = %38
%53 = load i64, i64* %13
%54 = trunc i64 %53 to i32
%55 = load i32*, i32** %10
store i32 %54, i32* %55
%56 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%57 = load i8*, i8** %7
%58 = call i32 @substr(i8* %56, i8* %57, i32 36, i32 13)
%59 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%60 = load double*, double** %11
%61 = call i32 @parse_double(i8* %59, double* %60)
%62 = icmp ne i32 %61, 0
br i1 %62, label %67, label %63
63: ; preds = %52
%64 = load i32, i32* @stderr
%65 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%66 = call i32 @fprintf(i32 %64, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %65)
store i32 0, i32* %6
br label %68
67: ; preds = %52
store i32 1, i32* %6
br label %68
68: ; preds = %67, %63, %48, %34, %20
%69 = load i32, i32* %6
ret i32 %69
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [25 x i8] c"cannot parse year: \22%s\22\0A\00"
@.str.1 = [26 x i8] c"cannot parse month: \22%s\22\0A\00"
@.str.2 = [24 x i8] c"cannot parse day: \22%s\22\0A\00"
@.str.3 = [24 x i8] c"cannot parse delta: %s\0A\00"
define i32 @parse_line(i8* %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2, i32* nocapture writeonly %3, double* %4) {
%6 = alloca [256 x i8]
%7 = alloca i64
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%9 = bitcast i64* %7 to i8*
%10 = call i32 @substr(i8* %8, i8* %0, i32 1, i32 4)
%11 = call i32 @parse_long(i8* %8, i64* %7)
%12 = icmp eq i32 %11, 0
br i1 %12, label %31, label %13
13: ; preds = %5
%14 = load i64, i64* %7
%15 = trunc i64 %14 to i32
store i32 %15, i32* %1
%16 = call i32 @substr(i8* %8, i8* %0, i32 6, i32 3)
%17 = call i32 @parse_month(i8* %8, i64* %7)
%18 = icmp eq i32 %17, 0
br i1 %18, label %31, label %19
19: ; preds = %13
%20 = load i64, i64* %7
%21 = trunc i64 %20 to i32
store i32 %21, i32* %2
%22 = call i32 @substr(i8* %8, i8* %0, i32 10, i32 2)
%23 = call i32 @parse_long(i8* %8, i64* %7)
%24 = icmp eq i32 %23, 0
br i1 %24, label %31, label %25
25: ; preds = %19
%26 = load i64, i64* %7
%27 = trunc i64 %26 to i32
store i32 %27, i32* %3
%28 = call i32 @substr(i8* %8, i8* %0, i32 36, i32 13)
%29 = call i32 @parse_double(i8* %8, double* %4)
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %35
31: ; preds = %25, %19, %13, %5
%32 = phi i8* [ getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), %5 ], [ getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), %13 ], [ getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), %19 ], [ getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), %25 ]
%33 = load i32, i32* @stderr
%34 = call i32 @fprintf(i32 %33, i8* %32, i8* %8)
br label %35
35: ; preds = %31, %25
%36 = phi i32 [ 1, %25 ], [ 0, %31 ]
ret i32 %36
}