#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*/ __tokencap_dump(char const *, int /*<<< orphan*/, int);
scalar_t__ __tokencap_is_ro(char const *);
int /*<<< orphan*/ strlen(char const *);
int strcmp(const char *str1, const char *str2) {
  if (__tokencap_is_ro(str1))
    __tokencap_dump(str1, strlen(str1), 1);
  if (__tokencap_is_ro(str2))
    __tokencap_dump(str2, strlen(str2), 1);
  while (1) {
    unsigned char c1 = *str1, c2 = *str2;
    if (c1 != c2)
      return (c1 > c2) ? 1 : -1;
    if (!c1)
      return 0;
    str1++;
    str2++;
  }
}


x86 assembly (clang, -O0):
<strcmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <__tokencap_is_ro@plt>
cmp    $0x0,%rax
je     1174 <strcmp+0x44>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%esi
mov    $0x1,%edx
call   1030 <__tokencap_dump@plt>
mov    -0x18(%rbp),%rdi
call   1050 <__tokencap_is_ro@plt>
cmp    $0x0,%rax
je     11a8 <strcmp+0x78>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    %eax,%esi
mov    $0x1,%edx
call   1030 <__tokencap_dump@plt>
jmp    11ad <strcmp+0x7d>
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x19(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x1a(%rbp)
movzbl -0x19(%rbp),%eax
movzbl -0x1a(%rbp),%ecx
cmp    %ecx,%eax
je     11ee <strcmp+0xbe>
movzbl -0x19(%rbp),%edx
movzbl -0x1a(%rbp),%esi
mov    $0xffffffff,%eax
mov    $0x1,%ecx
cmp    %esi,%edx
cmovg  %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    1221 <strcmp+0xf1>
cmpb   $0x0,-0x19(%rbp)
jne    1204 <strcmp+0xd4>
movl   $0x0,-0x4(%rbp)
jmp    1221 <strcmp+0xf1>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11ad <strcmp+0x7d>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strcmp>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1050 <__tokencap_is_ro@plt>
test   %rax,%rax
je     115b <strcmp+0x2b>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x1,%edx
call   1030 <__tokencap_dump@plt>
mov    %r14,%rdi
call   1050 <__tokencap_is_ro@plt>
test   %rax,%rax
je     117f <strcmp+0x4f>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %r14,%rdi
mov    %eax,%esi
mov    $0x1,%edx
call   1030 <__tokencap_dump@plt>
mov    (%rbx),%al
mov    (%r14),%cl
cmp    %cl,%al
jne    11a5 <strcmp+0x75>
mov    $0x1,%edx
nopl   (%rax)
test   %al,%al
je     11b4 <strcmp+0x84>
movzbl (%rbx,%rdx,1),%eax
movzbl (%r14,%rdx,1),%ecx
add    $0x1,%rdx
cmp    %cl,%al
je     1190 <strcmp+0x60>
xor    %edx,%edx
cmp    %cl,%al
seta   %dl
lea    (%rdx,%rdx,1),%eax
add    $0xffffffff,%eax
jmp    11b6 <strcmp+0x86>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i32 @strcmp(i8* %0, i8* %1) {
%3 = tail call i64 @__tokencap_is_ro(i8* %0)
%4 = icmp eq i64 %3, 0
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = tail call i32 @strlen(i8* %0)
%7 = tail call i32 @__tokencap_dump(i8* %0, i32 %6, i32 1)
br label %8
8: ; preds = %5, %2
%9 = tail call i64 @__tokencap_is_ro(i8* %1)
%10 = icmp eq i64 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %8
%12 = tail call i32 @strlen(i8* %1)
%13 = tail call i32 @__tokencap_dump(i8* %1, i32 %12, i32 1)
br label %14
14: ; preds = %11, %8
%15 = load i8, i8* %0
%16 = load i8, i8* %1
%17 = icmp eq i8 %15, %16
br i1 %17, label %23, label %18
18: ; preds = %28, %14
%19 = phi i8 [ %15, %14 ], [ %31, %28 ]
%20 = phi i8 [ %16, %14 ], [ %32, %28 ]
%21 = icmp ugt i8 %19, %20
%22 = select i1 %21, i32 1, i32 -1
br label %34
23: ; preds = %14, %28
%24 = phi i8 [ %31, %28 ], [ %15, %14 ]
%25 = phi i8* [ %29, %28 ], [ %0, %14 ]
%26 = phi i8* [ %30, %28 ], [ %1, %14 ]
%27 = icmp eq i8 %24, 0
br i1 %27, label %34, label %28
28: ; preds = %23
%29 = getelementptr inbounds i8, i8* %25, i64 1
%30 = getelementptr inbounds i8, i8* %26, i64 1
%31 = load i8, i8* %29
%32 = load i8, i8* %30
%33 = icmp eq i8 %31, %32
br i1 %33, label %23, label %18
34: ; preds = %23, %18
%35 = phi i32 [ %22, %18 ], [ 0, %23 ]
ret i32 %35
}