#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 */
unsigned int strlen(char *);
int strmatch(char *strfirst, char *strsecond) {
  unsigned int strfirst_len = strlen(strfirst);
  unsigned int strsecond_len = strlen(strsecond);
  if (strfirst_len != strsecond_len)
    return 0;
  unsigned int ii = 0;
  for (ii = 0; ii <= strfirst_len; ii++)
    if (strfirst[ii] != strsecond[ii])
      return 0;
  return 1;
}


x86 assembly (clang, -O0):
<strmatch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%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
je     1150 <strmatch+0x40>
movl   $0x0,-0x4(%rbp)
jmp    11ae <strmatch+0x9e>
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
ja     11a7 <strmatch+0x97>
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
mov    -0x18(%rbp),%rcx
mov    -0x24(%rbp),%edx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
je     1194 <strmatch+0x84>
movl   $0x0,-0x4(%rbp)
jmp    11ae <strmatch+0x9e>
jmp    1199 <strmatch+0x89>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    115e <strmatch+0x4e>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strmatch>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    %ecx,%ebp
jne    1159 <strmatch+0x49>
xor    %eax,%eax
xor    %ecx,%ecx
nopl   0x0(%rax,%rax,1)
mov    %ecx,%edx
movzbl (%r15,%rdx,1),%ebx
cmp    (%r14,%rdx,1),%bl
jne    1159 <strmatch+0x49>
add    $0x1,%ecx
cmp    %ebp,%ecx
jbe    1140 <strmatch+0x30>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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