#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 EXIT_SUCCESS;
int /*<<< orphan*/ FAIL(char *, char const *);
int /*<<< orphan*/ PASS(char *);
char *foo(char *);
scalar_t__ strcmp(char const *, char *);
int main() {
  const char *x = foo("seed");
  if (strcmp(x, "foo3(foo2(foo1(foo(seed))))") == 0)
    PASS("interpose-chained");
  else
    FAIL("interpose-chained %s", x);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
call   1040 <foo@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe9b(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    118a <main+0x4a>
lea    0xea1(%rip),%rdi
call   1050 <PASS@plt>
jmp    119a <main+0x5a>
mov    -0x10(%rbp),%rsi
lea    0xe9e(%rip),%rdi
call   1060 <FAIL@plt>
mov    0x2e3f(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xeb8(%rip),%rdi
call   1040 <foo@plt>
mov    %rax,%rbx
lea    0xeae(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1175 <main+0x35>
lea    0xec8(%rip),%rdi
mov    %rbx,%rsi
call   1060 <FAIL@plt>
jmp    1181 <main+0x41>
lea    0xea5(%rip),%rdi
call   1050 <PASS@plt>
mov    0x2e58(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"seed\00"
@.str.1 = [28 x i8] c"foo3(foo2(foo1(foo(seed))))\00"
@.str.2 = [18 x i8] c"interpose-chained\00"
@.str.3 = [21 x i8] c"interpose-chained %s\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
store i32 0, i32* %1
%3 = call i8* @foo(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %3, i8** %2
%4 = load i8*, i8** %2
%5 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 @PASS(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
br label %12
9: ; preds = %0
%10 = load i8*, i8** %2
%11 = call i32 @FAIL(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %10)
br label %12
12: ; preds = %9, %7
%13 = load i32, i32* @EXIT_SUCCESS
ret i32 %13
}

LLVM IR (-O2):
@.str = [5 x i8] c"seed\00"
@.str.1 = [28 x i8] c"foo3(foo2(foo1(foo(seed))))\00"
@.str.2 = [18 x i8] c"interpose-chained\00"
@.str.3 = [21 x i8] c"interpose-chained %s\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = tail call i8* @foo(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%2 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = tail call i32 @PASS(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
br label %8
6: ; preds = %0
%7 = tail call i32 @FAIL(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %1)
br label %8
8: ; preds = %6, %4
%9 = load i32, i32* @EXIT_SUCCESS
ret i32 %9
}