#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*/ mmmerge(int *, int, int *, int, int *, int, int);
int /*<<< orphan*/ printf(char *, ...);
void __test2(void) {
  int v1[3] = {1, 3, 7};
  int v2[5] = {2, 4, 5, 6, 8};
  int r[8];
  int i;
  mmmerge(r, 8, v1, 3, v2, 5, sizeof(int));
  for (i = 0; i < 8; ++i)
    printf("%d ", r[i]);
  printf("\n");
}


x86 assembly (clang, -O0):
<__test2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0xed1(%rip),%rax
mov    %rax,-0xc(%rbp)
mov    0xecf(%rip),%eax
mov    %eax,-0x4(%rbp)
mov    0xecd(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xec8(%rip),%eax
mov    %eax,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
lea    -0xc(%rbp),%rdx
lea    -0x20(%rbp),%r8
mov    $0x8,%esi
mov    $0x3,%ecx
mov    $0x5,%r9d
movl   $0x4,(%rsp)
call   1040 <mmmerge@plt>
movl   $0x0,-0x44(%rbp)
cmpl   $0x8,-0x44(%rbp)
jge    11b8 <__test2+0x98>
movslq -0x44(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%esi
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    118a <__test2+0x6a>
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__test2>:
push   %rbx
sub    $0x60,%rsp
mov    0xecd(%rip),%eax
mov    %eax,0x38(%rsp)
mov    0xeba(%rip),%rax
mov    %rax,0x30(%rsp)
mov    0xecf(%rip),%eax
mov    %eax,0x50(%rsp)
movaps 0xeb4(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movl   $0x4,(%rsp)
lea    0x10(%rsp),%rdi
lea    0x30(%rsp),%rdx
lea    0x40(%rsp),%r8
mov    $0x8,%esi
mov    $0x3,%ecx
mov    $0x5,%r9d
call   1050 <mmmerge@plt>
mov    0x10(%rsp),%esi
lea    0xe8d(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x1c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x20(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x24(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x28(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x60,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.__test2.v1 = [3 x i32] [i32 1, i32 3, i32 7]
@__const.__test2.v2 = [5 x i32] [i32 2, i32 4, i32 5, i32 6, i32 8]
@.str = [4 x i8] c"%d \00"
@.str.1 = [2 x i8] c"\0A\00"
define void @__test2() {
%1 = alloca [3 x i32]
%2 = alloca [5 x i32]
%3 = alloca [8 x i32]
%4 = alloca i32
%5 = bitcast [3 x i32]* %1 to i8*
%6 = bitcast [5 x i32]* %2 to i8*
%7 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 0
%8 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 0
%9 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%10 = call i32 @mmmerge(i32* %7, i32 8, i32* %8, i32 3, i32* %9, i32 5, i32 4)
store i32 0, i32* %4
br label %11
11: ; preds = %20, %0
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 8
br i1 %13, label %14, label %23
14: ; preds = %11
%15 = load i32, i32* %4
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 %16
%18 = load i32, i32* %17
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %18)
br label %20
20: ; preds = %14
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %11
23: ; preds = %11
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@__const.__test2.v1 = [3 x i32] [i32 1, i32 3, i32 7]
@__const.__test2.v2 = [5 x i32] [i32 2, i32 4, i32 5, i32 6, i32 8]
@.str = [4 x i8] c"%d \00"
define void @__test2() {
%1 = alloca [3 x i32]
%2 = alloca [5 x i32]
%3 = alloca [8 x i32]
%4 = bitcast [3 x i32]* %1 to i8*
%5 = bitcast [5 x i32]* %2 to i8*
%6 = bitcast [8 x i32]* %3 to i8*
%7 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 0
%8 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 0
%9 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%10 = call i32 @mmmerge(i32* %7, i32 8, i32* %8, i32 3, i32* %9, i32 5, i32 4)
%11 = load i32, i32* %7
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 1
%14 = load i32, i32* %13
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 2
%17 = load i32, i32* %16
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 3
%20 = load i32, i32* %19
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %20)
%22 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 4
%23 = load i32, i32* %22
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %23)
%25 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 5
%26 = load i32, i32* %25
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %26)
%28 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 6
%29 = load i32, i32* %28
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %29)
%31 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 7
%32 = load i32, i32* %31
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %32)
%34 = call i32 @putchar(i32 10)
ret void
}