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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xe87(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1080 <foo@plt>
cltq
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11d8 <main+0x78>
mov    -0x20(%rbp),%rdi
lea    0xe64(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
je     11bf <main+0x5f>
call   1040 <abort@plt>
mov    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0xe,%edx
call   1060 <memset@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1050 <bar@plt>
cltq
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     121b <main+0xbb>
mov    -0x20(%rbp),%rdi
lea    0xe11(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
je     1212 <main+0xb2>
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    0xea4(%rip),%rax
mov    %rax,(%rsp)
lea    0xea1(%rip),%rax
mov    %rax,0x8(%rsp)
mov    (%rsp),%rdi
xor    %eax,%eax
call   1070 <foo@plt>
test   %eax,%eax
je     1199 <main+0x49>
movslq %eax,%rbx
lea    0xe8b(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
jne    11ce <main+0x7e>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    (%rsp),%rdi
xor    %eax,%eax
call   1050 <bar@plt>
test   %eax,%eax
je     11c6 <main+0x76>
movslq %eax,%rbx
lea    0xe5e(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
jne    11ce <main+0x7e>
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 = [14 x i8] c"string1/abcde\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 = call i32 (i8*, ...) bitcast (i32 (...)* @foo to i32 (i8*, ...)*)(i8* %5)
%7 = sext i32 %6 to i64
%8 = inttoptr i64 %7 to i8*
store i8* %8, i8** %4
%9 = load i8*, i8** %4
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %19
11: ; preds = %0
%12 = load i8*, i8** %4
%13 = call i32 @strcmp(i8* %12, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %11
unreachable
16: ; preds = %11
%17 = load i8*, i8** %4
%18 = load i8*, i8** %4
br label %19
19: ; preds = %16, %0
%20 = load volatile i8*, i8** %2
%21 = call i32 (i8*, ...) bitcast (i32 (...)* @bar to i32 (i8*, ...)*)(i8* %20)
%22 = sext i32 %21 to i64
%23 = inttoptr i64 %22 to i8*
store i8* %23, i8** %4
%24 = load i8*, i8** %4
%25 = icmp ne i8* %24, null
br i1 %25, label %26, label %33
26: ; preds = %19
%27 = load i8*, i8** %4
%28 = call i32 @strcmp(i8* %27, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %26
unreachable
31: ; preds = %26
%32 = load i8*, i8** %4
br label %33
33: ; preds = %31, %19
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"string1\00"
@.str.1 = [8 x i8] c"string2\00"
@.str.2 = [14 x i8] c"string1/abcde\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 = tail call i32 (i8*, ...) bitcast (i32 (...)* @foo to i32 (i8*, ...)*)(i8* %5)
%7 = sext i32 %6 to i64
%8 = inttoptr i64 %7 to i8*
%9 = icmp eq i32 %6, 0
br i1 %9, label %15, label %10
10: ; preds = %0
%11 = tail call i32 @strcmp(i8* %8, i8* dereferenceable(14) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp eq i32 %11, 0
br i1 %12, label %14, label %13
13: ; preds = %10
tail call void @abort()
unreachable
14: ; preds = %10
tail call void @free(i8* %8)
br label %15
15: ; preds = %14, %0
%16 = load volatile i8*, i8** %1
%17 = tail call i32 (i8*, ...) bitcast (i32 (...)* @bar to i32 (i8*, ...)*)(i8* %16)
%18 = sext i32 %17 to i64
%19 = inttoptr i64 %18 to i8*
%20 = icmp eq i32 %17, 0
br i1 %20, label %26, label %21
21: ; preds = %15
%22 = tail call i32 @strcmp(i8* %19, i8* dereferenceable(14) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%23 = icmp eq i32 %22, 0
br i1 %23, label %25, label %24
24: ; preds = %21
tail call void @abort()
unreachable
25: ; preds = %21
tail call void @free(i8* %19)
br label %26
26: ; preds = %25, %15
ret i32 0
}