#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 */
size_t strlen(char const *);
scalar_t__ strncmp(char const *, char *, size_t);
int endsWithPac(const char *str) {
  if (!str)
    return 0;
  size_t lenstr = strlen(str);
  size_t lensuffix = strlen(".pac");
  if (lensuffix > lenstr)
    return 0;
  return strncmp(str + lenstr - lensuffix, ".pac", lensuffix) == 0;
}


x86 assembly (clang, -O0):
<endsWithPac>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1143 <endsWithPac+0x23>
movl   $0x0,-0x4(%rbp)
jmp    11a2 <endsWithPac+0x82>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x18(%rbp)
movq   $0x4,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jbe    1172 <endsWithPac+0x52>
movl   $0x0,-0x4(%rbp)
jmp    11a2 <endsWithPac+0x82>
mov    -0x10(%rbp),%rdi
add    -0x18(%rbp),%rdi
xor    %eax,%eax
sub    -0x20(%rbp),%rax
add    %rax,%rdi
mov    -0x20(%rbp),%rdx
lea    0xe72(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<endsWithPac>:
push   %rbp
push   %rbx
push   %rax
xor    %ebp,%ebp
test   %rdi,%rdi
je     115a <endsWithPac+0x3a>
mov    %rdi,%rbx
call   1040 <strlen@plt>
cmp    $0x4,%rax
jb     115a <endsWithPac+0x3a>
lea    (%rbx,%rax,1),%rdi
add    $0xfffffffffffffffc,%rdi
lea    0xeb9(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
sete   %bpl
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c".pac\00"
define i32 @endsWithPac(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = icmp ne i8* %6, null
br i1 %7, label %9, label %8
8: ; preds = %1
store i32 0, i32* %2
br label %27
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = call i64 @strlen(i8* %10)
store i64 %11, i64* %4
store i64 4, i64* %5
%12 = load i64, i64* %5
%13 = load i64, i64* %4
%14 = icmp ugt i64 %12, %13
br i1 %14, label %15, label %16
15: ; preds = %9
store i32 0, i32* %2
br label %27
16: ; preds = %9
%17 = load i8*, i8** %3
%18 = load i64, i64* %4
%19 = getelementptr inbounds i8, i8* %17, i64 %18
%20 = load i64, i64* %5
%21 = sub i64 0, %20
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = load i64, i64* %5
%24 = call i64 @strncmp(i8* %22, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 %23)
%25 = icmp eq i64 %24, 0
%26 = zext i1 %25 to i32
store i32 %26, i32* %2
br label %27
27: ; preds = %16, %15, %8
%28 = load i32, i32* %2
ret i32 %28
}

LLVM IR (-O2):
@.str = [5 x i8] c".pac\00"
define i32 @endsWithPac(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %12, label %3
3: ; preds = %1
%4 = tail call i64 @strlen(i8* %0)
%5 = icmp ult i64 %4, 4
br i1 %5, label %12, label %6
6: ; preds = %3
%7 = getelementptr inbounds i8, i8* %0, i64 %4
%8 = getelementptr inbounds i8, i8* %7, i64 -4
%9 = tail call i64 @strncmp(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 4)
%10 = icmp eq i64 %9, 0
%11 = zext i1 %10 to i32
br label %12
12: ; preds = %6, %3, %1
%13 = phi i32 [ 0, %1 ], [ %11, %6 ], [ 0, %3 ]
ret i32 %13
}