__attribute__((noclone, no, noipa)) void *test_min_3_phi(int i) {
  char a, b;
  char *p0 = &a;
  char *p1 = &b;
  char *p2 = get_min_3(&a, &b);
  char *p3 = get_min_3(&a, &b);
  char *p4 = p2 < p0 ? p2 : p0;
  char *p5 = p3 < p1 ? p3 : p1;
  __builtin_printf("%p %p %p %p\n", p2, p3, p4, p5);
  if (i == 1)
    return p4;
  else
    return p5;
}


x86 assembly (clang, -O0):
<test_min_3_phi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0xc(%rbp)
lea    -0xd(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    -0xe(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    -0xd(%rbp),%rdi
lea    -0xe(%rbp),%rsi
mov    $0x0,%al
call   1040 <get_min_3@plt>
cltq
mov    %rax,-0x28(%rbp)
lea    -0xd(%rbp),%rdi
lea    -0xe(%rbp),%rsi
mov    $0x0,%al
call   1040 <get_min_3@plt>
cltq
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1180 <test_min_3_phi+0x60>
mov    -0x28(%rbp),%rax
mov    %rax,-0x48(%rbp)
jmp    1188 <test_min_3_phi+0x68>
mov    -0x18(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    11ab <test_min_3_phi+0x8b>
mov    -0x30(%rbp),%rax
mov    %rax,-0x50(%rbp)
jmp    11b3 <test_min_3_phi+0x93>
mov    -0x20(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    -0x40(%rbp),%r8
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x1,-0xc(%rbp)
jne    11f0 <test_min_3_phi+0xd0>
mov    -0x38(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11f8 <test_min_3_phi+0xd8>
mov    -0x40(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_min_3_phi>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%r14d
lea    0x7(%rsp),%rbx
lea    0x6(%rsp),%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <get_min_3@plt>
movslq %eax,%r15
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <get_min_3@plt>
movslq %eax,%rdx
cmp    %r15,%rbx
cmova  %r15,%rbx
cmp    %rdx,%rbp
cmova  %rdx,%rbp
lea    0xe97(%rip),%rdi
mov    %r15,%rsi
mov    %rbx,%rcx
mov    %rbp,%r8
xor    %eax,%eax
call   1030 <printf@plt>
cmp    $0x1,%r14d
cmove  %rbx,%rbp
mov    %rbp,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"%p %p %p %p\0A\00"
define i8* @test_min_3_phi(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8
%5 = alloca i8
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
store i32 %0, i32* %3
store i8* %4, i8** %6
store i8* %5, i8** %7
%12 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @get_min_3 to i32 (i8*, i8*, ...)*)(i8* %4, i8* %5)
%13 = sext i32 %12 to i64
%14 = inttoptr i64 %13 to i8*
store i8* %14, i8** %8
%15 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @get_min_3 to i32 (i8*, i8*, ...)*)(i8* %4, i8* %5)
%16 = sext i32 %15 to i64
%17 = inttoptr i64 %16 to i8*
store i8* %17, i8** %9
%18 = load i8*, i8** %8
%19 = load i8*, i8** %6
%20 = icmp ult i8* %18, %19
br i1 %20, label %21, label %23
21: ; preds = %1
%22 = load i8*, i8** %8
br label %25
23: ; preds = %1
%24 = load i8*, i8** %6
br label %25
25: ; preds = %23, %21
%26 = phi i8* [ %22, %21 ], [ %24, %23 ]
store i8* %26, i8** %10
%27 = load i8*, i8** %9
%28 = load i8*, i8** %7
%29 = icmp ult i8* %27, %28
br i1 %29, label %30, label %32
30: ; preds = %25
%31 = load i8*, i8** %9
br label %34
32: ; preds = %25
%33 = load i8*, i8** %7
br label %34
34: ; preds = %32, %30
%35 = phi i8* [ %31, %30 ], [ %33, %32 ]
store i8* %35, i8** %11
%36 = load i8*, i8** %8
%37 = load i8*, i8** %9
%38 = load i8*, i8** %10
%39 = load i8*, i8** %11
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %36, i8* %37, i8* %38, i8* %39)
%41 = load i32, i32* %3
%42 = icmp eq i32 %41, 1
br i1 %42, label %43, label %45
43: ; preds = %34
%44 = load i8*, i8** %10
store i8* %44, i8** %2
br label %47
45: ; preds = %34
%46 = load i8*, i8** %11
store i8* %46, i8** %2
br label %47
47: ; preds = %45, %43
%48 = load i8*, i8** %2
ret i8* %48
}

LLVM IR (-O2):
@.str = [13 x i8] c"%p %p %p %p\0A\00"
define i8* @test_min_3_phi(i32 %0) {
%2 = alloca i8
%3 = alloca i8
%4 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @get_min_3 to i32 (i8*, i8*, ...)*)(i8* %2, i8* %3)
%5 = sext i32 %4 to i64
%6 = inttoptr i64 %5 to i8*
%7 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @get_min_3 to i32 (i8*, i8*, ...)*)(i8* %2, i8* %3)
%8 = sext i32 %7 to i64
%9 = inttoptr i64 %8 to i8*
%10 = icmp ugt i8* %2, %6
%11 = select i1 %10, i8* %6, i8* %2
%12 = icmp ugt i8* %3, %9
%13 = select i1 %12, i8* %9, i8* %3
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %6, i8* %9, i8* %11, i8* %13)
%15 = icmp eq i32 %0, 1
%16 = select i1 %15, i8* %11, i8* %13
ret i8* %16
}