#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 */
scalar_t__ strlen(char *);
unsigned int _starts_with(char *str, char *n) {
  int i;
  if (strlen(n) > strlen(str))
    return 0;
  for (i = 0; *(n + i) != '\0'; i++)
    if (*(n + i) != *(str + i))
      return 0;
  return 1;
}


x86 assembly (clang, -O0):
<_starts_with>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
jle    1152 <_starts_with+0x42>
movl   $0x0,-0x4(%rbp)
jmp    11b4 <_starts_with+0xa4>
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11ad <_starts_with+0x9d>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x10(%rbp),%rcx
movslq -0x1c(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
je     119a <_starts_with+0x8a>
movl   $0x0,-0x4(%rbp)
jmp    11b4 <_starts_with+0xa4>
jmp    119f <_starts_with+0x8f>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1159 <_starts_with+0x49>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_starts_with>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1030 <strlen@plt>
mov    %rax,%r15
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%r15
jg     1167 <_starts_with+0x57>
mov    (%rbx),%cl
mov    $0x1,%eax
test   %cl,%cl
je     1167 <_starts_with+0x57>
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nop
cmp    (%r14,%rdx,1),%cl
jne    1165 <_starts_with+0x55>
movzbl 0x1(%rbx,%rdx,1),%ecx
add    $0x1,%rdx
test   %cl,%cl
jne    1150 <_starts_with+0x40>
jmp    1167 <_starts_with+0x57>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @_starts_with(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %5
%8 = call i64 @strlen(i8* %7)
%9 = load i8*, i8** %4
%10 = call i64 @strlen(i8* %9)
%11 = icmp sgt i64 %8, %10
br i1 %11, label %12, label %13
12: ; preds = %2
store i32 0, i32* %3
br label %42
13: ; preds = %2
store i32 0, i32* %6
br label %14
14: ; preds = %38, %13
%15 = load i8*, i8** %5
%16 = load i32, i32* %6
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %41
22: ; preds = %14
%23 = load i8*, i8** %5
%24 = load i32, i32* %6
%25 = sext 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** %4
%30 = load i32, i32* %6
%31 = sext 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* %6
%40 = add nsw i32 %39, 1
store i32 %40, i32* %6
br label %14
41: ; preds = %14
store i32 1, i32* %3
br label %42
42: ; preds = %41, %36, %12
%43 = load i32, i32* %3
ret i32 %43
}

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