#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*/ printf(char *);
int /*<<< orphan*/ test_endswith(char *, char *, int);
int main(int argc, char *argv[]) {
  test_endswith("endswith", "swith", 1);
  test_endswith("endswith", "ends", 0);
  test_endswith("endswith", "offendswith", 0);
  printf("All tests passed\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xed2(%rip),%rdi
lea    0xece(%rip),%rsi
mov    $0x1,%edx
call   1040 <test_endswith@plt>
lea    0xeba(%rip),%rdi
lea    0xeab(%rip),%rsi
xor    %edx,%edx
call   1040 <test_endswith@plt>
lea    0xea5(%rip),%rdi
lea    0xe9b(%rip),%rsi
xor    %edx,%edx
call   1040 <test_endswith@plt>
lea    0xe99(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xee0(%rip),%rbx
lea    0xedc(%rip),%rsi
mov    %rbx,%rdi
mov    $0x1,%edx
call   1040 <test_endswith@plt>
lea    0xebd(%rip),%rsi
mov    %rbx,%rdi
xor    %edx,%edx
call   1040 <test_endswith@plt>
lea    0xeb1(%rip),%rsi
mov    %rbx,%rdi
xor    %edx,%edx
call   1040 <test_endswith@plt>
lea    0xeac(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [9 x i8] c"endswith\00"
@.str.1 = [6 x i8] c"swith\00"
@.str.2 = [5 x i8] c"ends\00"
@.str.3 = [12 x i8] c"offendswith\00"
@.str.4 = [18 x i8] c"All tests passed\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
store i32 %0, i32* %3
store i8** %1, i8*** %4
%5 = call i32 @test_endswith(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 1)
%6 = call i32 @test_endswith(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 0)
%7 = call i32 @test_endswith(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 0)
%8 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"endswith\00"
@.str.1 = [6 x i8] c"swith\00"
@.str.2 = [5 x i8] c"ends\00"
@.str.3 = [12 x i8] c"offendswith\00"
@str = [17 x i8] c"All tests passed\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @test_endswith(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 1)
%4 = tail call i32 @test_endswith(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 0)
%5 = tail call i32 @test_endswith(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 0)
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
ret i32 0
}