#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*/ die(char *);
int /*<<< orphan*/ hexprint(char *, char const *);
scalar_t__ strcmp(char *, char const *);
int check_order(const char *key, void *value, void *arg) {
  char **prev = arg;
  if (*prev && strcmp(*prev, key) >= 0) {
    hexprint("first:", *prev);
    hexprint("second:", key);
    die("FAIL: keys not ordered");
  }
  *prev = value;
  return 0;
}


x86 assembly (clang, -O0):
<check_order>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
je     11a3 <check_order+0x73>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jl     11a3 <check_order+0x73>
mov    -0x20(%rbp),%rax
mov    (%rax),%rsi
lea    0xe7e(%rip),%rdi
call   1030 <hexprint@plt>
mov    -0x8(%rbp),%rsi
lea    0xe75(%rip),%rdi
call   1030 <hexprint@plt>
lea    0xe71(%rip),%rdi
call   1050 <die@plt>
mov    -0x10(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_order>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    (%rdx),%rdi
test   %rdi,%rdi
je     117d <check_order+0x4d>
mov    %r15,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
js     117d <check_order+0x4d>
mov    (%rbx),%rsi
lea    0xea3(%rip),%rdi
call   1030 <hexprint@plt>
lea    0xe9e(%rip),%rdi
mov    %r15,%rsi
call   1030 <hexprint@plt>
lea    0xe97(%rip),%rdi
call   1050 <die@plt>
mov    %r14,(%rbx)
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c"first:\00"
@.str.1 = [8 x i8] c"second:\00"
@.str.2 = [23 x i8] c"FAIL: keys not ordered\00"
define i32 @check_order(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8**
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%8 = load i8*, i8** %6
%9 = bitcast i8* %8 to i8**
store i8** %9, i8*** %7
%10 = load i8**, i8*** %7
%11 = load i8*, i8** %10
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %26
13: ; preds = %3
%14 = load i8**, i8*** %7
%15 = load i8*, i8** %14
%16 = load i8*, i8** %4
%17 = call i64 @strcmp(i8* %15, i8* %16)
%18 = icmp sge i64 %17, 0
br i1 %18, label %19, label %26
19: ; preds = %13
%20 = load i8**, i8*** %7
%21 = load i8*, i8** %20
%22 = call i32 @hexprint(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %21)
%23 = load i8*, i8** %4
%24 = call i32 @hexprint(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %23)
%25 = call i32 @die(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
br label %26
26: ; preds = %19, %13, %3
%27 = load i8*, i8** %5
%28 = load i8**, i8*** %7
store i8* %27, i8** %28
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"first:\00"
@.str.1 = [8 x i8] c"second:\00"
@.str.2 = [23 x i8] c"FAIL: keys not ordered\00"
define i32 @check_order(i8* %0, i8* %1, i8* nocapture %2) {
%4 = bitcast i8* %2 to i8**
%5 = load i8*, i8** %4
%6 = icmp eq i8* %5, null
br i1 %6, label %15, label %7
7: ; preds = %3
%8 = tail call i64 @strcmp(i8* %5, i8* %0)
%9 = icmp sgt i64 %8, -1
br i1 %9, label %10, label %15
10: ; preds = %7
%11 = load i8*, i8** %4
%12 = tail call i32 @hexprint(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = tail call i32 @hexprint(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%14 = tail call i32 @die(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
br label %15
15: ; preds = %10, %7, %3
store i8* %1, i8** %4
ret i32 0
}