#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(char *);
int strcmpFrom(char *s1, char *s2, int index) {
  if (strlen(s1) < index || strlen(s2) < index) {
    return 1;
  }
  for (int i = 0; i < index; i++) {
    if (s1[i] != s2[i])
      return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<strcmpFrom>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    -0x1c(%rbp),%eax
jl     1147 <strcmpFrom+0x37>
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
cmp    -0x1c(%rbp),%eax
jge    1153 <strcmpFrom+0x43>
movl   $0x1,-0x4(%rbp)
jmp    11ac <strcmpFrom+0x9c>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11a5 <strcmpFrom+0x95>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x18(%rbp),%rcx
movslq -0x20(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
je     1192 <strcmpFrom+0x82>
movl   $0x1,-0x4(%rbp)
jmp    11ac <strcmpFrom+0x9c>
jmp    1197 <strcmpFrom+0x87>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    115a <strcmpFrom+0x4a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strcmpFrom>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    $0x1,%r15d
cmp    %ebp,%eax
jl     1175 <strcmpFrom+0x65>
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    %ebp,%eax
jl     1175 <strcmpFrom+0x65>
test   %ebp,%ebp
jle    1172 <strcmpFrom+0x62>
mov    (%rbx),%al
cmp    (%r14),%al
jne    1175 <strcmpFrom+0x65>
mov    %ebp,%esi
mov    $0x1,%edx
nopl   0x0(%rax)
mov    %rdx,%rcx
cmp    %rdx,%rsi
je     1166 <strcmpFrom+0x56>
movzbl (%rbx,%rcx,1),%eax
lea    0x1(%rcx),%rdx
cmp    (%r14,%rcx,1),%al
je     1150 <strcmpFrom+0x40>
xor    %r15d,%r15d
cmp    %rsi,%rcx
setb   %r15b
jmp    1175 <strcmpFrom+0x65>
xor    %r15d,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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