int main() {
  char *volatile p = "string1";
  char *volatile r = "string2";
  char *q = foo(p, r);
  if (q != ((void *)0)) {
    if (strcmp(q, "string1/abcdestring2fg"))
      abort();
    free(q);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xea7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1060 <foo@plt>
cltq
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11ac <main+0x6c>
mov    -0x20(%rbp),%rdi
lea    0xe80(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
je     11a3 <main+0x63>
call   1040 <abort@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xeb4(%rip),%rax
mov    %rax,0x8(%rsp)
lea    0xeb0(%rip),%rax
mov    %rax,(%rsp)
mov    0x8(%rsp),%rdi
mov    (%rsp),%rsi
xor    %eax,%eax
call   1060 <foo@plt>
test   %eax,%eax
je     118e <main+0x4e>
movslq %eax,%rbx
lea    0xe96(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
jne    1196 <main+0x56>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
call   1040 <abort@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"string1\00"
@.str.1 = [8 x i8] c"string2\00"
@.str.2 = [23 x i8] c"string1/abcdestring2fg\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i32 0, i32* %1
store volatile i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %2
store volatile i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %3
%5 = load volatile i8*, i8** %2
%6 = load volatile i8*, i8** %3
%7 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @foo to i32 (i8*, i8*, ...)*)(i8* %5, i8* %6)
%8 = sext i32 %7 to i64
%9 = inttoptr i64 %8 to i8*
store i8* %9, i8** %4
%10 = load i8*, i8** %4
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %19
12: ; preds = %0
%13 = load i8*, i8** %4
%14 = call i32 @strcmp(i8* %13, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %12
unreachable
17: ; preds = %12
%18 = load i8*, i8** %4
br label %19
19: ; preds = %17, %0
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"string1\00"
@.str.1 = [8 x i8] c"string2\00"
@.str.2 = [23 x i8] c"string1/abcdestring2fg\00"
define i32 @main() {
%1 = alloca i8*
%2 = alloca i8*
%3 = bitcast i8** %1 to i8*
store volatile i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %1
%4 = bitcast i8** %2 to i8*
store volatile i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %2
%5 = load volatile i8*, i8** %1
%6 = load volatile i8*, i8** %2
%7 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @foo to i32 (i8*, i8*, ...)*)(i8* %5, i8* %6)
%8 = sext i32 %7 to i64
%9 = inttoptr i64 %8 to i8*
%10 = icmp eq i32 %7, 0
br i1 %10, label %16, label %11
11: ; preds = %0
%12 = tail call i32 @strcmp(i8* %9, i8* dereferenceable(23) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp eq i32 %12, 0
br i1 %13, label %15, label %14
14: ; preds = %11
tail call void @abort()
unreachable
15: ; preds = %11
tail call void @free(i8* %9)
br label %16
16: ; preds = %15, %0
ret i32 0
}