#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 strcmp(char const *, char const *);
int strncmp(char const *, char const *, int);
int dmyhms_datecmp(const char *a, const char *b) {
  int cmp;
  cmp = strncmp(a + 6, b + 6, 4);
  if (cmp)
    return cmp;
  cmp = strncmp(a + 3, b + 3, 2);
  if (cmp)
    return cmp;
  return strcmp(a, b);
}


x86 assembly (clang, -O0):
<dmyhms_datecmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
add    $0x6,%rdi
mov    -0x18(%rbp),%rsi
add    $0x6,%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1162 <dmyhms_datecmp+0x42>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11a4 <dmyhms_datecmp+0x84>
mov    -0x10(%rbp),%rdi
add    $0x3,%rdi
mov    -0x18(%rbp),%rsi
add    $0x3,%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1194 <dmyhms_datecmp+0x74>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11a4 <dmyhms_datecmp+0x84>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcmp@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dmyhms_datecmp>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
add    $0x6,%rdi
add    $0x6,%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    1156 <dmyhms_datecmp+0x36>
lea    0x3(%rbx),%rdi
lea    0x3(%r14),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     115e <dmyhms_datecmp+0x3e>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <strcmp@plt>

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

LLVM IR (-O2):
define i32 @dmyhms_datecmp(i8* %0, i8* %1) {
%3 = getelementptr inbounds i8, i8* %0, i64 6
%4 = getelementptr inbounds i8, i8* %1, i64 6
%5 = tail call i32 @strncmp(i8* %3, i8* %4, i32 4)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %14
7: ; preds = %2
%8 = getelementptr inbounds i8, i8* %0, i64 3
%9 = getelementptr inbounds i8, i8* %1, i64 3
%10 = tail call i32 @strncmp(i8* %8, i8* %9, i32 2)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(1) %1)
br label %14
14: ; preds = %7, %2, %12
%15 = phi i32 [ %13, %12 ], [ %5, %2 ], [ %10, %7 ]
ret i32 %15
}