#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 */
scalar_t__ isid(int *, int);
int /*<<< orphan*/ printf(char *, ...);
void print_perm(int *p, int n, int nl) {
  int i;
  if (isid(p, n))
    printf("id");
  else {
    printf("(");
    printf("%d", p[0]);
    for (i = 1; i < n; i++) {
      printf(",%d", p[i]);
    }
    printf(")");
  }
  if (nl)
    printf("\n");
}


x86 assembly (clang, -O0):
<print_perm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <isid@plt>
cmp    $0x0,%rax
je     115b <print_perm+0x3b>
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c5 <print_perm+0xa5>
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b7 <print_perm+0x97>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1184 <print_perm+0x64>
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x10(%rbp)
je     11dd <print_perm+0xbd>
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_perm>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r14d
mov    %esi,%ebp
mov    %rdi,%r12
call   1050 <isid@plt>
test   %rax,%rax
je     116f <print_perm+0x3f>
lea    0xeaf(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %r14d,%r14d
je     11c6 <print_perm+0x96>
mov    $0xa,%edi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>
mov    $0x28,%edi
call   1030 <putchar@plt>
mov    (%r12),%esi
lea    0xe80(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x2,%ebp
jl     11b7 <print_perm+0x87>
mov    %ebp,%ebp
mov    $0x1,%ebx
lea    0xe65(%rip),%r15
xchg   %ax,%ax
mov    (%r12,%rbx,4),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    11a0 <print_perm+0x70>
mov    $0x29,%edi
call   1030 <putchar@plt>
test   %r14d,%r14d
jne    115d <print_perm+0x2d>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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