#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
scalar_t__ isid(int *, int);
void fprint_perm(FILE *file, int *p, int n, int nl) {
  int i;
  if (isid(p, n))
    fprintf(file, "id");
  else {
    fprintf(file, "(");
    fprintf(file, "%d", p[0]);
    for (i = 1; i < n; i++) {
      fprintf(file, ",%d", p[i]);
    }
    fprintf(file, ")");
  }
  if (nl)
    fprintf(file, "\n");
}


x86 assembly (clang, -O0):
<fprint_perm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <isid@plt>
cmp    $0x0,%rax
je     1163 <fprint_perm+0x43>
mov    -0x8(%rbp),%rdi
lea    0xea9(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11dd <fprint_perm+0xbd>
mov    -0x8(%rbp),%rdi
lea    0xe95(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%edx
lea    0xe80(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11cb <fprint_perm+0xab>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe4f(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1194 <fprint_perm+0x74>
mov    -0x8(%rbp),%rdi
lea    0xe33(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
cmpl   $0x0,-0x18(%rbp)
je     11f9 <fprint_perm+0xd9>
mov    -0x8(%rbp),%rdi
lea    0xe19(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fprint_perm>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %edx,%r15d
mov    %rsi,%r13
mov    %rdi,%r12
mov    %rsi,%rdi
mov    %edx,%esi
call   1050 <isid@plt>
test   %rax,%rax
je     11a3 <fprint_perm+0x63>
lea    0xe93(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1060 <fwrite@plt>
test   %r14d,%r14d
je     1211 <fprint_perm+0xd1>
mov    $0xa,%edi
mov    %r12,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fputc@plt>
mov    $0x28,%edi
mov    %r12,%rsi
call   1030 <fputc@plt>
mov    0x0(%r13),%edx
lea    0xe49(%rip),%rsi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <fprintf@plt>
cmp    $0x2,%r15d
jl     11fb <fprint_perm+0xbb>
mov    %r15d,%ebx
mov    $0x1,%ebp
lea    0xe29(%rip),%r15
nopw   0x0(%rax,%rax,1)
mov    0x0(%r13,%rbp,4),%edx
mov    %r12,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    11e0 <fprint_perm+0xa0>
mov    $0x29,%edi
mov    %r12,%rsi
call   1030 <fputc@plt>
test   %r14d,%r14d
jne    1188 <fprint_perm+0x48>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
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 @fprint_perm(i32* %0, i32* %1, i32 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load i32*, i32** %6
%11 = load i32, i32* %7
%12 = call i64 @isid(i32* %10, i32 %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %4
%15 = load i32*, i32** %5
%16 = call i32 (i32*, i8*, ...) @fprintf(i32* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %43
17: ; preds = %4
%18 = load i32*, i32** %5
%19 = call i32 (i32*, i8*, ...) @fprintf(i32* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%20 = load i32*, i32** %5
%21 = load i32*, i32** %6
%22 = getelementptr inbounds i32, i32* %21, i64 0
%23 = load i32, i32* %22
%24 = call i32 (i32*, i8*, ...) @fprintf(i32* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %23)
store i32 1, i32* %9
br label %25
25: ; preds = %37, %17
%26 = load i32, i32* %9
%27 = load i32, i32* %7
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %40
29: ; preds = %25
%30 = load i32*, i32** %5
%31 = load i32*, i32** %6
%32 = load i32, i32* %9
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i32, i32* %31, i64 %33
%35 = load i32, i32* %34
%36 = call i32 (i32*, i8*, ...) @fprintf(i32* %30, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %35)
br label %37
37: ; preds = %29
%38 = load i32, i32* %9
%39 = add nsw i32 %38, 1
store i32 %39, i32* %9
br label %25
40: ; preds = %25
%41 = load i32*, i32** %5
%42 = call i32 (i32*, i8*, ...) @fprintf(i32* %41, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %43
43: ; preds = %40, %14
%44 = load i32, i32* %8
%45 = icmp ne i32 %44, 0
br i1 %45, label %46, label %49
46: ; preds = %43
%47 = load i32*, i32** %5
%48 = call i32 (i32*, i8*, ...) @fprintf(i32* %47, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %49
49: ; preds = %46, %43
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 @fprint_perm(i32* nocapture %0, i32* %1, i32 %2, i32 %3) {
%5 = tail call i64 @isid(i32* %1, i32 %2)
%6 = icmp eq i64 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %4
%8 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i64 2, i64 1, i32* %0)
br label %25
9: ; preds = %4
%10 = tail call i32 @fputc(i32 40, i32* %0)
%11 = load i32, i32* %1
%12 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%13 = icmp sgt i32 %2, 1
br i1 %13, label %14, label %23
14: ; preds = %9
%15 = zext i32 %2 to i64
br label %16
16: ; preds = %14, %16
%17 = phi i64 [ 1, %14 ], [ %21, %16 ]
%18 = getelementptr inbounds i32, i32* %1, i64 %17
%19 = load i32, i32* %18
%20 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %19)
%21 = add nuw nsw i64 %17, 1
%22 = icmp eq i64 %21, %15
br i1 %22, label %23, label %16
23: ; preds = %16, %9
%24 = tail call i32 @fputc(i32 41, i32* %0)
br label %25
25: ; preds = %23, %7
%26 = icmp eq i32 %3, 0
br i1 %26, label %29, label %27
27: ; preds = %25
%28 = tail call i32 @fputc(i32 10, i32* %0)
br label %29
29: ; preds = %27, %25
ret void
}