#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 /*<<< orphan*/ assert_log(int, int, char *, int *);
int ends_with(char *, char *);
int test_ends_with(int verbose) {
  int ok = 1;
  assert_log(ends_with("whatever", "ever"), verbose, "ends_with!", &ok);
  assert_log(!ends_with("some", "!me"), verbose, "ends_with", &ok);
  assert_log(ends_with("some/file.o", ".o"), verbose, "ends_with .o", &ok);
  return ok;
}


x86 assembly (clang, -O0):
<test_ends_with>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
lea    0xec7(%rip),%rdi
lea    0xec4(%rip),%rsi
call   1040 <ends_with@plt>
mov    %eax,%edi
mov    -0x4(%rbp),%esi
lea    0xeb8(%rip),%rdx
lea    -0x8(%rbp),%rcx
call   1030 <assert_log@plt>
lea    0xeb3(%rip),%rdi
lea    0xeb1(%rip),%rsi
call   1040 <ends_with@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
mov    -0x4(%rbp),%esi
lea    0xe99(%rip),%rdx
lea    -0x8(%rbp),%rcx
call   1030 <assert_log@plt>
lea    0xe93(%rip),%rdi
lea    0xea2(%rip),%rsi
call   1040 <ends_with@plt>
mov    %eax,%edi
mov    -0x4(%rbp),%esi
lea    0xe87(%rip),%rdx
lea    -0x8(%rbp),%rcx
call   1030 <assert_log@plt>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_ends_with>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
movl   $0x1,0x4(%rsp)
lea    0xecb(%rip),%rdi
lea    0xec8(%rip),%rsi
call   1040 <ends_with@plt>
lea    0xec1(%rip),%rdx
lea    0x4(%rsp),%r14
mov    %eax,%edi
mov    %ebx,%esi
mov    %r14,%rcx
call   1030 <assert_log@plt>
lea    0xeb4(%rip),%rdi
lea    0xeb2(%rip),%rsi
call   1040 <ends_with@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
lea    0xea2(%rip),%rdx
mov    %ebx,%esi
mov    %r14,%rcx
call   1030 <assert_log@plt>
lea    0xe9b(%rip),%rdi
lea    0xeaa(%rip),%rsi
call   1040 <ends_with@plt>
lea    0xe94(%rip),%rdx
mov    %eax,%edi
mov    %ebx,%esi
mov    %r14,%rcx
call   1030 <assert_log@plt>
mov    0x4(%rsp),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [9 x i8] c"whatever\00"
@.str.1 = [5 x i8] c"ever\00"
@.str.2 = [11 x i8] c"ends_with!\00"
@.str.3 = [5 x i8] c"some\00"
@.str.4 = [4 x i8] c"!me\00"
@.str.5 = [10 x i8] c"ends_with\00"
@.str.6 = [12 x i8] c"some/file.o\00"
@.str.7 = [3 x i8] c".o\00"
@.str.8 = [13 x i8] c"ends_with .o\00"
define i32 @test_ends_with(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 1, i32* %3
%4 = call i32 @ends_with(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%5 = load i32, i32* %2
%6 = call i32 @assert_log(i32 %4, i32 %5, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%7 = call i32 @ends_with(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%8 = icmp ne i32 %7, 0
%9 = xor i1 %8, true
%10 = zext i1 %9 to i32
%11 = load i32, i32* %2
%12 = call i32 @assert_log(i32 %10, i32 %11, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32* %3)
%13 = call i32 @ends_with(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%14 = load i32, i32* %2
%15 = call i32 @assert_log(i32 %13, i32 %14, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i32* %3)
%16 = load i32, i32* %3
ret i32 %16
}

LLVM IR (-O2):
@.str = [9 x i8] c"whatever\00"
@.str.1 = [5 x i8] c"ever\00"
@.str.2 = [11 x i8] c"ends_with!\00"
@.str.3 = [5 x i8] c"some\00"
@.str.4 = [4 x i8] c"!me\00"
@.str.5 = [10 x i8] c"ends_with\00"
@.str.6 = [12 x i8] c"some/file.o\00"
@.str.7 = [3 x i8] c".o\00"
@.str.8 = [13 x i8] c"ends_with .o\00"
define i32 @test_ends_with(i32 %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
store i32 1, i32* %2
%4 = tail call i32 @ends_with(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @assert_log(i32 %4, i32 %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%6 = call i32 @ends_with(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%7 = icmp eq i32 %6, 0
%8 = zext i1 %7 to i32
%9 = call i32 @assert_log(i32 %8, i32 %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32* %2)
%10 = call i32 @ends_with(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%11 = call i32 @assert_log(i32 %10, i32 %0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i32* %2)
%12 = load i32, i32* %2
ret i32 %12
}