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


x86 assembly (clang, -O0):
<timestamp_find_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),%rax
mov    (%rax),%rdi
mov    -0x20(%rbp),%rsi
lea    -0x2c(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
call   1040 <timestamp_compare@plt>
cmp    $0x0,%rax
jge    1176 <timestamp_find_common+0x46>
movl   $0xffffffff,-0x4(%rbp)
jmp    11fd <timestamp_find_common+0xcd>
cmpl   $0xffffffff,-0x2c(%rbp)
jne    119f <timestamp_find_common+0x6f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1050 <strdup@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x28(%rbp),%rsi
lea    -0x2c(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
call   1040 <timestamp_compare@plt>
cmp    $0x0,%rax
jge    11cd <timestamp_find_common+0x9d>
movl   $0xffffffff,-0x4(%rbp)
jmp    11fd <timestamp_find_common+0xcd>
cmpl   $0x1,-0x2c(%rbp)
jne    11f6 <timestamp_find_common+0xc6>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1050 <strdup@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<timestamp_find_common>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rcx,%r14
mov    %rdx,%rbp
mov    %rsi,%r15
mov    %rdi,%rbx
mov    (%rdi),%rdi
lea    0xc(%rsp),%rdx
mov    %rbp,%rsi
xor    %ecx,%ecx
call   1040 <timestamp_compare@plt>
mov    $0xffffffff,%r12d
test   %rax,%rax
js     11b3 <timestamp_find_common+0x83>
cmpl   $0xffffffff,0xc(%rsp)
jne    117f <timestamp_find_common+0x4f>
mov    (%rbx),%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
call   1050 <strdup@plt>
mov    %rax,(%rbx)
mov    (%r15),%rdi
lea    0xc(%rsp),%rdx
mov    %r14,%rsi
xor    %ecx,%ecx
call   1040 <timestamp_compare@plt>
test   %rax,%rax
js     11b3 <timestamp_find_common+0x83>
cmpl   $0x1,0xc(%rsp)
jne    11b0 <timestamp_find_common+0x80>
mov    (%r15),%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1050 <strdup@plt>
mov    %rax,(%r15)
xor    %r12d,%r12d
mov    %r12d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @timestamp_find_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** %11
%13 = load i8*, i8** %8
%14 = call i64 @timestamp_compare(i8* %12, i8* %13, i32* %10, i32* null)
%15 = icmp slt i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %4
store i32 -1, i32* %5
br label %45
17: ; preds = %4
%18 = load i32, i32* %10
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %27
20: ; preds = %17
%21 = load i8**, i8*** %6
%22 = load i8*, i8** %21
%23 = call i32 @free(i8* %22)
%24 = load i8*, i8** %8
%25 = call i8* @strdup(i8* %24)
%26 = load i8**, i8*** %6
store i8* %25, i8** %26
br label %27
27: ; preds = %20, %17
%28 = load i8**, i8*** %7
%29 = load i8*, i8** %28
%30 = load i8*, i8** %9
%31 = call i64 @timestamp_compare(i8* %29, i8* %30, i32* %10, i32* null)
%32 = icmp slt i64 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %27
store i32 -1, i32* %5
br label %45
34: ; preds = %27
%35 = load i32, i32* %10
%36 = icmp eq i32 %35, 1
br i1 %36, label %37, label %44
37: ; preds = %34
%38 = load i8**, i8*** %7
%39 = load i8*, i8** %38
%40 = call i32 @free(i8* %39)
%41 = load i8*, i8** %9
%42 = call i8* @strdup(i8* %41)
%43 = load i8**, i8*** %7
store i8* %42, i8** %43
br label %44
44: ; preds = %37, %34
store i32 0, i32* %5
br label %45
45: ; preds = %44, %33, %16
%46 = load i32, i32* %5
ret i32 %46
}

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