#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 */
char *find_triple_start(char const *, char const **);
char *strstr(char const *, char const *);
void find_triple_end(char const *string, char const **which) {
  char const *s = string;
  while (1) {
    s = strstr(s, *which);
    if (!s)
      break;
    s += 3;
    *which = NULL;
    s = find_triple_start(s, which);
    if (!s)
      break;
    s += 3;
  }
}


x86 assembly (clang, -O0):
<find_triple_end>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
call   1040 <strstr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    115c <find_triple_end+0x3c>
jmp    11a5 <find_triple_end+0x85>
mov    -0x18(%rbp),%rax
add    $0x3,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <find_triple_start@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1194 <find_triple_end+0x74>
jmp    11a5 <find_triple_end+0x85>
mov    -0x18(%rbp),%rax
add    $0x3,%rax
mov    %rax,-0x18(%rbp)
jmp    1138 <find_triple_end+0x18>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_triple_end>:
push   %rbx
mov    %rsi,%rbx
mov    (%rsi),%rsi
nopw   0x0(%rax,%rax,1)
call   1040 <strstr@plt>
test   %rax,%rax
je     1161 <find_triple_end+0x41>
add    $0x3,%rax
movq   $0x0,(%rbx)
mov    %rax,%rdi
mov    %rbx,%rsi
call   1030 <find_triple_start@plt>
test   %rax,%rax
je     1161 <find_triple_end+0x41>
add    $0x3,%rax
mov    (%rbx),%rsi
mov    %rax,%rdi
jmp    1130 <find_triple_end+0x10>
pop    %rbx
ret

LLVM IR (-O0):
define void @find_triple_end(i8* %0, i8** %1) {
%3 = alloca i8*
%4 = alloca i8**
%5 = alloca i8*
store i8* %0, i8** %3
store i8** %1, i8*** %4
%6 = load i8*, i8** %3
store i8* %6, i8** %5
br label %7
7: ; preds = %2, %25
%8 = load i8*, i8** %5
%9 = load i8**, i8*** %4
%10 = load i8*, i8** %9
%11 = call i8* @strstr(i8* %8, i8* %10)
store i8* %11, i8** %5
%12 = load i8*, i8** %5
%13 = icmp ne i8* %12, null
br i1 %13, label %15, label %14
14: ; preds = %7
br label %28
15: ; preds = %7
%16 = load i8*, i8** %5
%17 = getelementptr inbounds i8, i8* %16, i64 3
store i8* %17, i8** %5
%18 = load i8**, i8*** %4
store i8* null, i8** %18
%19 = load i8*, i8** %5
%20 = load i8**, i8*** %4
%21 = call i8* @find_triple_start(i8* %19, i8** %20)
store i8* %21, i8** %5
%22 = load i8*, i8** %5
%23 = icmp ne i8* %22, null
br i1 %23, label %25, label %24
24: ; preds = %15
br label %28
25: ; preds = %15
%26 = load i8*, i8** %5
%27 = getelementptr inbounds i8, i8* %26, i64 3
store i8* %27, i8** %5
br label %7
28: ; preds = %24, %14
ret void
}

LLVM IR (-O2):
define void @find_triple_end(i8* %0, i8** %1) {
%3 = load i8*, i8** %1
%4 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) %3)
%5 = icmp eq i8* %4, null
br i1 %5, label %16, label %11
6: ; preds = %11
%7 = getelementptr inbounds i8, i8* %14, i64 3
%8 = load i8*, i8** %1
%9 = tail call i8* @strstr(i8* dereferenceable(1) %7, i8* dereferenceable(1) %8)
%10 = icmp eq i8* %9, null
br i1 %10, label %16, label %11
11: ; preds = %2, %6
%12 = phi i8* [ %9, %6 ], [ %4, %2 ]
%13 = getelementptr inbounds i8, i8* %12, i64 3
store i8* null, i8** %1
%14 = tail call i8* @find_triple_start(i8* %13, i8** %1)
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %6
16: ; preds = %6, %11, %2
ret void
}