#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 *);
scalar_t__ tolower(char);
int startsWhith(char *a, char *b) {
  int i, n = 0;
  n = (((strlen(a)) < (strlen(b))) ? (strlen(a)) : (strlen(b)));
  for (i = 0; i < n; i++) {
    if (tolower(a[i]) != tolower(b[i])) {
      return 0;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<startsWhith>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cmp    %ecx,%eax
jge    116a <startsWhith+0x4a>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x28(%rbp)
jmp    1176 <startsWhith+0x56>
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    11e4 <startsWhith+0xc4>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <tolower@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <tolower@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
cmp    %rcx,%rax
je     11d1 <startsWhith+0xb1>
movl   $0x0,-0x4(%rbp)
jmp    11eb <startsWhith+0xcb>
jmp    11d6 <startsWhith+0xb6>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1183 <startsWhith+0x63>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<startsWhith>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r12
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    %eax,%ebp
mov    %r14,%rdi
cmovl  %r12,%rdi
call   1030 <strlen@plt>
mov    $0x1,%r15d
test   %eax,%eax
jle    118a <startsWhith+0x6a>
mov    %eax,%r13d
xor    %ebx,%ebx
nopl   (%rax)
movsbl (%r12,%rbx,1),%edi
call   1040 <tolower@plt>
mov    %rax,%rbp
movsbl (%r14,%rbx,1),%edi
call   1040 <tolower@plt>
cmp    %rax,%rbp
jne    1187 <startsWhith+0x67>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1160 <startsWhith+0x40>
jmp    118a <startsWhith+0x6a>
xor    %r15d,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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