#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 strcasecmp(char *, char *);
int strcmp_withnull(char *one, char *two) {
  if (one == NULL && two == NULL) {
    return 0;
  }
  if (one != NULL && two == NULL) {
    return -1;
  }
  if (one == NULL) {
    return 1;
  }
  return strcasecmp(one, two);
}


x86 assembly (clang, -O0):
<strcmp_withnull>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1142 <strcmp_withnull+0x32>
cmpq   $0x0,-0x18(%rbp)
jne    1142 <strcmp_withnull+0x32>
movl   $0x0,-0x4(%rbp)
jmp    118b <strcmp_withnull+0x7b>
cmpq   $0x0,-0x10(%rbp)
je     1164 <strcmp_withnull+0x54>
cmpq   $0x0,-0x18(%rbp)
jne    1164 <strcmp_withnull+0x54>
movl   $0xffffffff,-0x4(%rbp)
jmp    118b <strcmp_withnull+0x7b>
cmpq   $0x0,-0x10(%rbp)
jne    117b <strcmp_withnull+0x6b>
movl   $0x1,-0x4(%rbp)
jmp    118b <strcmp_withnull+0x7b>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcasecmp@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strcmp_withnull>:
xor    %eax,%eax
mov    %rdi,%rcx
or     %rsi,%rcx
je     113a <strcmp_withnull+0x2a>
cmp    $0x1,%rsi
sbb    %ecx,%ecx
or     $0x1,%ecx
mov    $0x1,%eax
test   %rdi,%rdi
cmovne %ecx,%eax
je     113a <strcmp_withnull+0x2a>
test   %rsi,%rsi
je     113a <strcmp_withnull+0x2a>
jmp    1030 <strcasecmp@plt>
ret

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

LLVM IR (-O2):
define i32 @strcmp_withnull(i8* %0, i8* %1) {
%3 = icmp eq i8* %0, null
%4 = icmp eq i8* %1, null
%5 = and i1 %3, %4
br i1 %5, label %13, label %6
6: ; preds = %2
%7 = icmp ne i8* %0, null
%8 = and i1 %7, %4
%9 = or i1 %3, %4
%10 = select i1 %8, i32 -1, i32 1
br i1 %9, label %13, label %11
11: ; preds = %6
%12 = tail call i32 @strcasecmp(i8* %0, i8* %1)
br label %13
13: ; preds = %6, %2, %11
%14 = phi i32 [ %12, %11 ], [ 0, %2 ], [ %10, %6 ]
ret i32 %14
}