#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 */
unsigned long approxidate_str(char const *, struct timeval *, int *);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ parse_date_basic(char const *, unsigned long *, int *);
unsigned long approxidate_careful(const char *date, int *error_ret) {
  struct timeval tv;
  unsigned long timestamp;
  int offset;
  int dummy = 0;
  if (!error_ret)
    error_ret = &dummy;
  if (!parse_date_basic(date, &timestamp, &offset)) {
    *error_ret = 0;
    return timestamp;
  }
  gettimeofday(&tv, NULL);
  return approxidate_str(date, &tv, error_ret);
}


x86 assembly (clang, -O0):
<approxidate_careful>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x30(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    115a <approxidate_careful+0x2a>
lea    -0x30(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x28(%rbp),%rsi
lea    -0x2c(%rbp),%rdx
call   1050 <parse_date_basic@plt>
cmp    $0x0,%eax
jne    118b <approxidate_careful+0x5b>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11ad <approxidate_careful+0x7d>
lea    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rsi
call   1040 <approxidate_str@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<approxidate_careful>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%r14
movl   $0x0,0xc(%rsp)
test   %rsi,%rsi
lea    0xc(%rsp),%rbx
cmovne %rsi,%rbx
lea    0x10(%rsp),%rsi
lea    0x1c(%rsp),%rdx
call   1050 <parse_date_basic@plt>
test   %eax,%eax
je     1182 <approxidate_careful+0x52>
lea    0x18(%rsp),%r15
mov    %r15,%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1040 <approxidate_str@plt>
jmp    118d <approxidate_careful+0x5d>
movl   $0x0,(%rbx)
mov    0x10(%rsp),%rax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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