#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*/ interceptor_increaseBy(int);
__attribute__((optimize("0"))) int strcmp(const char *s1, const char *s2) {
  for (size_t i = 0; s1[i] || s2[i]; i++) {
    if (s1[i] != s2[i]) {
      return (s1[i] - s2[i]);
    }
    interceptor_increaseBy(1);
  }
  interceptor_increaseBy(5);
  return 0;
}


x86 assembly (clang, -O0):
<strcmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
mov    $0x1,%al
cmp    $0x0,%ecx
mov    %al,-0x21(%rbp)
jne    1157 <strcmp+0x47>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1167 <strcmp+0x57>
jmp    11c4 <strcmp+0xb4>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
je     11a9 <strcmp+0x99>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    11d5 <strcmp+0xc5>
mov    $0x1,%edi
call   1030 <interceptor_increaseBy@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1128 <strcmp+0x18>
mov    $0x5,%edi
call   1030 <interceptor_increaseBy@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strcmp>:
push   %r15
push   %r14
push   %rbx
mov    (%rdi),%al
mov    (%rsi),%cl
mov    %eax,%edx
or     %cl,%dl
je     1152 <strcmp+0x42>
mov    %rsi,%r14
mov    %rdi,%r15
mov    $0x1,%ebx
nopw   0x0(%rax,%rax,1)
cmp    %cl,%al
jne    1160 <strcmp+0x50>
mov    $0x1,%edi
call   1030 <interceptor_increaseBy@plt>
movzbl (%r15,%rbx,1),%eax
movzbl (%r14,%rbx,1),%ecx
add    $0x1,%rbx
mov    %eax,%edx
or     %cl,%dl
jne    1130 <strcmp+0x20>
mov    $0x5,%edi
call   1030 <interceptor_increaseBy@plt>
xor    %eax,%eax
jmp    1168 <strcmp+0x58>
movsbl %cl,%ecx
movsbl %al,%eax
sub    %ecx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @strcmp(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
store i8* %0, i8** %4
store i8* %1, i8** %5
store i64 0, i64* %6
br label %7
7: ; preds = %49, %2
%8 = load i8*, i8** %4
%9 = load i64, i64* %6
%10 = getelementptr inbounds i8, i8* %8, i64 %9
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 0
br i1 %13, label %21, label %14
14: ; preds = %7
%15 = load i8*, i8** %5
%16 = load i64, i64* %6
%17 = getelementptr inbounds i8, i8* %15, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %19, 0
br label %21
21: ; preds = %14, %7
%22 = phi i1 [ true, %7 ], [ %20, %14 ]
br i1 %22, label %23, label %52
23: ; preds = %21
%24 = load i8*, i8** %4
%25 = load i64, i64* %6
%26 = getelementptr inbounds i8, i8* %24, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = load i8*, i8** %5
%30 = load i64, i64* %6
%31 = getelementptr inbounds i8, i8* %29, i64 %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp ne i32 %28, %33
br i1 %34, label %35, label %47
35: ; preds = %23
%36 = load i8*, i8** %4
%37 = load i64, i64* %6
%38 = getelementptr inbounds i8, i8* %36, i64 %37
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = load i8*, i8** %5
%42 = load i64, i64* %6
%43 = getelementptr inbounds i8, i8* %41, i64 %42
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = sub nsw i32 %40, %45
store i32 %46, i32* %3
br label %54
47: ; preds = %23
%48 = call i32 @interceptor_increaseBy(i32 1)
br label %49
49: ; preds = %47
%50 = load i64, i64* %6
%51 = add i64 %50, 1
store i64 %51, i64* %6
br label %7
52: ; preds = %21
%53 = call i32 @interceptor_increaseBy(i32 5)
store i32 0, i32* %3
br label %54
54: ; preds = %52, %35
%55 = load i32, i32* %3
ret i32 %55
}

LLVM IR (-O2):
define i32 @strcmp(i8* nocapture %0, i8* nocapture %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
%5 = load i8, i8* %1
%6 = icmp eq i8 %5, 0
%7 = select i1 %4, i1 %6, i1 false
br i1 %7, label %27, label %8
8: ; preds = %2, %13
%9 = phi i8 [ %20, %13 ], [ %5, %2 ]
%10 = phi i8 [ %17, %13 ], [ %3, %2 ]
%11 = phi i64 [ %15, %13 ], [ 0, %2 ]
%12 = icmp eq i8 %10, %9
br i1 %12, label %13, label %23
13: ; preds = %8
%14 = tail call i32 @interceptor_increaseBy(i32 1)
%15 = add i64 %11, 1
%16 = getelementptr inbounds i8, i8* %0, i64 %15
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 0
%19 = getelementptr inbounds i8, i8* %1, i64 %15
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 0
%22 = select i1 %18, i1 %21, i1 false
br i1 %22, label %27, label %8
23: ; preds = %8
%24 = sext i8 %9 to i32
%25 = sext i8 %10 to i32
%26 = sub nsw i32 %25, %24
br label %29
27: ; preds = %13, %2
%28 = tail call i32 @interceptor_increaseBy(i32 5)
br label %29
29: ; preds = %23, %27
%30 = phi i32 [ %26, %23 ], [ 0, %27 ]
ret i32 %30
}