#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 *);
int /*<<< orphan*/ puts(char *);
int strutil_ends_with(char *, char *);
int main(void) {
  char *str1 = "Hello, world!";
  char *str2 = "world!";
  char *str3 = "WORLD!";
  char *str4 = "world";
  printf("\"%s\" ends with \"%s\": ", str1, str2);
  switch (strutil_ends_with(str1, str2)) {
  case 1:
    puts("true");
    break;
  case 0:
    puts("false");
    break;
  }
  printf("\"%s\" ends with \"%s\": ", str1, str3);
  switch (strutil_ends_with(str1, str3)) {
  case 1:
    puts("true");
    break;
  case 0:
    puts("false");
    break;
  }
  printf("\"%s\" ends with \"%s\": ", str1, str4);
  switch (strutil_ends_with(str1, str4)) {
  case 1:
    puts("true");
    break;
  case 0:
    puts("false");
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xeb6(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xeb2(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0xeae(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xea1(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strutil_ends_with@plt>
mov    %eax,%ecx
mov    %ecx,-0x2c(%rbp)
test   %eax,%eax
je     11c0 <main+0x90>
jmp    119e <main+0x6e>
mov    -0x2c(%rbp),%eax
sub    $0x1,%eax
jne    11cc <main+0x9c>
jmp    11af <main+0x7f>
lea    0xe7b(%rip),%rdi
call   1040 <puts@plt>
jmp    11cc <main+0x9c>
lea    0xe6f(%rip),%rdi
call   1040 <puts@plt>
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xe40(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <strutil_ends_with@plt>
mov    %eax,%ecx
mov    %ecx,-0x30(%rbp)
test   %eax,%eax
je     1221 <main+0xf1>
jmp    11ff <main+0xcf>
mov    -0x30(%rbp),%eax
sub    $0x1,%eax
jne    122d <main+0xfd>
jmp    1210 <main+0xe0>
lea    0xe1a(%rip),%rdi
call   1040 <puts@plt>
jmp    122d <main+0xfd>
lea    0xe0e(%rip),%rdi
call   1040 <puts@plt>
mov    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    0xddf(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <strutil_ends_with@plt>
mov    %eax,%ecx
mov    %ecx,-0x34(%rbp)
test   %eax,%eax
je     1282 <main+0x152>
jmp    1260 <main+0x130>
mov    -0x34(%rbp),%eax
sub    $0x1,%eax
jne    128e <main+0x15e>
jmp    1271 <main+0x141>
lea    0xdb9(%rip),%rdi
call   1040 <puts@plt>
jmp    128e <main+0x15e>
lea    0xdad(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xee0(%rip),%rdi
lea    0xebe(%rip),%rbx
lea    0xebe(%rip),%r14
mov    %rbx,%rsi
mov    %r14,%rdx
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strutil_ends_with@plt>
cmp    $0x1,%eax
je     1171 <main+0x41>
test   %eax,%eax
jne    117d <main+0x4d>
lea    0xec7(%rip),%rdi
jmp    1178 <main+0x48>
lea    0xeb9(%rip),%rdi
call   1040 <puts@plt>
lea    0xe97(%rip),%rdi
lea    0xe75(%rip),%rbx
lea    0xe7c(%rip),%r14
mov    %rbx,%rsi
mov    %r14,%rdx
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strutil_ends_with@plt>
cmp    $0x1,%eax
je     11ba <main+0x8a>
test   %eax,%eax
jne    11c6 <main+0x96>
lea    0xe7e(%rip),%rdi
jmp    11c1 <main+0x91>
lea    0xe70(%rip),%rdi
call   1040 <puts@plt>
lea    0xe4e(%rip),%rdi
lea    0xe2c(%rip),%rbx
lea    0xe3a(%rip),%r14
mov    %rbx,%rsi
mov    %r14,%rdx
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strutil_ends_with@plt>
cmp    $0x1,%eax
je     1203 <main+0xd3>
test   %eax,%eax
jne    120f <main+0xdf>
lea    0xe35(%rip),%rdi
jmp    120a <main+0xda>
lea    0xe27(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Hello, world!\00"
@.str.1 = [7 x i8] c"world!\00"
@.str.2 = [7 x i8] c"WORLD!\00"
@.str.3 = [6 x i8] c"world\00"
@.str.4 = [22 x i8] c"\22%s\22 ends with \22%s\22: \00"
@.str.5 = [5 x i8] c"true\00"
@.str.6 = [6 x i8] c"false\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i32 0, i32* %1
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8** %2
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8** %3
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8** %4
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8** %5
%6 = load i8*, i8** %2
%7 = load i8*, i8** %3
%8 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %6, i8* %7)
%9 = load i8*, i8** %2
%10 = load i8*, i8** %3
%11 = call i32 @strutil_ends_with(i8* %9, i8* %10)
switch i32 %11, label %16 [
i32 1, label %12
i32 0, label %14
]
12: ; preds = %0
%13 = call i32 @puts(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %16
14: ; preds = %0
%15 = call i32 @puts(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
br label %16
16: ; preds = %0, %14, %12
%17 = load i8*, i8** %2
%18 = load i8*, i8** %4
%19 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %17, i8* %18)
%20 = load i8*, i8** %2
%21 = load i8*, i8** %4
%22 = call i32 @strutil_ends_with(i8* %20, i8* %21)
switch i32 %22, label %27 [
i32 1, label %23
i32 0, label %25
]
23: ; preds = %16
%24 = call i32 @puts(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %27
25: ; preds = %16
%26 = call i32 @puts(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
br label %27
27: ; preds = %16, %25, %23
%28 = load i8*, i8** %2
%29 = load i8*, i8** %5
%30 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %28, i8* %29)
%31 = load i8*, i8** %2
%32 = load i8*, i8** %5
%33 = call i32 @strutil_ends_with(i8* %31, i8* %32)
switch i32 %33, label %38 [
i32 1, label %34
i32 0, label %36
]
34: ; preds = %27
%35 = call i32 @puts(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %38
36: ; preds = %27
%37 = call i32 @puts(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
br label %38
38: ; preds = %27, %36, %34
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"Hello, world!\00"
@.str.1 = [7 x i8] c"world!\00"
@.str.2 = [7 x i8] c"WORLD!\00"
@.str.3 = [6 x i8] c"world\00"
@.str.4 = [22 x i8] c"\22%s\22 ends with \22%s\22: \00"
@.str.5 = [5 x i8] c"true\00"
@.str.6 = [6 x i8] c"false\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i32 @strutil_ends_with(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
switch i32 %2, label %7 [
i32 1, label %4
i32 0, label %3
]
3: ; preds = %0
br label %4
4: ; preds = %0, %3
%5 = phi i8* [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), %3 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), %0 ]
%6 = tail call i32 @puts(i8* dereferenceable(1) %5)
br label %7
7: ; preds = %4, %0
%8 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%9 = tail call i32 @strutil_ends_with(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
switch i32 %9, label %14 [
i32 1, label %11
i32 0, label %10
]
10: ; preds = %7
br label %11
11: ; preds = %7, %10
%12 = phi i8* [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), %10 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), %7 ]
%13 = tail call i32 @puts(i8* dereferenceable(1) %12)
br label %14
14: ; preds = %11, %7
%15 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%16 = tail call i32 @strutil_ends_with(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
switch i32 %16, label %21 [
i32 1, label %18
i32 0, label %17
]
17: ; preds = %14
br label %18
18: ; preds = %14, %17
%19 = phi i8* [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), %17 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), %14 ]
%20 = tail call i32 @puts(i8* dereferenceable(1) %19)
br label %21
21: ; preds = %18, %14
ret i32 0
}