#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_star(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");
  for (i = 2; i <= len; i++) {
    fprintf(f, "%d --> 1", i);
    if (i != len)
      fprintf(f, "\n");
  }
  fclose(f);
}


x86 assembly (clang, -O0):
<generate_star>:
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_star+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_star+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     1205 <generate_star+0xd5>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xe46(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
je     11f2 <generate_star+0xc2>
mov    -0x10(%rbp),%rdi
lea    0xe26(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    11f7 <generate_star+0xc7>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b3 <generate_star+0x83>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate_star>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edi,%r14d
lea    0xe9e(%rip),%rdi
lea    0xe9b(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r12
lea    0xe8f(%rip),%rdi
mov    $0x5,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1070 <fwrite@plt>
cmp    $0x2,%r14d
jge    119f <generate_star+0x4f>
mov    $0xa,%edi
mov    %r12,%rsi
call   1040 <fputc@plt>
jmp    11e4 <generate_star+0x94>
mov    %r14d,%ebx
neg    %ebx
mov    $0x2,%ebp
lea    0xe5d(%rip),%r15
mov    %r12,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    (%rbx,%rbp,1),%eax
add    $0x1,%eax
mov    %ebp,%ecx
add    $0x1,%ecx
mov    %ecx,%ebp
cmp    $0x1,%eax
jne    11b0 <generate_star+0x60>
mov    $0xa,%edi
mov    %r12,%rsi
call   1040 <fputc@plt>
cmp    $0x2,%r14d
jge    11f4 <generate_star+0xa4>
mov    %r12,%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>
mov    $0x2,%ebp
lea    0xe11(%rip),%r14
jmp    1222 <generate_star+0xd2>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    (%rbx,%rbp,1),%eax
add    $0x1,%eax
mov    %ebp,%ecx
add    $0x1,%ecx
mov    %ecx,%ebp
cmp    $0x1,%eax
je     11e4 <generate_star+0x94>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %ebx,%eax
add    %ebp,%eax
je     1210 <generate_star+0xc0>
mov    $0xa,%edi
mov    %r12,%rsi
call   1040 <fputc@plt>
jmp    1210 <generate_star+0xc0>

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 = [2 x i8] c"\0A\00"
@.str.5 = [9 x i8] c"%d --> 1\00"
define void @generate_star(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 ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32 2, i32* %4
br label %22
22: ; preds = %37, %19
%23 = load i32, i32* %4
%24 = load i32, i32* %2
%25 = icmp sle i32 %23, %24
br i1 %25, label %26, label %40
26: ; preds = %22
%27 = load i32*, i32** %3
%28 = load i32, i32* %4
%29 = call i32 (i32*, i8*, ...) @fprintf(i32* %27, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 %28)
%30 = load i32, i32* %4
%31 = load i32, i32* %2
%32 = icmp ne i32 %30, %31
br i1 %32, label %33, label %36
33: ; preds = %26
%34 = load i32*, i32** %3
%35 = call i32 (i32*, i8*, ...) @fprintf(i32* %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %36
36: ; preds = %33, %26
br label %37
37: ; preds = %36
%38 = load i32, i32* %4
%39 = add nsw i32 %38, 1
store i32 %39, i32* %4
br label %22
40: ; preds = %22
%41 = load i32*, i32** %3
%42 = call i32 @fclose(i32* %41)
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.5 = [9 x i8] c"%d --> 1\00"
define void @generate_star(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 i32 @fputc(i32 10, i32* %2)
br label %23
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 i32 @fputc(i32 10, i32* %2)
br i1 %4, label %23, label %14
14: ; preds = %12, %20
%15 = phi i32 [ %21, %20 ], [ 2, %12 ]
%16 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %2, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 %15)
%17 = icmp eq i32 %15, %0
br i1 %17, label %20, label %18
18: ; preds = %14
%19 = tail call i32 @fputc(i32 10, i32* %2)
br label %20
20: ; preds = %14, %18
%21 = add nuw i32 %15, 1
%22 = icmp eq i32 %15, %0
br i1 %22, label %23, label %14
23: ; preds = %20, %5, %12
%24 = tail call i32 @fclose(i32* %2)
ret void
}