#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*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strcat(char *, char *);
void recursive_activity_selector(int *s, int *f, int k, int n, char *a) {
  int m;
  char buf[4];
  m = k + 1;
  while (m <= n && s[m] < f[k])
    m = m + 1;
  if (m <= n) {
    sprintf(buf, "a%d ", m);
    strcat(a, buf);
    recursive_activity_selector(s, f, m, n, a);
  }
}


x86 assembly (clang, -O0):
<recursive_activity_selector>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%ecx
xor    %eax,%eax
cmp    -0x18(%rbp),%ecx
mov    %al,-0x29(%rbp)
jg     1180 <recursive_activity_selector+0x50>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x10(%rbp),%rcx
movslq -0x14(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
setl   %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    1190 <recursive_activity_selector+0x60>
jmp    119e <recursive_activity_selector+0x6e>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1153 <recursive_activity_selector+0x23>
mov    -0x24(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     11e1 <recursive_activity_selector+0xb1>
lea    -0x28(%rbp),%rdi
mov    -0x24(%rbp),%edx
lea    0xe48(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1040 <strcat@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x24(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x20(%rbp),%r8
call   1030 <recursive_activity_selector@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<recursive_activity_selector>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r14
mov    %ecx,%r15d
mov    %rsi,%r12
mov    %rdi,%rbp
movslq %edx,%rax
cmp    %eax,%ecx
mov    %eax,%ecx
cmovg  %r15d,%ecx
movslq %ecx,%rcx
mov    %rax,%rbx
nopl   0x0(%rax,%rax,1)
cmp    %rbx,%rcx
je     11a7 <recursive_activity_selector+0x77>
mov    0x4(%rbp,%rbx,4),%edx
add    $0x1,%rbx
cmp    (%r12,%rax,4),%edx
jl     1160 <recursive_activity_selector+0x30>
lea    0xe86(%rip),%rsi
lea    0x4(%rsp),%r13
mov    %r13,%rdi
mov    %ebx,%edx
call   1050 <sprintf@plt>
mov    %r14,%rdi
mov    %r13,%rsi
call   1040 <strcat@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
mov    %ebx,%edx
mov    %r15d,%ecx
mov    %r14,%r8
call   1030 <recursive_activity_selector@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"a%d \00"
define void @recursive_activity_selector(i32* nocapture %0, i32* nocapture %1, i32 %2, i32 %3, i8* %4) {
%6 = alloca [4 x i8]
%7 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%8 = sext i32 %2 to i64
%9 = getelementptr inbounds i32, i32* %1, i64 %8
%10 = call i32 @llvm.smax.i32(i32 %3, i32 %2)
%11 = sext i32 %10 to i64
br label %12
12: ; preds = %16, %5
%13 = phi i64 [ %14, %16 ], [ %8, %5 ]
%14 = add nsw i64 %13, 1
%15 = icmp eq i64 %13, %11
br i1 %15, label %25, label %16
16: ; preds = %12
%17 = getelementptr inbounds i32, i32* %0, i64 %14
%18 = load i32, i32* %17
%19 = load i32, i32* %9
%20 = icmp slt i32 %18, %19
br i1 %20, label %12, label %21
21: ; preds = %16
%22 = trunc i64 %14 to i32
%23 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %22)
%24 = call i32 @strcat(i8* %4, i8* %7)
br label %25
25: ; preds = %12, %21
ret void
}