#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 /*<<< orphan*/ sink(int *, int *, void *, void *, void *);
__attribute__((noipa)) void *return_array_or_array_plus_var(int i, int j) {
  int a[5];
  int b[7];
  void *p0 = a + i;
  void *p1 = b + j;
  void *p = i < j ? p0 : p1;
  sink(a, b, p0, p1, p);
  return p;
}


x86 assembly (clang, -O0):
<return_array_or_array_plus_var>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
lea    -0x20(%rbp),%rax
movslq -0x4(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x48(%rbp)
lea    -0x40(%rbp),%rax
movslq -0x8(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x50(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    115d <return_array_or_array_plus_var+0x4d>
mov    -0x48(%rbp),%rax
mov    %rax,-0x60(%rbp)
jmp    1165 <return_array_or_array_plus_var+0x55>
mov    -0x50(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rax
mov    %rax,-0x58(%rbp)
lea    -0x20(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    -0x48(%rbp),%rdx
mov    -0x50(%rbp),%rcx
mov    -0x58(%rbp),%r8
call   1030 <sink@plt>
mov    -0x58(%rbp),%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<return_array_or_array_plus_var>:
push   %rbx
sub    $0x40,%rsp
movslq %edi,%rax
lea    (%rsp,%rax,4),%rdx
movslq %esi,%rsi
lea    (%rsp,%rsi,4),%rcx
add    $0x20,%rcx
cmp    %esi,%eax
mov    %rcx,%rbx
cmovl  %rdx,%rbx
mov    %rsp,%rdi
lea    0x20(%rsp),%rsi
mov    %rbx,%r8
call   1030 <sink@plt>
mov    %rbx,%rax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i8* @return_array_or_array_plus_var(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [5 x i32]
%6 = alloca [7 x i32]
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
store i32 %0, i32* %3
store i32 %1, i32* %4
%10 = getelementptr inbounds [5 x i32], [5 x i32]* %5, i64 0, i64 0
%11 = load i32, i32* %3
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i32, i32* %10, i64 %12
%14 = bitcast i32* %13 to i8*
store i8* %14, i8** %7
%15 = getelementptr inbounds [7 x i32], [7 x i32]* %6, i64 0, i64 0
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i32, i32* %15, i64 %17
%19 = bitcast i32* %18 to i8*
store i8* %19, i8** %8
%20 = load i32, i32* %3
%21 = load i32, i32* %4
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %25
23: ; preds = %2
%24 = load i8*, i8** %7
br label %27
25: ; preds = %2
%26 = load i8*, i8** %8
br label %27
27: ; preds = %25, %23
%28 = phi i8* [ %24, %23 ], [ %26, %25 ]
store i8* %28, i8** %9
%29 = getelementptr inbounds [5 x i32], [5 x i32]* %5, i64 0, i64 0
%30 = getelementptr inbounds [7 x i32], [7 x i32]* %6, i64 0, i64 0
%31 = load i8*, i8** %7
%32 = load i8*, i8** %8
%33 = load i8*, i8** %9
%34 = call i32 @sink(i32* %29, i32* %30, i8* %31, i8* %32, i8* %33)
%35 = load i8*, i8** %9
ret i8* %35
}

LLVM IR (-O2):
define i8* @return_array_or_array_plus_var(i32 %0, i32 %1) {
%3 = alloca [5 x i32]
%4 = alloca [7 x i32]
%5 = bitcast [5 x i32]* %3 to i8*
%6 = bitcast [7 x i32]* %4 to i8*
%7 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 0
%8 = sext i32 %0 to i64
%9 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 %8
%10 = bitcast i32* %9 to i8*
%11 = getelementptr inbounds [7 x i32], [7 x i32]* %4, i64 0, i64 0
%12 = sext i32 %1 to i64
%13 = getelementptr inbounds [7 x i32], [7 x i32]* %4, i64 0, i64 %12
%14 = bitcast i32* %13 to i8*
%15 = icmp slt i32 %0, %1
%16 = select i1 %15, i8* %10, i8* %14
%17 = call i32 @sink(i32* %7, i32* %11, i8* %10, i8* %14, i8* %16)
ret i8* %16
}