#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*/ Debugprintf(char *, ...);
int tolower(unsigned char);
int stricmp(const unsigned char *pStr1, const unsigned char *pStr2) {
  unsigned char c1, c2;
  int v;
  if (pStr1 == NULL) {
    if (pStr2)
      Debugprintf("stricmp called with NULL 1st param - 2nd %s ", pStr2);
    else
      Debugprintf("stricmp called with two NULL params");
    return 1;
  }
  do {
    c1 = *pStr1++;
    c2 = *pStr2++;
    v = tolower(c1) - tolower(c2);
  } while ((v == 0) && (c1 != '\0') && (c2 != '\0'));
  return v;
}


x86 assembly (clang, -O0):
<stricmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1177 <stricmp+0x57>
cmpq   $0x0,-0x18(%rbp)
je     115d <stricmp+0x3d>
mov    -0x18(%rbp),%rsi
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1030 <Debugprintf@plt>
jmp    116b <stricmp+0x4b>
lea    0xec9(%rip),%rdi
mov    $0x0,%al
call   1030 <Debugprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1202 <stricmp+0xe2>
jmp    117c <stricmp+0x5c>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%al
mov    %al,-0x19(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
mov    (%rax),%al
mov    %al,-0x1a(%rbp)
movzbl -0x19(%rbp),%edi
call   1040 <tolower@plt>
mov    %eax,-0x24(%rbp)
movzbl -0x1a(%rbp),%edi
call   1040 <tolower@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x20(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x20(%rbp)
mov    %al,-0x25(%rbp)
jne    11f1 <stricmp+0xd1>
movzbl -0x19(%rbp),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x25(%rbp)
je     11f1 <stricmp+0xd1>
movzbl -0x1a(%rbp),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
test   $0x1,%al
jne    117c <stricmp+0x5c>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stricmp>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
test   %rdi,%rdi
je     1173 <stricmp+0x53>
mov    %rdi,%r15
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movzbl (%r15,%rbx,1),%r12d
movzbl (%r14,%rbx,1),%r13d
mov    %r12d,%edi
call   1040 <tolower@plt>
mov    %eax,%ebp
movzbl %r13b,%edi
call   1040 <tolower@plt>
sub    %eax,%ebp
test   %r12d,%r12d
je     119e <stricmp+0x7e>
test   %ebp,%ebp
jne    119e <stricmp+0x7e>
add    $0x1,%rbx
test   %r13b,%r13b
jne    1140 <stricmp+0x20>
jmp    119e <stricmp+0x7e>
test   %r14,%r14
je     118b <stricmp+0x6b>
lea    0xe81(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <Debugprintf@plt>
jmp    1199 <stricmp+0x79>
lea    0xe9b(%rip),%rdi
xor    %eax,%eax
call   1030 <Debugprintf@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [45 x i8] c"stricmp called with NULL 1st param - 2nd %s \00"
@.str.1 = [36 x i8] c"stricmp called with two NULL params\00"
define i32 @stricmp(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8
%7 = alloca i8
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%9 = load i8*, i8** %4
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %20
11: ; preds = %2
%12 = load i8*, i8** %5
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = load i8*, i8** %5
%16 = call i32 (i8*, ...) @Debugprintf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i8* %15)
br label %19
17: ; preds = %11
%18 = call i32 (i8*, ...) @Debugprintf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
br label %19
19: ; preds = %17, %14
store i32 1, i32* %3
br label %48
20: ; preds = %2
br label %21
21: ; preds = %44, %20
%22 = load i8*, i8** %4
%23 = getelementptr inbounds i8, i8* %22, i32 1
store i8* %23, i8** %4
%24 = load i8, i8* %22
store i8 %24, i8* %6
%25 = load i8*, i8** %5
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %5
%27 = load i8, i8* %25
store i8 %27, i8* %7
%28 = load i8, i8* %6
%29 = call i32 @tolower(i8 zeroext %28)
%30 = load i8, i8* %7
%31 = call i32 @tolower(i8 zeroext %30)
%32 = sub nsw i32 %29, %31
store i32 %32, i32* %8
br label %33
33: ; preds = %21
%34 = load i32, i32* %8
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %44
36: ; preds = %33
%37 = load i8, i8* %6
%38 = zext i8 %37 to i32
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %44
40: ; preds = %36
%41 = load i8, i8* %7
%42 = zext i8 %41 to i32
%43 = icmp ne i32 %42, 0
br label %44
44: ; preds = %40, %36, %33
%45 = phi i1 [ false, %36 ], [ false, %33 ], [ %43, %40 ]
br i1 %45, label %21, label %46
46: ; preds = %44
%47 = load i32, i32* %8
store i32 %47, i32* %3
br label %48
48: ; preds = %46, %19
%49 = load i32, i32* %3
ret i32 %49
}

LLVM IR (-O2):
@.str = [45 x i8] c"stricmp called with NULL 1st param - 2nd %s \00"
@.str.1 = [36 x i8] c"stricmp called with two NULL params\00"
define i32 @stricmp(i8* %0, i8* %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %4, label %10
4: ; preds = %2
%5 = icmp eq i8* %1, null
br i1 %5, label %8, label %6
6: ; preds = %4
%7 = tail call i32 (i8*, ...) @Debugprintf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i8* %1)
br label %25
8: ; preds = %4
%9 = tail call i32 (i8*, ...) @Debugprintf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
br label %25
10: ; preds = %2, %10
%11 = phi i8* [ %15, %10 ], [ %1, %2 ]
%12 = phi i8* [ %13, %10 ], [ %0, %2 ]
%13 = getelementptr inbounds i8, i8* %12, i64 1
%14 = load i8, i8* %12
%15 = getelementptr inbounds i8, i8* %11, i64 1
%16 = load i8, i8* %11
%17 = tail call i32 @tolower(i8 zeroext %14)
%18 = tail call i32 @tolower(i8 zeroext %16)
%19 = sub nsw i32 %17, %18
%20 = icmp eq i32 %19, 0
%21 = icmp ne i8 %14, 0
%22 = and i1 %21, %20
%23 = icmp ne i8 %16, 0
%24 = select i1 %22, i1 %23, i1 false
br i1 %24, label %10, label %25
25: ; preds = %10, %6, %8
%26 = phi i32 [ 1, %8 ], [ 1, %6 ], [ %19, %10 ]
ret i32 %26
}