#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 *, ...);
void saveEquation(char *filename, int *equ, int numClauses) {
  FILE *file = fopen(filename, "w");
  for (int clause = 0; clause < numClauses; clause++) {
    for (int term = 0; term < 3; term++) {
      int ind = clause * 3 + term;
      if (term == 3 - 1)
        fprintf(file, "%d", equ[ind]);
      else
        fprintf(file, "%d ", equ[ind]);
    }
    if (clause < numClauses - 1)
      fprintf(file, "\n");
  }
  fclose(file);
}


x86 assembly (clang, -O0):
<saveEquation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeb2(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1217 <saveEquation+0xe7>
movl   $0x0,-0x28(%rbp)
cmpl   $0x3,-0x28(%rbp)
jge    11e1 <saveEquation+0xb1>
imul   $0x3,-0x24(%rbp),%eax
add    -0x28(%rbp),%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0x2,-0x28(%rbp)
jne    11b1 <saveEquation+0x81>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe5d(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    11ce <saveEquation+0x9e>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe3e(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    11d3 <saveEquation+0xa3>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1171 <saveEquation+0x41>
mov    -0x24(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1204 <saveEquation+0xd4>
mov    -0x20(%rbp),%rdi
lea    0xe0c(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    1209 <saveEquation+0xd9>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    115e <saveEquation+0x2e>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<saveEquation>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %rsi,%r14
lea    0xea8(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
test   %r15d,%r15d
jle    11db <saveEquation+0x9b>
lea    -0x1(%r15),%eax
mov    %rax,(%rsp)
mov    %r15d,%ebp
lea    0xe8e(%rip),%r15
xor    %r12d,%r12d
jmp    1189 <saveEquation+0x49>
nopl   0x0(%rax)
add    $0x1,%r12
cmp    %rbp,%r12
je     11db <saveEquation+0x9b>
lea    (%r12,%r12,2),%r13d
mov    (%r14,%r13,4),%edx
mov    %rbx,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x4(%r14,%r13,4),%edx
mov    %rbx,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x8(%r14,%r13,4),%edx
mov    %rbx,%rdi
lea    0xe43(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
cmp    (%rsp),%r12
jae    1180 <saveEquation+0x40>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
jmp    1180 <saveEquation+0x40>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>

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

LLVM IR (-O2):
@.str = [2 x i8] c"w\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"%d \00"
define void @saveEquation(i8* nocapture %0, i32* nocapture %1, i32 %2) {
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp sgt i32 %2, 0
br i1 %5, label %6, label %10
6: ; preds = %3
%7 = add nsw i32 %2, -1
%8 = zext i32 %7 to i64
%9 = zext i32 %2 to i64
br label %12
10: ; preds = %30, %3
%11 = tail call i32 @fclose(i32* %4)
ret void
12: ; preds = %6, %30
%13 = phi i64 [ 0, %6 ], [ %31, %30 ]
%14 = mul i64 %13, 3
%15 = and i64 %14, 4294967295
%16 = getelementptr inbounds i32, i32* %1, i64 %15
%17 = load i32, i32* %16
%18 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %17)
%19 = add nuw nsw i64 %15, 1
%20 = getelementptr inbounds i32, i32* %1, i64 %19
%21 = load i32, i32* %20
%22 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %21)
%23 = add nuw nsw i64 %15, 2
%24 = getelementptr inbounds i32, i32* %1, i64 %23
%25 = load i32, i32* %24
%26 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %25)
%27 = icmp ult i64 %13, %8
br i1 %27, label %28, label %30
28: ; preds = %12
%29 = tail call i32 @fputc(i32 10, i32* %4)
br label %30
30: ; preds = %12, %28
%31 = add nuw nsw i64 %13, 1
%32 = icmp eq i64 %31, %9
br i1 %32, label %10, label %12
}