#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, ...);
int /*<<< orphan*/ printf(char *, char *);
int scg_write_front(int nV, int nF, double *Vertex, int *Index, char *file) {
  FILE *f;
  int i, c = 0;
  if (!(f = fopen(file, "w")))
    return -1;
  fprintf(f, "%d %d\n", nV, nF);
  for (i = 0; i < nV; i++)
    fprintf(f, "%20.15e %20.15e %20.15e\n", Vertex[3 * i + 0],
            Vertex[3 * i + 1], Vertex[3 * i + 2]);
  for (i = 0; i < nF; i++)
    fprintf(f, "%d %d %d  %d\n", Index[3 * i + 0], Index[3 * i + 1],
            Index[3 * i + 2], c);
  fclose(f);
  printf("%s written.\n", file);
  return 0;
}


x86 assembly (clang, -O0):
<scg_write_front>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xe94(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    118b <scg_write_front+0x4b>
movl   $0xffffffff,-0x4(%rbp)
jmp    129a <scg_write_front+0x15a>
mov    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xe66(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    120f <scg_write_front+0xcf>
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rax
imul   $0x3,-0x34(%rbp),%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
cvttsd2si (%rax,%rcx,8),%edx
mov    -0x18(%rbp),%rax
imul   $0x3,-0x34(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
cvttsd2si (%rax,%rcx,8),%ecx
mov    -0x18(%rbp),%rax
imul   $0x3,-0x34(%rbp),%esi
add    $0x2,%esi
movslq %esi,%rsi
movsd  (%rax,%rsi,8),%xmm0
lea    0xe0f(%rip),%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11aa <scg_write_front+0x6a>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    127a <scg_write_front+0x13a>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rax
imul   $0x3,-0x34(%rbp),%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x20(%rbp),%rax
imul   $0x3,-0x34(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%ecx
mov    -0x20(%rbp),%rax
imul   $0x3,-0x34(%rbp),%esi
add    $0x2,%esi
movslq %esi,%rsi
mov    (%rax,%rsi,4),%r8d
mov    -0x38(%rbp),%r9d
lea    0xdbd(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1216 <scg_write_front+0xd6>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x28(%rbp),%rsi
lea    0xda2(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scg_write_front>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,%r14
mov    %rcx,%rbx
mov    %rdx,%rbp
mov    %esi,%r12d
mov    %edi,%r13d
lea    0xe9c(%rip),%rsi
mov    %r8,%rdi
call   1060 <fopen@plt>
test   %rax,%rax
je     1252 <scg_write_front+0x112>
mov    %rax,%r15
mov    %r14,0x10(%rsp)
lea    0xe7e(%rip),%rsi
mov    %rax,%rdi
mov    %r13d,%edx
mov    %r12d,0xc(%rsp)
mov    %r12d,%ecx
xor    %eax,%eax
call   1050 <fprintf@plt>
test   %r13d,%r13d
jle    11eb <scg_write_front+0xab>
mov    %r13d,%eax
shl    $0x3,%rax
lea    (%rax,%rax,2),%r14
xor    %r12d,%r12d
lea    0xe56(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cvttsd2si 0x0(%rbp,%r12,1),%edx
cvttsd2si 0x8(%rbp,%r12,1),%ecx
movsd  0x10(%rbp,%r12,1),%xmm0
mov    %r15,%rdi
mov    %r13,%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
add    $0x18,%r12
cmp    %r12,%r14
jne    11c0 <scg_write_front+0x80>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    1235 <scg_write_front+0xf5>
mov    %eax,%eax
shl    $0x2,%rax
lea    (%rax,%rax,2),%r14
lea    0xe1e(%rip),%r12
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
mov    (%rbx,%rbp,1),%edx
mov    0x4(%rbx,%rbp,1),%ecx
mov    0x8(%rbx,%rbp,1),%r8d
mov    %r15,%rdi
mov    %r12,%rsi
xor    %r9d,%r9d
xor    %eax,%eax
call   1050 <fprintf@plt>
add    $0xc,%rbp
cmp    %rbp,%r14
jne    1210 <scg_write_front+0xd0>
mov    %r15,%rdi
call   1030 <fclose@plt>
lea    0xdec(%rip),%rdi
mov    0x10(%rsp),%rsi
call   1040 <printf@plt>
xor    %eax,%eax
jmp    1257 <scg_write_front+0x117>
mov    $0xffffffff,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"w\00"
@.str.1 = [7 x i8] c"%d %d\0A\00"
@.str.2 = [25 x i8] c"%20.15e %20.15e %20.15e\0A\00"
@.str.3 = [14 x i8] c"%d %d %d %d\0A\00"
@.str.4 = [13 x i8] c"%s written.\0A\00"
define i32 @scg_write_front(i32 %0, i32 %1, double* %2, i32* %3, i8* %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca double*
%10 = alloca i32*
%11 = alloca i8*
%12 = alloca i32*
%13 = alloca i32
%14 = alloca i32
store i32 %0, i32* %7
store i32 %1, i32* %8
store double* %2, double** %9
store i32* %3, i32** %10
store i8* %4, i8** %11
store i32 0, i32* %14
%15 = load i8*, i8** %11
%16 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %16, i32** %12
%17 = icmp ne i32* %16, null
br i1 %17, label %19, label %18
18: ; preds = %5
store i32 -1, i32* %6
br label %95
19: ; preds = %5
%20 = load i32*, i32** %12
%21 = load i32, i32* %7
%22 = load i32, i32* %8
%23 = call i32 (i32*, i8*, i32, i32, ...) @fprintf(i32* %20, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %21, i32 %22)
store i32 0, i32* %13
br label %24
24: ; preds = %54, %19
%25 = load i32, i32* %13
%26 = load i32, i32* %7
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %57
28: ; preds = %24
%29 = load i32*, i32** %12
%30 = load double*, double** %9
%31 = load i32, i32* %13
%32 = mul nsw i32 3, %31
%33 = add nsw i32 %32, 0
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds double, double* %30, i64 %34
%36 = load double, double* %35
%37 = fptosi double %36 to i32
%38 = load double*, double** %9
%39 = load i32, i32* %13
%40 = mul nsw i32 3, %39
%41 = add nsw i32 %40, 1
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds double, double* %38, i64 %42
%44 = load double, double* %43
%45 = fptosi double %44 to i32
%46 = load double*, double** %9
%47 = load i32, i32* %13
%48 = mul nsw i32 3, %47
%49 = add nsw i32 %48, 2
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds double, double* %46, i64 %50
%52 = load double, double* %51
%53 = call i32 (i32*, i8*, i32, i32, ...) @fprintf(i32* %29, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %37, i32 %45, double %52)
br label %54
54: ; preds = %28
%55 = load i32, i32* %13
%56 = add nsw i32 %55, 1
store i32 %56, i32* %13
br label %24
57: ; preds = %24
store i32 0, i32* %13
br label %58
58: ; preds = %87, %57
%59 = load i32, i32* %13
%60 = load i32, i32* %8
%61 = icmp slt i32 %59, %60
br i1 %61, label %62, label %90
62: ; preds = %58
%63 = load i32*, i32** %12
%64 = load i32*, i32** %10
%65 = load i32, i32* %13
%66 = mul nsw i32 3, %65
%67 = add nsw i32 %66, 0
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i32, i32* %64, i64 %68
%70 = load i32, i32* %69
%71 = load i32*, i32** %10
%72 = load i32, i32* %13
%73 = mul nsw i32 3, %72
%74 = add nsw i32 %73, 1
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds i32, i32* %71, i64 %75
%77 = load i32, i32* %76
%78 = load i32*, i32** %10
%79 = load i32, i32* %13
%80 = mul nsw i32 3, %79
%81 = add nsw i32 %80, 2
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds i32, i32* %78, i64 %82
%84 = load i32, i32* %83
%85 = load i32, i32* %14
%86 = call i32 (i32*, i8*, i32, i32, ...) @fprintf(i32* %63, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %70, i32 %77, i32 %84, i32 %85)
br label %87
87: ; preds = %62
%88 = load i32, i32* %13
%89 = add nsw i32 %88, 1
store i32 %89, i32* %13
br label %58
90: ; preds = %58
%91 = load i32*, i32** %12
%92 = call i32 @fclose(i32* %91)
%93 = load i8*, i8** %11
%94 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* %93)
store i32 0, i32* %6
br label %95
95: ; preds = %90, %18
%96 = load i32, i32* %6
ret i32 %96
}

LLVM IR (-O2):
@.str = [2 x i8] c"w\00"
@.str.1 = [7 x i8] c"%d %d\0A\00"
@.str.2 = [25 x i8] c"%20.15e %20.15e %20.15e\0A\00"
@.str.3 = [14 x i8] c"%d %d %d %d\0A\00"
@.str.4 = [13 x i8] c"%s written.\0A\00"
define i32 @scg_write_front(i32 %0, i32 %1, double* nocapture %2, i32* nocapture %3, i8* %4) {
%6 = tail call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %50, label %8
8: ; preds = %5
%9 = tail call i32 (i32*, i8*, i32, i32, ...) @fprintf(i32* %6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %0, i32 %1)
%10 = icmp sgt i32 %0, 0
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = zext i32 %0 to i64
br label %17
13: ; preds = %17, %8
%14 = icmp sgt i32 %1, 0
br i1 %14, label %15, label %47
15: ; preds = %13
%16 = zext i32 %1 to i64
br label %33
17: ; preds = %11, %17
%18 = phi i64 [ 0, %11 ], [ %31, %17 ]
%19 = mul nuw nsw i64 %18, 3
%20 = getelementptr inbounds double, double* %2, i64 %19
%21 = load double, double* %20
%22 = fptosi double %21 to i32
%23 = add nuw nsw i64 %19, 1
%24 = getelementptr inbounds double, double* %2, i64 %23
%25 = load double, double* %24
%26 = fptosi double %25 to i32
%27 = add nuw nsw i64 %19, 2
%28 = getelementptr inbounds double, double* %2, i64 %27
%29 = load double, double* %28
%30 = tail call i32 (i32*, i8*, i32, i32, ...) @fprintf(i32* %6, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %22, i32 %26, double %29)
%31 = add nuw nsw i64 %18, 1
%32 = icmp eq i64 %31, %12
br i1 %32, label %13, label %17
33: ; preds = %15, %33
%34 = phi i64 [ 0, %15 ], [ %45, %33 ]
%35 = mul nuw nsw i64 %34, 3
%36 = getelementptr inbounds i32, i32* %3, i64 %35
%37 = load i32, i32* %36
%38 = add nuw nsw i64 %35, 1
%39 = getelementptr inbounds i32, i32* %3, i64 %38
%40 = load i32, i32* %39
%41 = add nuw nsw i64 %35, 2
%42 = getelementptr inbounds i32, i32* %3, i64 %41
%43 = load i32, i32* %42
%44 = tail call i32 (i32*, i8*, i32, i32, ...) @fprintf(i32* %6, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %37, i32 %40, i32 %43, i32 0)
%45 = add nuw nsw i64 %34, 1
%46 = icmp eq i64 %45, %16
br i1 %46, label %47, label %33
47: ; preds = %33, %13
%48 = tail call i32 @fclose(i32* %6)
%49 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* %4)
br label %50
50: ; preds = %5, %47
%51 = phi i32 [ 0, %47 ], [ -1, %5 ]
ret i32 %51
}