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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
void generate_complete(uint32_t len) {
  FILE *f;
  uint32_t i;
  f = fopen("out", "w+");
  for (i = 1; i <= len; i++) {
    fprintf(f, "%d -->", i);
    uint32_t j;
    for (j = 1; j <= len; j++) {
      if (j != i) {
        fprintf(f, " %d", j);
      }
    }
    fprintf(f, "\n");
    if (i != len)
      fprintf(f, "\n");
  }
  fclose(f);
}


x86 assembly (clang, -O0):
<generate_complete>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
lea    0xebe(%rip),%rdi
lea    0xebb(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     1204 <generate_complete+0xd4>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xe94(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     11c1 <generate_complete+0x91>
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
je     11ae <generate_complete+0x7e>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%edx
lea    0xe67(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    11b3 <generate_complete+0x83>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1181 <generate_complete+0x51>
mov    -0x10(%rbp),%rdi
lea    0xe46(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
je     11f1 <generate_complete+0xc1>
mov    -0x10(%rbp),%rdi
lea    0xe28(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    11f6 <generate_complete+0xc6>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1159 <generate_complete+0x29>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate_complete>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%ebp
lea    0xeac(%rip),%rdi
lea    0xea9(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
test   %ebp,%ebp
jle    1218 <generate_complete+0xd8>
mov    %ebp,%r14d
neg    %r14d
mov    $0x1,%r12d
lea    0xe90(%rip),%r13
xor    %r15d,%r15d
mov    %ebp,0x4(%rsp)
jmp    11a1 <generate_complete+0x61>
nopw   0x0(%rax,%rax,1)
lea    0x1(%r12),%eax
add    $0xffffffff,%r15d
cmp    %ebp,%r12d
mov    %eax,%r12d
je     1218 <generate_complete+0xd8>
mov    %rbx,%rdi
lea    0xe5c(%rip),%rsi
mov    %r12d,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%ebp
jmp    11d3 <generate_complete+0x93>
nopl   0x0(%rax)
lea    (%r14,%rbp,1),%eax
add    $0x1,%eax
mov    %ebp,%ecx
add    $0x1,%ecx
mov    %ecx,%ebp
cmp    $0x1,%eax
je     11f0 <generate_complete+0xb0>
lea    (%r15,%rbp,1),%eax
cmp    $0x1,%eax
je     11c0 <generate_complete+0x80>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    11c0 <generate_complete+0x80>
nopl   (%rax)
mov    $0xa,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
mov    0x4(%rsp),%ebp
cmp    %ebp,%r12d
je     1190 <generate_complete+0x50>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
jmp    1190 <generate_complete+0x50>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"out\00"
@.str.1 = [3 x i8] c"w+\00"
@.str.2 = [7 x i8] c"%d -->\00"
@.str.3 = [4 x i8] c" %d\00"
@.str.4 = [2 x i8] c"\0A\00"
define void @generate_complete(i32 %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
%6 = call i32* @fopen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %6, i32** %3
store i32 1, i32* %4
br label %7
7: ; preds = %41, %1
%8 = load i32, i32* %4
%9 = load i32, i32* %2
%10 = icmp sle i32 %8, %9
br i1 %10, label %11, label %44
11: ; preds = %7
%12 = load i32*, i32** %3
%13 = load i32, i32* %4
%14 = call i32 (i32*, i8*, ...) @fprintf(i32* %12, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %13)
store i32 1, i32* %5
br label %15
15: ; preds = %28, %11
%16 = load i32, i32* %5
%17 = load i32, i32* %2
%18 = icmp sle i32 %16, %17
br i1 %18, label %19, label %31
19: ; preds = %15
%20 = load i32, i32* %5
%21 = load i32, i32* %4
%22 = icmp ne i32 %20, %21
br i1 %22, label %23, label %27
23: ; preds = %19
%24 = load i32*, i32** %3
%25 = load i32, i32* %5
%26 = call i32 (i32*, i8*, ...) @fprintf(i32* %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %25)
br label %27
27: ; preds = %23, %19
br label %28
28: ; preds = %27
%29 = load i32, i32* %5
%30 = add nsw i32 %29, 1
store i32 %30, i32* %5
br label %15
31: ; preds = %15
%32 = load i32*, i32** %3
%33 = call i32 (i32*, i8*, ...) @fprintf(i32* %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%34 = load i32, i32* %4
%35 = load i32, i32* %2
%36 = icmp ne i32 %34, %35
br i1 %36, label %37, label %40
37: ; preds = %31
%38 = load i32*, i32** %3
%39 = call i32 (i32*, i8*, ...) @fprintf(i32* %38, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %40
40: ; preds = %37, %31
br label %41
41: ; preds = %40
%42 = load i32, i32* %4
%43 = add nsw i32 %42, 1
store i32 %43, i32* %4
br label %7
44: ; preds = %7
%45 = load i32*, i32** %3
%46 = call i32 @fclose(i32* %45)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"out\00"
@.str.1 = [3 x i8] c"w+\00"
@.str.2 = [7 x i8] c"%d -->\00"
@.str.3 = [4 x i8] c" %d\00"
define void @generate_complete(i32 %0) {
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp slt i32 %0, 1
br i1 %3, label %23, label %4
4: ; preds = %1, %20
%5 = phi i32 [ %21, %20 ], [ 1, %1 ]
%6 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %5)
br label %7
7: ; preds = %4, %12
%8 = phi i32 [ %13, %12 ], [ 1, %4 ]
%9 = icmp eq i32 %8, %5
br i1 %9, label %12, label %10
10: ; preds = %7
%11 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %8)
br label %12
12: ; preds = %7, %10
%13 = add nuw i32 %8, 1
%14 = icmp eq i32 %8, %0
br i1 %14, label %15, label %7
15: ; preds = %12
%16 = tail call i32 @fputc(i32 10, i32* %2)
%17 = icmp eq i32 %5, %0
br i1 %17, label %20, label %18
18: ; preds = %15
%19 = tail call i32 @fputc(i32 10, i32* %2)
br label %20
20: ; preds = %18, %15
%21 = add nuw i32 %5, 1
%22 = icmp eq i32 %5, %0
br i1 %22, label %23, label %4
23: ; preds = %20, %1
%24 = tail call i32 @fclose(i32* %2)
ret void
}