#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 */
scalar_t__ timestamp_compare(char const *, char const *, int *,
                             int /*<<< orphan*/ *);
int timestamp_has_common(const char *start, const char *end, const char *oldest,
                         const char *latest) {
  int res;
  if (timestamp_compare(start, latest, &res, NULL) < 0) {
    return -2;
  }
  if (res == 1) {
    return -3;
  }
  if (timestamp_compare(end, oldest, &res, NULL) < 0) {
    return -2;
  }
  if (res == -1) {
    return -4;
  }
  return 1;
}


x86 assembly (clang, -O0):
<timestamp_has_common>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
lea    -0x2c(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
call   1030 <timestamp_compare@plt>
cmp    $0x0,%rax
jge    1153 <timestamp_has_common+0x43>
movl   $0xfffffffe,-0x4(%rbp)
jmp    11b1 <timestamp_has_common+0xa1>
cmpl   $0x1,-0x2c(%rbp)
jne    1169 <timestamp_has_common+0x59>
movl   $0xfffffffd,-0x4(%rbp)
jmp    11b1 <timestamp_has_common+0xa1>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
lea    -0x2c(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
call   1030 <timestamp_compare@plt>
cmp    $0x0,%rax
jge    1194 <timestamp_has_common+0x84>
movl   $0xfffffffe,-0x4(%rbp)
jmp    11b1 <timestamp_has_common+0xa1>
cmpl   $0xffffffff,-0x2c(%rbp)
jne    11aa <timestamp_has_common+0x9a>
movl   $0xfffffffc,-0x4(%rbp)
jmp    11b1 <timestamp_has_common+0xa1>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<timestamp_has_common>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
lea    0x4(%rsp),%rdx
mov    %rcx,%rsi
xor    %ecx,%ecx
call   1030 <timestamp_compare@plt>
mov    %rax,%rcx
mov    $0xfffffffe,%eax
test   %rcx,%rcx
js     1171 <timestamp_has_common+0x61>
mov    $0xfffffffd,%eax
cmpl   $0x1,0x4(%rsp)
je     1171 <timestamp_has_common+0x61>
lea    0x4(%rsp),%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %ecx,%ecx
call   1030 <timestamp_compare@plt>
mov    %rax,%rcx
mov    $0xfffffffe,%eax
test   %rcx,%rcx
js     1171 <timestamp_has_common+0x61>
xor    %eax,%eax
cmpl   $0xffffffff,0x4(%rsp)
setne  %al
lea    (%rax,%rax,4),%eax
add    $0xfffffffc,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @timestamp_has_common(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
%11 = load i8*, i8** %6
%12 = load i8*, i8** %9
%13 = call i64 @timestamp_compare(i8* %11, i8* %12, i32* %10, i32* null)
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %4
store i32 -2, i32* %5
br label %31
16: ; preds = %4
%17 = load i32, i32* %10
%18 = icmp eq i32 %17, 1
br i1 %18, label %19, label %20
19: ; preds = %16
store i32 -3, i32* %5
br label %31
20: ; preds = %16
%21 = load i8*, i8** %7
%22 = load i8*, i8** %8
%23 = call i64 @timestamp_compare(i8* %21, i8* %22, i32* %10, i32* null)
%24 = icmp slt i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %20
store i32 -2, i32* %5
br label %31
26: ; preds = %20
%27 = load i32, i32* %10
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %30
29: ; preds = %26
store i32 -4, i32* %5
br label %31
30: ; preds = %26
store i32 1, i32* %5
br label %31
31: ; preds = %30, %29, %25, %19, %15
%32 = load i32, i32* %5
ret i32 %32
}

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