#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 */
struct sarray {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int sarray_cmp(struct sarray *, struct sarray *);
int /*<<< orphan*/ sarray_merge(struct sarray *, struct sarray *, size_t,
                                size_t, size_t);
void sarray_msort(struct sarray *a, struct sarray *aux, size_t lo, size_t hi,
                  struct sarray *ca) {
  size_t mid;
  if (hi <= lo)
    return;
  mid = lo + (hi - lo) / 2;
  sarray_msort(a, aux, lo, mid, ca);
  sarray_msort(a, aux, mid + 1, hi, ca);
  sarray_merge(a, aux, lo, mid, hi);
  if (sarray_cmp(a, ca) == -1) {
    printf("1 ");
    return;
  }
}


x86 assembly (clang, -O0):
<sarray_msort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
ja     116f <sarray_msort+0x2f>
jmp    11f7 <sarray_msort+0xb7>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    -0x18(%rbp),%rcx
shr    $0x1,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x28(%rbp),%r8
call   1050 <sarray_msort@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x30(%rbp),%rdx
add    $0x1,%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
call   1050 <sarray_msort@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x20(%rbp),%r8
call   1060 <sarray_merge@plt>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <sarray_cmp@plt>
cmp    $0xffffffff,%eax
jne    11f7 <sarray_msort+0xb7>
lea    0xe0e(%rip),%rdi
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sarray_msort>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r12
sub    %rdx,%r12
jbe    11b0 <sarray_msort+0x70>
mov    %r8,%r14
mov    %rcx,%rbp
mov    %rdx,%rbx
mov    %rsi,%r13
mov    %rdi,%r15
shr    %r12
lea    (%r12,%rdx,1),%rcx
mov    %rcx,(%rsp)
call   1050 <sarray_msort@plt>
lea    (%r12,%rbx,1),%rdx
add    $0x1,%rdx
mov    %r15,%rdi
mov    %r13,%rsi
mov    %rbp,%rcx
mov    %r14,%r8
call   1050 <sarray_msort@plt>
mov    %r15,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
mov    (%rsp),%rcx
mov    %rbp,%r8
call   1060 <sarray_merge@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <sarray_cmp@plt>
cmp    $0xffffffff,%eax
je     11bf <sarray_msort+0x7f>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe3a(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
%struct.sarray = type { i32 }
@.str = [3 x i8] c"1 \00"
define void @sarray_msort(%struct.sarray* %0, %struct.sarray* %1, i64 %2, i64 %3, %struct.sarray* %4) {
%6 = alloca %struct.sarray*
%7 = alloca %struct.sarray*
%8 = alloca i64
%9 = alloca i64
%10 = alloca %struct.sarray*
%11 = alloca i64
store %struct.sarray* %0, %struct.sarray** %6
store %struct.sarray* %1, %struct.sarray** %7
store i64 %2, i64* %8
store i64 %3, i64* %9
store %struct.sarray* %4, %struct.sarray** %10
%12 = load i64, i64* %9
%13 = load i64, i64* %8
%14 = icmp ule i64 %12, %13
br i1 %14, label %15, label %16
15: ; preds = %5
br label %46
16: ; preds = %5
%17 = load i64, i64* %8
%18 = load i64, i64* %9
%19 = load i64, i64* %8
%20 = sub i64 %18, %19
%21 = udiv i64 %20, 2
%22 = add i64 %17, %21
store i64 %22, i64* %11
%23 = load %struct.sarray*, %struct.sarray** %6
%24 = load %struct.sarray*, %struct.sarray** %7
%25 = load i64, i64* %8
%26 = load i64, i64* %11
%27 = load %struct.sarray*, %struct.sarray** %10
%28 = load %struct.sarray*, %struct.sarray** %6
%29 = load %struct.sarray*, %struct.sarray** %7
%30 = load i64, i64* %11
%31 = add i64 %30, 1
%32 = load i64, i64* %9
%33 = load %struct.sarray*, %struct.sarray** %10
%34 = load %struct.sarray*, %struct.sarray** %6
%35 = load %struct.sarray*, %struct.sarray** %7
%36 = load i64, i64* %8
%37 = load i64, i64* %11
%38 = load i64, i64* %9
%39 = call i32 @sarray_merge(%struct.sarray* %34, %struct.sarray* %35, i64 %36, i64 %37, i64 %38)
%40 = load %struct.sarray*, %struct.sarray** %6
%41 = load %struct.sarray*, %struct.sarray** %10
%42 = call i32 @sarray_cmp(%struct.sarray* %40, %struct.sarray* %41)
%43 = icmp eq i32 %42, -1
br i1 %43, label %44, label %46
44: ; preds = %16
%45 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %46
46: ; preds = %15, %44, %16
ret void
}

LLVM IR (-O2):
%struct.sarray = type { i32 }
@.str = [3 x i8] c"1 \00"
define void @sarray_msort(%struct.sarray* %0, %struct.sarray* %1, i64 %2, i64 %3, %struct.sarray* %4) {
%6 = icmp ugt i64 %3, %2
br i1 %6, label %7, label %17
7: ; preds = %5
%8 = sub i64 %3, %2
%9 = lshr i64 %8, 1
%10 = add i64 %9, %2
tail call void @sarray_msort(%struct.sarray* %0, %struct.sarray* %1, i64 %2, i64 %10, %struct.sarray* %4)
%11 = add i64 %10, 1
tail call void @sarray_msort(%struct.sarray* %0, %struct.sarray* %1, i64 %11, i64 %3, %struct.sarray* %4)
%12 = tail call i32 @sarray_merge(%struct.sarray* %0, %struct.sarray* %1, i64 %2, i64 %10, i64 %3)
%13 = tail call i32 @sarray_cmp(%struct.sarray* %0, %struct.sarray* %4)
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %17
15: ; preds = %7
%16 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %7, %5, %15
ret void
}