#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 *, int, ...);
void backfunc(int *buf, int a, int b) {
  int mid = (a + b) / 2;
  if (b - a < 2) {
    if (a == b)
      printf("%d\n", a);
    else
      printf("%d,%d\n", a, b);
    return;
  } else
    printf("%d\n", mid);
  backfunc(buf, a, mid - 1);
  backfunc(buf, mid + 1, b);
}


x86 assembly (clang, -O0):
<backfunc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
sub    -0xc(%rbp),%eax
cmp    $0x2,%eax
jge    118d <backfunc+0x6d>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jne    1174 <backfunc+0x54>
mov    -0xc(%rbp),%esi
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1188 <backfunc+0x68>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11c2 <backfunc+0xa2>
mov    -0x14(%rbp),%esi
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
sub    $0x1,%edx
call   1030 <backfunc@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
add    $0x1,%esi
mov    -0x10(%rbp),%edx
call   1030 <backfunc@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<backfunc>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %edx,%r15d
mov    %esi,%r13d
mov    %edx,%eax
sub    %esi,%eax
cmp    $0x2,%eax
jge    113d <backfunc+0x1d>
mov    %r13d,%ebx
jmp    1187 <backfunc+0x67>
mov    %rdi,%r14
lea    0xebc(%rip),%r12
nopw   0x0(%rax,%rax,1)
lea    (%r15,%r13,1),%eax
mov    %eax,%ebx
shr    $0x1f,%ebx
add    %eax,%ebx
sar    %ebx
mov    %r12,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    -0x1(%rbx),%edx
mov    %r14,%rdi
mov    %r13d,%esi
call   1030 <backfunc@plt>
add    $0x1,%ebx
mov    %r15d,%eax
sub    %ebx,%eax
mov    %ebx,%r13d
cmp    $0x2,%eax
jge    1150 <backfunc+0x30>
cmp    %r15d,%ebx
jne    11a6 <backfunc+0x86>
lea    0xe70(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1040 <printf@plt>
lea    0xe53(%rip),%rdi
mov    %ebx,%esi
mov    %r15d,%edx
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1040 <printf@plt>

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

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