#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*/ josephus(int *, int, int, int);
int /*<<< orphan*/ printf(char *, ...);
void main() {
  int i, arr[30];
  int num = 13, step = 3, start = 0;
  josephus(arr, num, start, step);
  printf("the order is : ");
  for (i = num - 1; i >= 0; i--)
    printf("%-4d", arr[i]);
  printf("\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0xd,-0x84(%rbp)
movl   $0x3,-0x88(%rbp)
movl   $0x0,-0x8c(%rbp)
lea    -0x80(%rbp),%rdi
mov    -0x84(%rbp),%esi
mov    -0x8c(%rbp),%edx
mov    -0x88(%rbp),%ecx
call   1030 <josephus@plt>
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x84(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jl     11ac <main+0x8c>
movslq -0x4(%rbp),%rax
mov    -0x80(%rbp,%rax,4),%esi
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
jmp    117e <main+0x5e>
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x80,%rsp
mov    %rsp,%rdi
mov    $0xd,%esi
xor    %edx,%edx
mov    $0x3,%ecx
call   1040 <josephus@plt>
lea    0xead(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x30(%rsp),%esi
lea    0xeab(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x28(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x24(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x20(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x1c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x18(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x80,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [16 x i8] c"the order is : \00"
@.str.1 = [5 x i8] c"%-4d\00"
define void @main() {
%1 = alloca [30 x i32]
%2 = bitcast [30 x i32]* %1 to i8*
%3 = getelementptr inbounds [30 x i32], [30 x i32]* %1, i64 0, i64 0
%4 = call i32 @josephus(i32* %3, i32 13, i32 0, i32 3)
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [30 x i32], [30 x i32]* %1, i64 0, i64 12
%7 = load i32, i32* %6
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = getelementptr inbounds [30 x i32], [30 x i32]* %1, i64 0, i64 11
%10 = load i32, i32* %9
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%12 = getelementptr inbounds [30 x i32], [30 x i32]* %1, i64 0, i64 10
%13 = load i32, i32* %12
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = getelementptr inbounds [30 x i32], [30 x i32]* %1, i64 0, i64 9
%16 = load i32, i32* %15
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = getelementptr inbounds [30 x i32], [30 x i32]* %1, i64 0, i64 8
%19 = load i32, i32* %18
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = getelementptr inbounds [30 x i32], [30 x i32]* %1, i64 0, i64 7
%22 = load i32, i32* %21
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %22)
%24 = getelementptr inbounds [30 x i32], [30 x i32]* %1, i64 0, i64 6
%25 = load i32, i32* %24
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %25)
%27 = getelementptr inbounds [30 x i32], [30 x i32]* %1, i64 0, i64 5
%28 = load i32, i32* %27
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %28)
%30 = getelementptr inbounds [30 x i32], [30 x i32]* %1, i64 0, i64 4
%31 = load i32, i32* %30
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %31)
%33 = getelementptr inbounds [30 x i32], [30 x i32]* %1, i64 0, i64 3
%34 = load i32, i32* %33
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %34)
%36 = getelementptr inbounds [30 x i32], [30 x i32]* %1, i64 0, i64 2
%37 = load i32, i32* %36
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %37)
%39 = getelementptr inbounds [30 x i32], [30 x i32]* %1, i64 0, i64 1
%40 = load i32, i32* %39
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %40)
%42 = load i32, i32* %3
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %42)
%44 = call i32 @putchar(i32 10)
ret void
}