#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 julian_day(int, int, int);
int sscanf(char const *, char *, int *, int *, int *, int *, int *, int *);
void read_time_string(const char *timestr, int *jul, int *secs) {
  int yy, mm, dd, hh, min, ss, n;
  *jul = 0;
  *secs = 0;
  n = sscanf(timestr, "%4d-%2d-%2d %2d:%2d:%2d", &yy, &mm, &dd, &hh, &min, &ss);
  if (n > 2)
    *jul = julian_day(yy, mm, dd);
  if (n > 4)
    *secs = 3600 * hh + 60 * min;
  if (n > 5)
    *secs += ss;
}


x86 assembly (clang, -O0):
<read_time_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
lea    0xead(%rip),%rsi
lea    -0x1c(%rbp),%rdx
lea    -0x20(%rbp),%rcx
lea    -0x24(%rbp),%r8
lea    -0x28(%rbp),%r9
lea    -0x2c(%rbp),%r10
lea    -0x30(%rbp),%rax
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1040 <sscanf@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x2,-0x34(%rbp)
jle    119c <read_time_string+0x7c>
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
call   1030 <julian_day@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
cmpl   $0x4,-0x34(%rbp)
jle    11b9 <read_time_string+0x99>
imul   $0xe10,-0x28(%rbp),%ecx
imul   $0x3c,-0x2c(%rbp),%eax
add    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
cmpl   $0x5,-0x34(%rbp)
jle    11ce <read_time_string+0xae>
mov    -0x30(%rbp),%ecx
mov    -0x18(%rbp),%rax
add    (%rax),%ecx
mov    %ecx,(%rax)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_time_string>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
movl   $0x0,(%rsi)
movl   $0x0,(%rdx)
lea    0x8(%rsp),%rax
lea    0xc(%rsp),%rbp
lea    0xeb5(%rip),%rsi
lea    0x1c(%rsp),%rdx
lea    0x18(%rsp),%rcx
lea    0x14(%rsp),%r8
lea    0x10(%rsp),%r9
push   %rax
push   %rbp
call   1040 <sscanf@plt>
add    $0x10,%rsp
cmp    $0x3,%eax
jl     11a7 <read_time_string+0x87>
mov    %eax,%ebp
mov    0x1c(%rsp),%edi
mov    0x18(%rsp),%esi
mov    0x14(%rsp),%edx
call   1030 <julian_day@plt>
mov    %eax,(%rbx)
cmp    $0x5,%ebp
jb     11a7 <read_time_string+0x87>
imul   $0xe10,0x10(%rsp),%ecx
imul   $0x3c,0xc(%rsp),%eax
add    %ecx,%eax
mov    %eax,(%r14)
cmp    $0x5,%ebp
je     11a7 <read_time_string+0x87>
add    0x8(%rsp),%eax
mov    %eax,(%r14)
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [24 x i8] c"%4d-%2d-%2d %2d:%2d:%2d\00"
define void @read_time_string(i8* nocapture %0, i32* nocapture writeonly %1, i32* nocapture %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = bitcast i32* %4 to i8*
%11 = bitcast i32* %5 to i8*
%12 = bitcast i32* %6 to i8*
%13 = bitcast i32* %7 to i8*
%14 = bitcast i32* %8 to i8*
%15 = bitcast i32* %9 to i8*
store i32 0, i32* %1
store i32 0, i32* %2
%16 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32* %4, i32* %5, i32* %6, i32* %7, i32* %8, i32* %9)
%17 = icmp sgt i32 %16, 2
br i1 %17, label %18, label %34
18: ; preds = %3
%19 = load i32, i32* %4
%20 = load i32, i32* %5
%21 = load i32, i32* %6
%22 = call i32 @julian_day(i32 %19, i32 %20, i32 %21)
store i32 %22, i32* %1
%23 = icmp ugt i32 %16, 4
br i1 %23, label %24, label %34
24: ; preds = %18
%25 = load i32, i32* %7
%26 = mul nsw i32 %25, 3600
%27 = load i32, i32* %8
%28 = mul nsw i32 %27, 60
%29 = add nsw i32 %28, %26
store i32 %29, i32* %2
%30 = icmp eq i32 %16, 5
br i1 %30, label %34, label %31
31: ; preds = %24
%32 = load i32, i32* %9
%33 = add nsw i32 %29, %32
store i32 %33, i32* %2
br label %34
34: ; preds = %3, %18, %31, %24
ret void
}