#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_dandelion(uint32_t len) {
  FILE *f;
  uint32_t i;
  f = fopen("out", "w+");
  fprintf(f, "1 -->");
  for (i = 2; i <= len; i++) {
    fprintf(f, " %d", i);
  }
  fprintf(f, "\n\n");
  for (i = 2; i <= len; i++) {
    if (i == 2) {
      fprintf(f, "2 --> 1 3\n");
    } else if (i == len) {
      fprintf(f, "%d --> 1 %d\n", len, len - 1);
    } else {
      fprintf(f, "%d --> 1 %d %d\n", i, i - 1, i + 1);
    }
    if (i != len)
      fprintf(f, "\n");
  }
  fclose(f);
}


x86 assembly (clang, -O0):
<generate_dandelion>:
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)
mov    -0x10(%rbp),%rdi
lea    0xeaa(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x2,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     119a <generate_dandelion+0x6a>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xe88(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116b <generate_dandelion+0x3b>
mov    -0x10(%rbp),%rdi
lea    0xe6c(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x2,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     1265 <generate_dandelion+0x135>
cmpl   $0x2,-0x14(%rbp)
jne    11e0 <generate_dandelion+0xb0>
mov    -0x10(%rbp),%rdi
lea    0xe40(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    1234 <generate_dandelion+0x104>
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jne    120c <generate_dandelion+0xdc>
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%edx
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
lea    0xe1f(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    122f <generate_dandelion+0xff>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x14(%rbp),%r8d
add    $0x1,%r8d
lea    0xe04(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    1234 <generate_dandelion+0x104>
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
je     1252 <generate_dandelion+0x122>
mov    -0x10(%rbp),%rdi
lea    0xdc7(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    1257 <generate_dandelion+0x127>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b3 <generate_dandelion+0x83>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate_dandelion>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%r12d
lea    0xe9b(%rip),%rdi
lea    0xe98(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r15
lea    0xe8c(%rip),%rdi
mov    $0x5,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1070 <fwrite@plt>
cmp    $0x2,%r12d
jge    11ae <generate_dandelion+0x5e>
lea    0xe77(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1070 <fwrite@plt>
jmp    1220 <generate_dandelion+0xd0>
mov    %r12d,%r14d
neg    %r14d
mov    $0x2,%ebx
lea    0xe4d(%rip),%rbp
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    (%r14,%rbx,1),%eax
add    $0x1,%eax
mov    %ebx,%ecx
add    $0x1,%ecx
mov    %ecx,%ebx
cmp    $0x1,%eax
jne    11c0 <generate_dandelion+0x70>
lea    0xe28(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1070 <fwrite@plt>
cmp    $0x2,%r12d
jl     1220 <generate_dandelion+0xd0>
lea    0xe0c(%rip),%rdi
mov    $0xa,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1070 <fwrite@plt>
cmp    $0x2,%r12d
jne    1236 <generate_dandelion+0xe6>
mov    %r15,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>
lea    -0x1(%r12),%r13d
mov    $0xa,%edi
mov    %r15,%rsi
call   1040 <fputc@plt>
mov    $0x2,%ecx
jmp    1259 <generate_dandelion+0x109>
nop
mov    %r14d,%eax
mov    %ebp,%ecx
add    %ebp,%eax
je     1220 <generate_dandelion+0xd0>
lea    (%r14,%rcx,1),%ebx
lea    0x1(%rcx),%ebp
cmp    $0xffffffff,%ebx
je     1290 <generate_dandelion+0x140>
lea    0x2(%rcx),%r8d
mov    %r15,%rdi
lea    0xdb9(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
cmp    $0xffffffff,%ebx
jne    12ac <generate_dandelion+0x15c>
jmp    1250 <generate_dandelion+0x100>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15,%rdi
lea    0xd85(%rip),%rsi
mov    %r12d,%edx
mov    %r13d,%ecx
xor    %eax,%eax
call   1050 <fprintf@plt>
cmp    $0xffffffff,%ebx
je     1250 <generate_dandelion+0x100>
mov    $0xa,%edi
mov    %r15,%rsi
call   1040 <fputc@plt>
jmp    1250 <generate_dandelion+0x100>

LLVM IR (-O0):
@.str = [4 x i8] c"out\00"
@.str.1 = [3 x i8] c"w+\00"
@.str.2 = [6 x i8] c"1 -->\00"
@.str.3 = [4 x i8] c" %d\00"
@.str.4 = [3 x i8] c"\0A\0A\00"
@.str.5 = [11 x i8] c"2 --> 1 3\0A\00"
@.str.6 = [13 x i8] c"%d --> 1 %d\0A\00"
@.str.7 = [16 x i8] c"%d --> 1 %d %d\0A\00"
@.str.8 = [2 x i8] c"\0A\00"
define void @generate_dandelion(i32 %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
store i32 %0, i32* %2
%5 = 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* %5, i32** %3
%6 = load i32*, i32** %3
%7 = call i32 (i32*, i8*, ...) @fprintf(i32* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
store i32 2, i32* %4
br label %8
8: ; preds = %16, %1
%9 = load i32, i32* %4
%10 = load i32, i32* %2
%11 = icmp sle i32 %9, %10
br i1 %11, label %12, label %19
12: ; preds = %8
%13 = load i32*, i32** %3
%14 = load i32, i32* %4
%15 = call i32 (i32*, i8*, ...) @fprintf(i32* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %14)
br label %16
16: ; preds = %12
%17 = load i32, i32* %4
%18 = add nsw i32 %17, 1
store i32 %18, i32* %4
br label %8
19: ; preds = %8
%20 = load i32*, i32** %3
%21 = call i32 (i32*, i8*, ...) @fprintf(i32* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32 2, i32* %4
br label %22
22: ; preds = %59, %19
%23 = load i32, i32* %4
%24 = load i32, i32* %2
%25 = icmp sle i32 %23, %24
br i1 %25, label %26, label %62
26: ; preds = %22
%27 = load i32, i32* %4
%28 = icmp eq i32 %27, 2
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = load i32*, i32** %3
%31 = call i32 (i32*, i8*, ...) @fprintf(i32* %30, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
br label %51
32: ; preds = %26
%33 = load i32, i32* %4
%34 = load i32, i32* %2
%35 = icmp eq i32 %33, %34
br i1 %35, label %36, label %42
36: ; preds = %32
%37 = load i32*, i32** %3
%38 = load i32, i32* %2
%39 = load i32, i32* %2
%40 = sub nsw i32 %39, 1
%41 = call i32 (i32*, i8*, ...) @fprintf(i32* %37, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i32 %38, i32 %40)
br label %50
42: ; preds = %32
%43 = load i32*, i32** %3
%44 = load i32, i32* %4
%45 = load i32, i32* %4
%46 = sub nsw i32 %45, 1
%47 = load i32, i32* %4
%48 = add nsw i32 %47, 1
%49 = call i32 (i32*, i8*, ...) @fprintf(i32* %43, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i32 %44, i32 %46, i32 %48)
br label %50
50: ; preds = %42, %36
br label %51
51: ; preds = %50, %29
%52 = load i32, i32* %4
%53 = load i32, i32* %2
%54 = icmp ne i32 %52, %53
br i1 %54, label %55, label %58
55: ; preds = %51
%56 = load i32*, i32** %3
%57 = call i32 (i32*, i8*, ...) @fprintf(i32* %56, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %58
58: ; preds = %55, %51
br label %59
59: ; preds = %58
%60 = load i32, i32* %4
%61 = add nsw i32 %60, 1
store i32 %61, i32* %4
br label %22
62: ; preds = %22
%63 = load i32*, i32** %3
%64 = call i32 @fclose(i32* %63)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"out\00"
@.str.1 = [3 x i8] c"w+\00"
@.str.2 = [6 x i8] c"1 -->\00"
@.str.3 = [4 x i8] c" %d\00"
@.str.4 = [3 x i8] c"\0A\0A\00"
@.str.5 = [11 x i8] c"2 --> 1 3\0A\00"
@.str.6 = [13 x i8] c"%d --> 1 %d\0A\00"
@.str.7 = [16 x i8] c"%d --> 1 %d %d\0A\00"
define void @generate_dandelion(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 = tail call i64 @fwrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 5, i64 1, i32* %2)
%4 = icmp slt i32 %0, 2
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i64 2, i64 1, i32* %2)
br label %36
7: ; preds = %1, %7
%8 = phi i32 [ %10, %7 ], [ 2, %1 ]
%9 = 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)
%10 = add nuw i32 %8, 1
%11 = icmp eq i32 %8, %0
br i1 %11, label %12, label %7
12: ; preds = %7
%13 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i64 2, i64 1, i32* %2)
br i1 %4, label %36, label %14
14: ; preds = %12
%15 = add nsw i32 %0, -1
%16 = tail call i64 @fwrite(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i64 10, i64 1, i32* %2)
%17 = icmp eq i32 %0, 2
br i1 %17, label %36, label %18
18: ; preds = %14
%19 = tail call i32 @fputc(i32 10, i32* %2)
br label %20
20: ; preds = %33, %18
%21 = phi i32 [ 3, %18 ], [ %34, %33 ]
%22 = icmp eq i32 %21, %0
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %2, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i32 %0, i32 %15)
br label %29
25: ; preds = %20
%26 = add nsw i32 %21, -1
%27 = add nuw nsw i32 %21, 1
%28 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %2, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i32 %21, i32 %26, i32 %27)
br label %29
29: ; preds = %23, %25
%30 = icmp eq i32 %21, %0
br i1 %30, label %33, label %31
31: ; preds = %29
%32 = tail call i32 @fputc(i32 10, i32* %2)
br label %33
33: ; preds = %29, %31
%34 = add nuw i32 %21, 1
%35 = icmp eq i32 %21, %0
br i1 %35, label %36, label %20
36: ; preds = %33, %14, %5, %12
%37 = tail call i32 @fclose(i32* %2)
ret void
}