#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 *, ...);
void activities(int s[], int f[], int n) {
  int i, j;
  printf("Selected Activities are:\n");
  i = 1;
  printf("A%d ", i);
  for (j = 1; j < n; j++) {
    if (s[j] >= f[i]) {
      printf("A%d ", j + 1);
      i = j;
    }
  }
}


x86 assembly (clang, -O0):
<activities>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
lea    0xed6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xed8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11a5 <activities+0x95>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x10(%rbp),%rcx
movslq -0x18(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jl     1192 <activities+0x82>
mov    -0x1c(%rbp),%esi
add    $0x1,%esi
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    1197 <activities+0x87>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1150 <activities+0x40>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<activities>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,(%rsp)
mov    %rdi,%r12
lea    0xeca(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb9(%rip),%rdi
mov    $0x1,%ebx
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x2,%ebp
jl     11a4 <activities+0x84>
mov    %ebp,%r13d
mov    $0x1,%r15d
mov    $0x2,%ebp
jmp    117b <activities+0x5b>
nopl   (%rax)
add    $0x1,%ebp
mov    %r14,%r15
cmp    %r14,%r13
je     11a4 <activities+0x84>
mov    (%r12,%r15,4),%eax
movslq %ebx,%rcx
lea    0x1(%r15),%r14
mov    (%rsp),%rdx
cmp    (%rdx,%rcx,4),%eax
jl     1170 <activities+0x50>
lea    0xe6a(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15d,%ebx
jmp    1170 <activities+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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