#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 strlen(unsigned char *);
int compare_top_str2(unsigned char *s1, unsigned char *s2) {
  int l1, l2;
  l1 = strlen(s1);
  l2 = strlen(s2);
  if (l1 < l2)
    return ((int)(0));
  while (l2--)
    if (s1[l2] != s2[l2])
      return ((int)(0));
  return (!(((int)(0))));
}


x86 assembly (clang, -O0):
<compare_top_str2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1150 <compare_top_str2+0x40>
movl   $0x0,-0x4(%rbp)
jmp    11a1 <compare_top_str2+0x91>
jmp    1155 <compare_top_str2+0x45>
mov    -0x20(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x20(%rbp)
cmp    $0x0,%eax
je     119a <compare_top_str2+0x8a>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
mov    -0x18(%rbp),%rcx
movslq -0x20(%rbp),%rdx
movzbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
je     1195 <compare_top_str2+0x85>
movl   $0x0,-0x4(%rbp)
jmp    11a1 <compare_top_str2+0x91>
jmp    1155 <compare_top_str2+0x45>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compare_top_str2>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbp
call   1030 <strlen@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    %ecx,%ebx
jl     115c <compare_top_str2+0x4c>
movslq %ecx,%rcx
mov    %rcx,%rdx
nopw   0x0(%rax,%rax,1)
sub    $0x1,%rdx
jb     1157 <compare_top_str2+0x47>
movzbl -0x1(%rbp,%rcx,1),%ebx
cmp    -0x1(%r14,%rcx,1),%bl
mov    %rdx,%rcx
je     1140 <compare_top_str2+0x30>
jmp    115c <compare_top_str2+0x4c>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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