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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, long, ...);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
int /*<<< orphan*/ nrerror(char *);
void write_usvector_number(ushort *v, long nl, long nh, char *format,
                           char *filename) {
  long k;
  FILE *f;
  f = fopen(filename, "wt");
  if (f == NULL) {
    nrerror("Can't open file in write_usvector_number");
  }
  for (k = nl; k <= nh; k++) {
    fprintf(f, format, k, k, k);
  }
  fputc('\n', f);
  for (k = nl; k <= nh; k++) {
    fprintf(f, format, v[k]);
  }
  fputc('\n', f);
  fclose(f);
}


x86 assembly (clang, -O0):
<write_usvector_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xe89(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1197 <write_usvector_number+0x47>
lea    0xe71(%rip),%rdi
call   1030 <nrerror@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x18(%rbp),%rax
jg     11d9 <write_usvector_number+0x89>
mov    -0x38(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    119f <write_usvector_number+0x4f>
mov    -0x38(%rbp),%rsi
mov    $0xa,%edi
call   1050 <fputc@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x18(%rbp),%rax
jg     1229 <write_usvector_number+0xd9>
mov    -0x38(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x8(%rbp),%rax
mov    -0x30(%rbp),%rcx
movslq (%rax,%rcx,4),%rdx
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    11ef <write_usvector_number+0x9f>
mov    -0x38(%rbp),%rsi
mov    $0xa,%edi
call   1050 <fputc@plt>
mov    -0x38(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_usvector_number>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%rbp
mov    %rsi,%rbx
mov    %rdi,%r12
lea    0xe92(%rip),%rsi
mov    %r8,%rdi
call   1070 <fopen@plt>
mov    %rax,%r15
test   %rax,%rax
je     1192 <write_usvector_number+0x42>
cmp    %rbp,%rbx
jle    11a3 <write_usvector_number+0x53>
mov    $0xa,%edi
mov    %r15,%rsi
call   1050 <fputc@plt>
jmp    120a <write_usvector_number+0xba>
lea    0xe6a(%rip),%rdi
call   1030 <nrerror@plt>
cmp    %rbp,%rbx
jg     1183 <write_usvector_number+0x33>
mov    %rbp,(%rsp)
lea    0x1(%rbp),%r13
mov    %rbx,%rbp
xchg   %ax,%ax
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbp,%rdx
mov    %rbp,%rcx
mov    %rbp,%r8
xor    %eax,%eax
call   1060 <fprintf@plt>
add    $0x1,%rbp
cmp    %rbp,%r13
jne    11b0 <write_usvector_number+0x60>
mov    $0xa,%edi
mov    %r15,%rsi
call   1050 <fputc@plt>
cmp    (%rsp),%rbx
jg     120a <write_usvector_number+0xba>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movslq (%r12,%rbx,4),%rdx
mov    %r15,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    11f0 <write_usvector_number+0xa0>
mov    $0xa,%edi
mov    %r15,%rsi
call   1050 <fputc@plt>
mov    %r15,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fclose@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"wt\00"
@.str.1 = [41 x i8] c"Can't open file in write_usvector_number\00"
define void @write_usvector_number(i32* %0, i64 %1, i64 %2, i8* %3, i8* %4) {
%6 = alloca i32*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i32*
store i32* %0, i32** %6
store i64 %1, i64* %7
store i64 %2, i64* %8
store i8* %3, i8** %9
store i8* %4, i8** %10
%13 = load i8*, i8** %10
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %14, i32** %12
%15 = load i32*, i32** %12
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %19
17: ; preds = %5
%18 = call i32 @nrerror(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
br label %19
19: ; preds = %17, %5
%20 = load i64, i64* %7
store i64 %20, i64* %11
br label %21
21: ; preds = %32, %19
%22 = load i64, i64* %11
%23 = load i64, i64* %8
%24 = icmp sle i64 %22, %23
br i1 %24, label %25, label %35
25: ; preds = %21
%26 = load i32*, i32** %12
%27 = load i8*, i8** %9
%28 = load i64, i64* %11
%29 = load i64, i64* %11
%30 = load i64, i64* %11
%31 = call i32 (i32*, i8*, i64, ...) @fprintf(i32* %26, i8* %27, i64 %28, i64 %29, i64 %30)
br label %32
32: ; preds = %25
%33 = load i64, i64* %11
%34 = add nsw i64 %33, 1
store i64 %34, i64* %11
br label %21
35: ; preds = %21
%36 = load i32*, i32** %12
%37 = call i32 @fputc(i8 signext 10, i32* %36)
%38 = load i64, i64* %7
store i64 %38, i64* %11
br label %39
39: ; preds = %52, %35
%40 = load i64, i64* %11
%41 = load i64, i64* %8
%42 = icmp sle i64 %40, %41
br i1 %42, label %43, label %55
43: ; preds = %39
%44 = load i32*, i32** %12
%45 = load i8*, i8** %9
%46 = load i32*, i32** %6
%47 = load i64, i64* %11
%48 = getelementptr inbounds i32, i32* %46, i64 %47
%49 = load i32, i32* %48
%50 = sext i32 %49 to i64
%51 = call i32 (i32*, i8*, i64, ...) @fprintf(i32* %44, i8* %45, i64 %50)
br label %52
52: ; preds = %43
%53 = load i64, i64* %11
%54 = add nsw i64 %53, 1
store i64 %54, i64* %11
br label %39
55: ; preds = %39
%56 = load i32*, i32** %12
%57 = call i32 @fputc(i8 signext 10, i32* %56)
%58 = load i32*, i32** %12
%59 = call i32 @fclose(i32* %58)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"wt\00"
@.str.1 = [41 x i8] c"Can't open file in write_usvector_number\00"
define void @write_usvector_number(i32* nocapture %0, i64 %1, i64 %2, i8* nocapture %3, i8* nocapture %4) {
%6 = tail call i32* @fopen(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = tail call i32 @nrerror(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
br label %10
10: ; preds = %8, %5
%11 = icmp sgt i64 %1, %2
br i1 %11, label %12, label %14
12: ; preds = %10
%13 = tail call i32 @fputc(i8 signext 10, i32* %6)
br label %29
14: ; preds = %10, %14
%15 = phi i64 [ %17, %14 ], [ %1, %10 ]
%16 = tail call i32 (i32*, i8*, i64, ...) @fprintf(i32* %6, i8* %3, i64 %15, i64 %15, i64 %15)
%17 = add i64 %15, 1
%18 = icmp eq i64 %15, %2
br i1 %18, label %19, label %14
19: ; preds = %14
%20 = tail call i32 @fputc(i8 signext 10, i32* %6)
br i1 %11, label %29, label %21
21: ; preds = %19, %21
%22 = phi i64 [ %27, %21 ], [ %1, %19 ]
%23 = getelementptr inbounds i32, i32* %0, i64 %22
%24 = load i32, i32* %23
%25 = sext i32 %24 to i64
%26 = tail call i32 (i32*, i8*, i64, ...) @fprintf(i32* %6, i8* %3, i64 %25)
%27 = add i64 %22, 1
%28 = icmp eq i64 %22, %2
br i1 %28, label %29, label %21
29: ; preds = %21, %12, %19
%30 = tail call i32 @fputc(i8 signext 10, i32* %6)
%31 = tail call i32 @fclose(i32* %6)
ret void
}