#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 *, char *);
scalar_t__ string_ends_with(char *, char *);
int main() {
  char *filename = "drolegna.csv";
  char *filename1 = "puberty.mp4";
  char *suffix = ".csv";
  if (string_ends_with(filename, suffix))
    printf("%s ends with %s\n", filename, suffix);
  else
    printf("%s does not end with %s\n", filename, suffix);
  if (string_ends_with(filename1, suffix))
    printf("%s ends with %s\n", filename1, suffix);
  else
    printf("%s does not end with %s\n", filename1, suffix);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xecc(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xebc(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <string_ends_with@plt>
cmp    $0x0,%rax
je     1180 <main+0x60>
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xea3(%rip),%rdi
call   1030 <printf@plt>
jmp    1194 <main+0x74>
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xe9b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <string_ends_with@plt>
cmp    $0x0,%rax
je     11c4 <main+0xa4>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xe5f(%rip),%rdi
call   1030 <printf@plt>
jmp    11d8 <main+0xb8>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xe57(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xed1(%rip),%r14
lea    0xed2(%rip),%r15
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <string_ends_with@plt>
test   %rax,%rax
lea    0xedf(%rip),%r12
lea    0xec7(%rip),%rbx
mov    %rbx,%rdi
cmove  %r12,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1030 <printf@plt>
lea    0xea2(%rip),%r14
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <string_ends_with@plt>
test   %rax,%rax
cmove  %r12,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [13 x i8] c"drolegna.csv\00"
@.str.1 = [12 x i8] c"puberty.mp4\00"
@.str.2 = [5 x i8] c".csv\00"
@.str.3 = [17 x i8] c"%s ends with %s\0A\00"
@.str.4 = [25 x i8] c"%s does not end with %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i32 0, i32* %1
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8** %2
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8** %3
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %4
%5 = load i8*, i8** %2
%6 = load i8*, i8** %4
%7 = call i64 @string_ends_with(i8* %5, i8* %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %0
%10 = load i8*, i8** %2
%11 = load i8*, i8** %4
%12 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* %10, i8* %11)
br label %17
13: ; preds = %0
%14 = load i8*, i8** %2
%15 = load i8*, i8** %4
%16 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8* %14, i8* %15)
br label %17
17: ; preds = %13, %9
%18 = load i8*, i8** %3
%19 = load i8*, i8** %4
%20 = call i64 @string_ends_with(i8* %18, i8* %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %17
%23 = load i8*, i8** %3
%24 = load i8*, i8** %4
%25 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* %23, i8* %24)
br label %30
26: ; preds = %17
%27 = load i8*, i8** %3
%28 = load i8*, i8** %4
%29 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8* %27, i8* %28)
br label %30
30: ; preds = %26, %22
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"drolegna.csv\00"
@.str.1 = [12 x i8] c"puberty.mp4\00"
@.str.2 = [5 x i8] c".csv\00"
@.str.3 = [17 x i8] c"%s ends with %s\0A\00"
@.str.4 = [25 x i8] c"%s does not end with %s\0A\00"
define i32 @main() {
%1 = tail call i64 @string_ends_with(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%2 = icmp eq i64 %1, 0
%3 = select i1 %2, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0)
%4 = tail call i32 @printf(i8* %3, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%5 = tail call i64 @string_ends_with(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
%7 = select i1 %6, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0)
%8 = tail call i32 @printf(i8* %7, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}