#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*/ assert(char *);
int my_strcmp(const char *szA, const char *szB) {
  char *pcA = (char *)szA, *pcB = (char *)szB;
  int iRet = -1;
  assert(pcA);
  assert(pcB);
  while (*pcA == *pcB) {
    if (*pcA == '\0') {
      iRet = 0;
      break;
    }
    ++pcA;
    ++pcB;
  }
  return iRet;
}


x86 assembly (clang, -O0):
<my_strcmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0xffffffff,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <assert@plt>
mov    -0x20(%rbp),%rdi
call   1030 <assert@plt>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
mov    -0x20(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    1198 <my_strcmp+0x88>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    117b <my_strcmp+0x6b>
movl   $0x0,-0x24(%rbp)
jmp    1198 <my_strcmp+0x88>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1149 <my_strcmp+0x39>
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_strcmp>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <assert@plt>
mov    %r14,%rdi
call   1030 <assert@plt>
mov    (%rbx),%cl
mov    $0xffffffff,%eax
cmp    (%r14),%cl
jne    1159 <my_strcmp+0x49>
mov    $0x1,%edx
nopl   0x0(%rax,%rax,1)
test   %cl,%cl
je     1157 <my_strcmp+0x47>
movzbl (%rbx,%rdx,1),%ecx
lea    0x1(%rdx),%rsi
cmp    (%r14,%rdx,1),%cl
mov    %rsi,%rdx
je     1140 <my_strcmp+0x30>
jmp    1159 <my_strcmp+0x49>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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