#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ *stdout;
void assign_out_normal(int nvtxs, int *sets, char *outname) {
  FILE *fout;
  int i;
  if (outname != NULL) {
    fout = fopen(outname, "w");
  } else {
    fout = stdout;
  }
  for (i = 1; i <= nvtxs; i++) {
    fprintf(fout, "%d\n", sets[i]);
  }
  if (outname != NULL) {
    fclose(fout);
  }
}


x86 assembly (clang, -O0):
<assign_out_normal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1167 <assign_out_normal+0x37>
mov    -0x18(%rbp),%rdi
lea    0xea7(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x20(%rbp)
jmp    1175 <assign_out_normal+0x45>
mov    0x2e72(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     11b1 <assign_out_normal+0x81>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe64(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    117c <assign_out_normal+0x4c>
cmpq   $0x0,-0x18(%rbp)
je     11c5 <assign_out_normal+0x95>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<assign_out_normal>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %edi,%r12d
test   %rdx,%rdx
je     1162 <assign_out_normal+0x32>
lea    0xeb0(%rip),%rsi
mov    %r14,%rdi
call   1050 <fopen@plt>
mov    %rax,%rbx
test   %r12d,%r12d
jg     1171 <assign_out_normal+0x41>
jmp    11a8 <assign_out_normal+0x78>
mov    0x2e77(%rip),%rax
mov    (%rax),%rbx
test   %r12d,%r12d
jle    11a8 <assign_out_normal+0x78>
add    $0x1,%r12d
mov    $0x1,%ebp
lea    0xe81(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r15,%rbp,4),%edx
mov    %rbx,%rdi
mov    %r13,%rsi
call   1040 <fprintf@plt>
add    $0x1,%rbp
cmp    %rbp,%r12
jne    1190 <assign_out_normal+0x60>
test   %r14,%r14
je     11c3 <assign_out_normal+0x93>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c"w\00"
@stdout = global i32* null
@.str.1 = [4 x i8] c"%d\0A\00"
define void @assign_out_normal(i32 %0, i32* nocapture %1, i8* %2) {
%4 = icmp eq i8* %2, null
br i1 %4, label %7, label %5
5: ; preds = %3
%6 = tail call i32* @fopen(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %9
7: ; preds = %3
%8 = load i32*, i32** @stdout
br label %9
9: ; preds = %7, %5
%10 = phi i32* [ %6, %5 ], [ %8, %7 ]
%11 = icmp slt i32 %0, 1
br i1 %11, label %22, label %12
12: ; preds = %9
%13 = add nuw i32 %0, 1
%14 = zext i32 %13 to i64
br label %15
15: ; preds = %12, %15
%16 = phi i64 [ 1, %12 ], [ %20, %15 ]
%17 = getelementptr inbounds i32, i32* %1, i64 %16
%18 = load i32, i32* %17
%19 = tail call i32 @fprintf(i32* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, 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, %9
br i1 %4, label %25, label %23
23: ; preds = %22
%24 = tail call i32 @fclose(i32* %10)
br label %25
25: ; preds = %23, %22
ret void
}