#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*/ printf(char *, char *);
void balance(char **data, int len) {
  if (len) {
    int n = (len + 1) / 2;
    char **p = data + n - 1;
    printf("%s\n", *p);
    balance(data, n - 1);
    balance(p + 1, len - n);
  }
}


x86 assembly (clang, -O0):
<balance>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1196 <balance+0x76>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
add    $0xfffffffffffffff8,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
lea    0xe91(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
sub    $0x1,%esi
call   1030 <balance@plt>
mov    -0x18(%rbp),%rdi
add    $0x8,%rdi
mov    -0xc(%rbp),%esi
sub    -0x10(%rbp),%esi
call   1030 <balance@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<balance>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %esi,%esi
je     1176 <balance+0x56>
mov    %esi,%ebx
mov    %rdi,%r15
lea    0xec7(%rip),%r14
nopl   0x0(%rax)
lea    0x1(%rbx),%eax
shr    $0x1f,%eax
add    %ebx,%eax
add    $0x1,%eax
sar    %eax
movslq %eax,%r12
lea    (%r15,%r12,8),%r13
mov    -0x8(%r15,%r12,8),%rsi
mov    %r14,%rdi
call   1040 <printf@plt>
lea    -0x1(%r12),%esi
mov    %r15,%rdi
call   1030 <balance@plt>
mov    %r13,%r15
sub    %r12d,%ebx
jne    1140 <balance+0x20>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
define void @balance(i8** %0, i32 %1) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %18, label %4
4: ; preds = %2, %4
%5 = phi i32 [ %16, %4 ], [ %1, %2 ]
%6 = phi i8** [ %15, %4 ], [ %0, %2 ]
%7 = add nsw i32 %5, 1
%8 = sdiv i32 %7, 2
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i8*, i8** %6, i64 -1
%11 = getelementptr inbounds i8*, i8** %10, i64 %9
%12 = load i8*, i8** %11
%13 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = add nsw i32 %8, -1
tail call void @balance(i8** %6, i32 %14)
%15 = getelementptr inbounds i8*, i8** %11, i64 1
%16 = sub nsw i32 %5, %8
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %4
18: ; preds = %4, %2
ret void
}