#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 */
struct timeval {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ approxidate_str(char const *, struct timeval *);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ parse_date_basic(char const *, struct timeval *, int *);
int approxidate(const char *date, struct timeval *tv) {
  int offset;
  if (!parse_date_basic(date, tv, &offset)) {
    return 0;
  }
  gettimeofday(tv, NULL);
  if (!approxidate_str(date, tv)) {
    return 0;
  }
  return -1;
}


x86 assembly (clang, -O0):
<approxidate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
call   1050 <parse_date_basic@plt>
cmp    $0x0,%eax
jne    1166 <approxidate+0x36>
movl   $0x0,-0x4(%rbp)
jmp    119c <approxidate+0x6c>
mov    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <approxidate_str@plt>
cmp    $0x0,%eax
jne    1195 <approxidate+0x65>
movl   $0x0,-0x4(%rbp)
jmp    119c <approxidate+0x6c>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<approxidate>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0x4(%rsp),%rdx
call   1050 <parse_date_basic@plt>
test   %eax,%eax
je     1163 <approxidate+0x33>
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <approxidate_str@plt>
neg    %eax
sbb    %eax,%eax
jmp    1165 <approxidate+0x35>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.timeval = type { i32 }
define i32 @approxidate(i8* %0, %struct.timeval* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca %struct.timeval*
%6 = alloca i32
store i8* %0, i8** %4
store %struct.timeval* %1, %struct.timeval** %5
%7 = load i8*, i8** %4
%8 = load %struct.timeval*, %struct.timeval** %5
%9 = call i32 @parse_date_basic(i8* %7, %struct.timeval* %8, i32* %6)
%10 = icmp ne i32 %9, 0
br i1 %10, label %12, label %11
11: ; preds = %2
store i32 0, i32* %3
br label %21
12: ; preds = %2
%13 = load %struct.timeval*, %struct.timeval** %5
%14 = call i32 @gettimeofday(%struct.timeval* %13, i32* null)
%15 = load i8*, i8** %4
%16 = load %struct.timeval*, %struct.timeval** %5
%17 = call i32 @approxidate_str(i8* %15, %struct.timeval* %16)
%18 = icmp ne i32 %17, 0
br i1 %18, label %20, label %19
19: ; preds = %12
store i32 0, i32* %3
br label %21
20: ; preds = %12
store i32 -1, i32* %3
br label %21
21: ; preds = %20, %19, %11
%22 = load i32, i32* %3
ret i32 %22
}

LLVM IR (-O2):
%struct.timeval = type { i32 }
define i32 @approxidate(i8* %0, %struct.timeval* %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = call i32 @parse_date_basic(i8* %0, %struct.timeval* %1, i32* %3)
%6 = icmp eq i32 %5, 0
br i1 %6, label %12, label %7
7: ; preds = %2
%8 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%9 = call i32 @approxidate_str(i8* %0, %struct.timeval* %1)
%10 = icmp ne i32 %9, 0
%11 = sext i1 %10 to i32
br label %12
12: ; preds = %7, %2
%13 = phi i32 [ 0, %2 ], [ %11, %7 ]
ret i32 %13
}