#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 *, char *, ...);
scalar_t__ strend(char *, char *);
int main() {
  char s1[] = "hello";
  char s2[] = "helle";
  char s3[] = "ello";
  printf("Does string: %s, contains string: %s\n", s1, s2);
  printf("After strend function call we conclude that %s\n",
         strend(s1, s2) ? "it sure does" : "it doesn't");
  printf("Does string: %s, contains string: %s\n", s1, s3);
  printf("After strend function call we conclude that %s\n",
         strend(s1, s3) ? "it sure does" : "it doesn't");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xed2(%rip),%eax
mov    %eax,-0x6(%rbp)
mov    0xecc(%rip),%ax
mov    %ax,-0x2(%rbp)
mov    0xec4(%rip),%eax
mov    %eax,-0xc(%rbp)
mov    0xebe(%rip),%ax
mov    %ax,-0x8(%rbp)
mov    0xeab(%rip),%eax
mov    %eax,-0x11(%rbp)
mov    0xea6(%rip),%al
mov    %al,-0xd(%rbp)
lea    -0x6(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x6(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <strend@plt>
mov    %rax,%rcx
lea    0xee0(%rip),%rsi
lea    0xecc(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%rsi
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x6(%rbp),%rsi
lea    -0x11(%rbp),%rdx
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x6(%rbp),%rdi
lea    -0x11(%rbp),%rsi
call   1040 <strend@plt>
mov    %rax,%rcx
lea    0xe96(%rip),%rsi
lea    0xe82(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%rsi
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movw   $0x6f,0x14(%rsp)
movl   $0x6c6c6568,0x10(%rsp)
6c
movw   $0x65,0xc(%rsp)
movl   $0x6c6c6568,0x8(%rsp)
6c
movb   $0x0,0x4(%rsp)
movl   $0x6f6c6c65,(%rsp)
lea    0xead(%rip),%r14
lea    0x10(%rsp),%r15
lea    0x8(%rsp),%rbx
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <strend@plt>
test   %rax,%rax
lea    0xee1(%rip),%rbp
lea    0xecd(%rip),%rbx
mov    %rbx,%rsi
cmove  %rbp,%rsi
lea    0xe8f(%rip),%r12
mov    %r12,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rsp,%r13
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1040 <strend@plt>
test   %rax,%rax
cmove  %rbp,%rbx
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.s1 = [6 x i8] c"hello\00"
@__const.main.s2 = [6 x i8] c"helle\00"
@__const.main.s3 = [5 x i8] c"ello\00"
@.str = [38 x i8] c"Does string: %s, contains string: %s\0A\00"
@.str.1 = [48 x i8] c"After strend function call we conclude that %s\0A\00"
@.str.2 = [13 x i8] c"it sure does\00"
@.str.3 = [11 x i8] c"it doesn't\00"
define i32 @main() {
%1 = alloca [6 x i8]
%2 = alloca [6 x i8]
%3 = alloca [5 x i8]
%4 = bitcast [6 x i8]* %1 to i8*
%5 = bitcast [6 x i8]* %2 to i8*
%6 = bitcast [5 x i8]* %3 to i8*
%7 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%8 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%9 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %7, i8* %8)
%10 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%11 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%12 = call i64 @strend(i8* %10, i8* %11)
%13 = icmp ne i64 %12, 0
%14 = zext i1 %13 to i64
%15 = select i1 %13, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0)
%16 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%18 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%19 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %17, i8* %18)
%20 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%21 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%22 = call i64 @strend(i8* %20, i8* %21)
%23 = icmp ne i64 %22, 0
%24 = zext i1 %23 to i64
%25 = select i1 %23, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0)
%26 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i8* %25)
ret i32 0
}

LLVM IR (-O2):
@__const.main.s1 = [6 x i8] c"hello\00"
@__const.main.s2 = [6 x i8] c"helle\00"
@__const.main.s3 = [5 x i8] c"ello\00"
@.str = [38 x i8] c"Does string: %s, contains string: %s\0A\00"
@.str.1 = [48 x i8] c"After strend function call we conclude that %s\0A\00"
@.str.2 = [13 x i8] c"it sure does\00"
@.str.3 = [11 x i8] c"it doesn't\00"
define i32 @main() {
%1 = alloca [6 x i8]
%2 = alloca [6 x i8]
%3 = alloca [5 x i8]
%4 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%7 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %4, i8* %5)
%8 = call i64 @strend(i8* %4, i8* %5)
%9 = icmp eq i64 %8, 0
%10 = select i1 %9, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0)
%11 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %4, i8* %6)
%13 = call i64 @strend(i8* %4, i8* %6)
%14 = icmp eq i64 %13, 0
%15 = select i1 %14, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0)
%16 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i8* %15)
ret i32 0
}