#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 */
char *getvar(int);
int /*<<< orphan*/ printf(char *, char *, char *, ...);
void gencallrec(int ofs, int len) {
  int lenl = len / 2, lenr = len - lenl;
  int xh;
  if (len <= 1)
    return;
  gencallrec(ofs, lenl);
  gencallrec(ofs + lenl, lenr);
  printf("\t"
         "merge_%s_%s_%s_%s"
         "();\n",
         getvar(ofs), getvar(ofs + len - 1), getvar(ofs), getvar(ofs + lenl));
  for (xh = ofs; xh < ofs + len; xh++)
    printf("\t%s=t%s;\n", getvar(xh), getvar(xh));
}


x86 assembly (clang, -O0):
<gencallrec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jg     1164 <gencallrec+0x34>
jmp    121d <gencallrec+0xed>
mov    -0x4(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1050 <gencallrec@plt>
mov    -0x4(%rbp),%edi
add    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1050 <gencallrec@plt>
mov    -0x4(%rbp),%edi
call   1030 <getvar@plt>
mov    %rax,-0x30(%rbp)
mov    -0x4(%rbp),%edi
add    -0x8(%rbp),%edi
sub    $0x1,%edi
call   1030 <getvar@plt>
mov    %rax,-0x28(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <getvar@plt>
mov    %rax,-0x20(%rbp)
mov    -0x4(%rbp),%edi
add    -0xc(%rbp),%edi
call   1030 <getvar@plt>
mov    -0x30(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    %rax,%r8
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x4(%rbp),%ecx
add    -0x8(%rbp),%ecx
cmp    %ecx,%eax
jge    121d <gencallrec+0xed>
mov    -0x14(%rbp),%edi
call   1030 <getvar@plt>
mov    %rax,-0x38(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <getvar@plt>
mov    -0x38(%rbp),%rsi
mov    %rax,%rdx
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11d5 <gencallrec+0xa5>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gencallrec>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%esi
jl     11e9 <gencallrec+0xb9>
mov    %esi,%r14d
mov    %edi,%ebx
mov    %esi,%ebp
shr    $0x1f,%ebp
add    %esi,%ebp
sar    %ebp
mov    %esi,%r15d
sub    %ebp,%r15d
mov    %ebp,%esi
call   1050 <gencallrec@plt>
add    %ebx,%ebp
mov    %ebp,%edi
mov    %r15d,%esi
call   1050 <gencallrec@plt>
mov    %ebx,%edi
call   1030 <getvar@plt>
mov    %rax,%r15
mov    %r14d,%eax
add    %ebx,%r14d
lea    (%rax,%rbx,1),%edi
add    $0xffffffff,%edi
call   1030 <getvar@plt>
mov    %rax,%r12
mov    %ebx,%edi
call   1030 <getvar@plt>
mov    %rax,%r13
mov    %ebp,%edi
call   1030 <getvar@plt>
lea    0xe5f(%rip),%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
mov    %rax,%r8
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe5c(%rip),%r15
nopl   0x0(%rax,%rax,1)
mov    %ebx,%edi
call   1030 <getvar@plt>
mov    %rax,%rbp
mov    %ebx,%edi
call   1030 <getvar@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebx
cmp    %r14d,%ebx
jl     11c0 <gencallrec+0x90>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"\09merge_%s_%s_%s_%s();\0A\00"
@.str.1 = [10 x i8] c"\09%s=t%s;\0A\00"
define void @gencallrec(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%8 = load i32, i32* %4
%9 = sdiv i32 %8, 2
store i32 %9, i32* %5
%10 = load i32, i32* %4
%11 = load i32, i32* %5
%12 = sub nsw i32 %10, %11
store i32 %12, i32* %6
%13 = load i32, i32* %4
%14 = icmp sle i32 %13, 1
br i1 %14, label %15, label %16
15: ; preds = %2
br label %53
16: ; preds = %2
%17 = load i32, i32* %3
%18 = load i32, i32* %5
%19 = load i32, i32* %3
%20 = load i32, i32* %5
%21 = add nsw i32 %19, %20
%22 = load i32, i32* %6
%23 = load i32, i32* %3
%24 = call i8* @getvar(i32 %23)
%25 = load i32, i32* %3
%26 = load i32, i32* %4
%27 = add nsw i32 %25, %26
%28 = sub nsw i32 %27, 1
%29 = call i8* @getvar(i32 %28)
%30 = load i32, i32* %3
%31 = call i8* @getvar(i32 %30)
%32 = load i32, i32* %3
%33 = load i32, i32* %5
%34 = add nsw i32 %32, %33
%35 = call i8* @getvar(i32 %34)
%36 = call i32 (i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %24, i8* %29, i8* %31, i8* %35)
%37 = load i32, i32* %3
store i32 %37, i32* %7
br label %38
38: ; preds = %50, %16
%39 = load i32, i32* %7
%40 = load i32, i32* %3
%41 = load i32, i32* %4
%42 = add nsw i32 %40, %41
%43 = icmp slt i32 %39, %42
br i1 %43, label %44, label %53
44: ; preds = %38
%45 = load i32, i32* %7
%46 = call i8* @getvar(i32 %45)
%47 = load i32, i32* %7
%48 = call i8* @getvar(i32 %47)
%49 = call i32 (i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %46, i8* %48)
br label %50
50: ; preds = %44
%51 = load i32, i32* %7
%52 = add nsw i32 %51, 1
store i32 %52, i32* %7
br label %38
53: ; preds = %15, %38
ret void
}

LLVM IR (-O2):
@.str = [23 x i8] c"\09merge_%s_%s_%s_%s();\0A\00"
@.str.1 = [10 x i8] c"\09%s=t%s;\0A\00"
define void @gencallrec(i32 %0, i32 %1) {
%3 = sdiv i32 %1, 2
%4 = icmp slt i32 %1, 2
br i1 %4, label %22, label %5
5: ; preds = %2
%6 = sub nsw i32 %1, %3
tail call void @gencallrec(i32 %0, i32 %3)
%7 = add nsw i32 %3, %0
tail call void @gencallrec(i32 %7, i32 %6)
%8 = tail call i8* @getvar(i32 %0)
%9 = add nsw i32 %1, %0
%10 = add nsw i32 %9, -1
%11 = tail call i8* @getvar(i32 %10)
%12 = tail call i8* @getvar(i32 %0)
%13 = tail call i8* @getvar(i32 %7)
%14 = tail call i32 (i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %8, i8* %11, i8* %12, i8* %13)
br label %15
15: ; preds = %5, %15
%16 = phi i32 [ %20, %15 ], [ %0, %5 ]
%17 = tail call i8* @getvar(i32 %16)
%18 = tail call i8* @getvar(i32 %16)
%19 = tail call i32 (i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %17, i8* %18)
%20 = add nsw i32 %16, 1
%21 = icmp slt i32 %20, %9
br i1 %21, label %15, label %22
22: ; preds = %15, %2
ret void
}