#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 */
typedef int /*<<< orphan*/ time_t;
struct tm {
  long tm_sec;
  long tm_min;
  long tm_hour;
};

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ mkgmtime(struct tm *);
long strtol(char const *, char **, int);
time_t jtr_parse_time(const char *str, struct tm *tm, int *micro) {
  long int hms;
  char *dot;
  hms = strtol(str, &dot, 10);
  if (hms > 0) {
    tm->tm_sec = hms % 100;
    hms = hms / 100;
    tm->tm_min = hms % 100;
    hms = hms / 100;
    tm->tm_hour = hms % 100;
    if ((*dot == '.') && (micro != NULL))
      *micro = atoi(dot + 1) * 10000;
    return mkgmtime(tm);
  } else
    return 0;
}


x86 assembly (clang, -O0):
<jtr_parse_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jle    120f <jtr_parse_time+0xdf>
mov    -0x28(%rbp),%rax
mov    $0x64,%ecx
cqto
idiv   %rcx
mov    -0x18(%rbp),%rax
mov    %rdx,(%rax)
mov    -0x28(%rbp),%rax
mov    $0x64,%ecx
cqto
idiv   %rcx
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    $0x64,%ecx
cqto
idiv   %rcx
mov    -0x18(%rbp),%rax
mov    %rdx,0x8(%rax)
mov    -0x28(%rbp),%rax
mov    $0x64,%ecx
cqto
idiv   %rcx
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    $0x64,%ecx
cqto
idiv   %rcx
mov    -0x18(%rbp),%rax
mov    %rdx,0x10(%rax)
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    11fe <jtr_parse_time+0xce>
cmpq   $0x0,-0x20(%rbp)
je     11fe <jtr_parse_time+0xce>
mov    -0x30(%rbp),%rdi
add    $0x1,%rdi
call   1050 <atoi@plt>
imul   $0x2710,%eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rdi
call   1030 <mkgmtime@plt>
mov    %eax,-0x4(%rbp)
jmp    1216 <jtr_parse_time+0xe6>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<jtr_parse_time>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rsp,%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
test   %rax,%rax
jle    11f0 <jtr_parse_time+0xc0>
mov    %rax,%rsi
shr    $0x2,%rax
movabs $0x28f5c28f5c28f5c3,%r8
c2 f5 28
mul    %r8
mov    %rdx,%rax
mov    %rdx,%rdi
shr    $0x2,%rdi
imul   $0x64,%rdi,%rdx
mov    %rsi,%rcx
sub    %rdx,%rcx
mov    %rcx,(%rbx)
shr    $0x4,%rax
mul    %r8
shr    $0x2,%rdx
imul   $0x64,%rdx,%rax
sub    %rax,%rdi
mov    %rdi,0x8(%rbx)
movabs $0x346dc5d63886594b,%rcx
c5 6d 34
mov    %rsi,%rax
mul    %rcx
mov    %rdx,%rax
mov    %rdx,%rcx
shr    $0xb,%rcx
shr    $0xd,%rax
mul    %r8
shr    $0x2,%rdx
imul   $0x64,%rdx,%rax
sub    %rax,%rcx
mov    %rcx,0x10(%rbx)
test   %r14,%r14
je     11e1 <jtr_parse_time+0xb1>
mov    (%rsp),%rdi
cmpb   $0x2e,(%rdi)
jne    11e1 <jtr_parse_time+0xb1>
add    $0x1,%rdi
call   1050 <atoi@plt>
imul   $0x2710,%eax,%eax
mov    %eax,(%r14)
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <mkgmtime@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i64, i64, i64 }
define i32 @jtr_parse_time(i8* %0, %struct.tm* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca %struct.tm*
%7 = alloca i32*
%8 = alloca i64
%9 = alloca i8*
store i8* %0, i8** %5
store %struct.tm* %1, %struct.tm** %6
store i32* %2, i32** %7
%10 = load i8*, i8** %5
%11 = call i64 @strtol(i8* %10, i8** %9, i32 10)
store i64 %11, i64* %8
%12 = load i64, i64* %8
%13 = icmp sgt i64 %12, 0
br i1 %13, label %14, label %47
14: ; preds = %3
%15 = load i64, i64* %8
%16 = srem i64 %15, 100
%17 = load %struct.tm*, %struct.tm** %6
%18 = getelementptr inbounds %struct.tm, %struct.tm* %17, i32 0, i32 0
store i64 %16, i64* %18
%19 = load i64, i64* %8
%20 = sdiv i64 %19, 100
store i64 %20, i64* %8
%21 = load i64, i64* %8
%22 = srem i64 %21, 100
%23 = load %struct.tm*, %struct.tm** %6
%24 = getelementptr inbounds %struct.tm, %struct.tm* %23, i32 0, i32 1
store i64 %22, i64* %24
%25 = load i64, i64* %8
%26 = sdiv i64 %25, 100
store i64 %26, i64* %8
%27 = load i64, i64* %8
%28 = srem i64 %27, 100
%29 = load %struct.tm*, %struct.tm** %6
%30 = getelementptr inbounds %struct.tm, %struct.tm* %29, i32 0, i32 2
store i64 %28, i64* %30
%31 = load i8*, i8** %9
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 46
br i1 %34, label %35, label %44
35: ; preds = %14
%36 = load i32*, i32** %7
%37 = icmp ne i32* %36, null
br i1 %37, label %38, label %44
38: ; preds = %35
%39 = load i8*, i8** %9
%40 = getelementptr inbounds i8, i8* %39, i64 1
%41 = call i32 @atoi(i8* %40)
%42 = mul nsw i32 %41, 10000
%43 = load i32*, i32** %7
store i32 %42, i32* %43
br label %44
44: ; preds = %38, %35, %14
%45 = load %struct.tm*, %struct.tm** %6
%46 = call i32 @mkgmtime(%struct.tm* %45)
store i32 %46, i32* %4
br label %48
47: ; preds = %3
store i32 0, i32* %4
br label %48
48: ; preds = %47, %44
%49 = load i32, i32* %4
ret i32 %49
}

LLVM IR (-O2):
%struct.tm = type { i64, i64, i64 }
define i32 @jtr_parse_time(i8* %0, %struct.tm* %1, i32* writeonly %2) {
%4 = alloca i8*
%5 = bitcast i8** %4 to i8*
%6 = call i64 @strtol(i8* %0, i8** %4, i32 10)
%7 = icmp sgt i64 %6, 0
br i1 %7, label %8, label %28
8: ; preds = %3
%9 = urem i64 %6, 100
%10 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 0
store i64 %9, i64* %10
%11 = udiv i64 %6, 100
%12 = urem i64 %11, 100
%13 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 1
store i64 %12, i64* %13
%14 = udiv i64 %6, 10000
%15 = urem i64 %14, 100
%16 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 2
store i64 %15, i64* %16
%17 = load i8*, i8** %4
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 46
%20 = icmp ne i32* %2, null
%21 = and i1 %20, %19
br i1 %21, label %22, label %26
22: ; preds = %8
%23 = getelementptr inbounds i8, i8* %17, i64 1
%24 = tail call i32 @atoi(i8* %23)
%25 = mul nsw i32 %24, 10000
store i32 %25, i32* %2
br label %26
26: ; preds = %22, %8
%27 = tail call i32 @mkgmtime(%struct.tm* %1)
br label %28
28: ; preds = %3, %26
%29 = phi i32 [ %27, %26 ], [ 0, %3 ]
ret i32 %29
}