#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*/ ShowErrorMessage(char *, char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
void AppendSolutionsMatrixZone(int iZone, int iRun, int puno, int R[],
                               char savename[], int iOutputType,
                               int iIncludeHeaders) {
  FILE *fp;
  int j;
  char sDelimiter[20];
  fp = fopen(savename, "a");
  if (!fp)
    ShowErrorMessage("Cannot save output to %s \n", savename);
  if (iOutputType == 3)
    strcpy(sDelimiter, ",");
  else
    strcpy(sDelimiter, "    ");
  if (iIncludeHeaders == 1) {
    fprintf(fp, "S%i%s", iRun, sDelimiter);
  }
  for (j = 0; j < puno; j++) {
    if (j > 0)
      fprintf(fp, "%s", sDelimiter);
    if (R[j] == iZone)
      fprintf(fp, "1");
    else
      fprintf(fp, "0");
  }
  fprintf(fp, "\n");
  fclose(fp);
}


x86 assembly (clang, -O0):
<AppendSolutionsMatrixZone>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x10(%rbp),%eax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe85(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    119f <AppendSolutionsMatrixZone+0x4f>
mov    -0x20(%rbp),%rsi
lea    0xe68(%rip),%rdi
call   1070 <ShowErrorMessage@plt>
cmpl   $0x3,-0x24(%rbp)
jne    11be <AppendSolutionsMatrixZone+0x6e>
lea    -0x50(%rbp),%rdi
lea    0xe69(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11ce <AppendSolutionsMatrixZone+0x7e>
lea    -0x50(%rbp),%rdi
lea    0xe56(%rip),%rsi
call   1030 <strcpy@plt>
cmpl   $0x1,0x10(%rbp)
jne    11f1 <AppendSolutionsMatrixZone+0xa1>
mov    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%edx
lea    -0x50(%rbp),%rcx
lea    0xe3a(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1274 <AppendSolutionsMatrixZone+0x124>
cmpl   $0x0,-0x34(%rbp)
jle    1224 <AppendSolutionsMatrixZone+0xd4>
mov    -0x30(%rbp),%rdi
lea    -0x50(%rbp),%rdx
lea    0xe0a(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x4(%rbp),%eax
jne    124f <AppendSolutionsMatrixZone+0xff>
mov    -0x30(%rbp),%rdi
lea    0xde7(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    1261 <AppendSolutionsMatrixZone+0x111>
mov    -0x30(%rbp),%rdi
lea    0xdd2(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    1266 <AppendSolutionsMatrixZone+0x116>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11f8 <AppendSolutionsMatrixZone+0xa8>
mov    -0x30(%rbp),%rdi
lea    0xd9c(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AppendSolutionsMatrixZone>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9d,%ebp
mov    %r8,%r12
mov    %rcx,%r14
mov    %edx,%r15d
mov    %esi,0xc(%rsp)
mov    %edi,%r13d
lea    0xe68(%rip),%rsi
mov    %r8,%rdi
call   1080 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11b7 <AppendSolutionsMatrixZone+0x47>
lea    0xe53(%rip),%rdi
mov    %r12,%rsi
call   1090 <ShowErrorMessage@plt>
cmp    $0x3,%ebp
lea    0xe5c(%rip),%rax
lea    0xe57(%rip),%rsi
cmove  %rax,%rsi
lea    0x10(%rsp),%rdi
call   1030 <strcpy@plt>
cmpl   $0x1,0x60(%rsp)
jne    11f7 <AppendSolutionsMatrixZone+0x87>
lea    0xe40(%rip),%rsi
lea    0x10(%rsp),%rcx
mov    %rbx,%rdi
mov    0xc(%rsp),%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
test   %r15d,%r15d
jle    1259 <AppendSolutionsMatrixZone+0xe9>
xor    %edi,%edi
cmp    %r13d,(%r14)
sete   %dil
or     $0x30,%edi
mov    %rbx,%rsi
call   1060 <fputc@plt>
cmp    $0x1,%r15d
je     1259 <AppendSolutionsMatrixZone+0xe9>
mov    %r15d,%r12d
mov    $0x1,%ebp
lea    0x10(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <fputs@plt>
xor    %edi,%edi
cmp    %r13d,(%r14,%rbp,4)
sete   %dil
or     $0x30,%edi
mov    %rbx,%rsi
call   1060 <fputc@plt>
add    $0x1,%rbp
cmp    %rbp,%r12
jne    1230 <AppendSolutionsMatrixZone+0xc0>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1060 <fputc@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"a\00"
@.str.1 = [27 x i8] c"Cannot save output to %s \0A\00"
@.str.2 = [2 x i8] c",\00"
@.str.3 = [5 x i8] c" \00"
@.str.4 = [6 x i8] c"S%i%s\00"
@.str.5 = [3 x i8] c"%s\00"
@.str.6 = [2 x i8] c"1\00"
@.str.7 = [2 x i8] c"0\00"
@.str.8 = [2 x i8] c"\0A\00"
define void @AppendSolutionsMatrixZone(i32 %0, i32 %1, i32 %2, i32* %3, i8* %4, i32 %5, i32 %6) {
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32*
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32*
%16 = alloca i32
%17 = alloca [20 x i8]
store i32 %0, i32* %8
store i32 %1, i32* %9
store i32 %2, i32* %10
store i32* %3, i32** %11
store i8* %4, i8** %12
store i32 %5, i32* %13
store i32 %6, i32* %14
%18 = load i8*, i8** %12
%19 = call i32* @fopen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %19, i32** %15
%20 = load i32*, i32** %15
%21 = icmp ne i32* %20, null
br i1 %21, label %25, label %22
22: ; preds = %7
%23 = load i8*, i8** %12
%24 = call i32 @ShowErrorMessage(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %23)
br label %25
25: ; preds = %22, %7
%26 = load i32, i32* %13
%27 = icmp eq i32 %26, 3
br i1 %27, label %28, label %31
28: ; preds = %25
%29 = getelementptr inbounds [20 x i8], [20 x i8]* %17, i64 0, i64 0
%30 = call i32 @strcpy(i8* %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %34
31: ; preds = %25
%32 = getelementptr inbounds [20 x i8], [20 x i8]* %17, i64 0, i64 0
%33 = call i32 @strcpy(i8* %32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %34
34: ; preds = %31, %28
%35 = load i32, i32* %14
%36 = icmp eq i32 %35, 1
br i1 %36, label %37, label %42
37: ; preds = %34
%38 = load i32*, i32** %15
%39 = load i32, i32* %9
%40 = getelementptr inbounds [20 x i8], [20 x i8]* %17, i64 0, i64 0
%41 = call i32 (i32*, i8*, ...) @fprintf(i32* %38, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %39, i8* %40)
br label %42
42: ; preds = %37, %34
store i32 0, i32* %16
br label %43
43: ; preds = %69, %42
%44 = load i32, i32* %16
%45 = load i32, i32* %10
%46 = icmp slt i32 %44, %45
br i1 %46, label %47, label %72
47: ; preds = %43
%48 = load i32, i32* %16
%49 = icmp sgt i32 %48, 0
br i1 %49, label %50, label %54
50: ; preds = %47
%51 = load i32*, i32** %15
%52 = getelementptr inbounds [20 x i8], [20 x i8]* %17, i64 0, i64 0
%53 = call i32 (i32*, i8*, ...) @fprintf(i32* %51, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %52)
br label %54
54: ; preds = %50, %47
%55 = load i32*, i32** %11
%56 = load i32, i32* %16
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i32, i32* %55, i64 %57
%59 = load i32, i32* %58
%60 = load i32, i32* %8
%61 = icmp eq i32 %59, %60
br i1 %61, label %62, label %65
62: ; preds = %54
%63 = load i32*, i32** %15
%64 = call i32 (i32*, i8*, ...) @fprintf(i32* %63, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %68
65: ; preds = %54
%66 = load i32*, i32** %15
%67 = call i32 (i32*, i8*, ...) @fprintf(i32* %66, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %68
68: ; preds = %65, %62
br label %69
69: ; preds = %68
%70 = load i32, i32* %16
%71 = add nsw i32 %70, 1
store i32 %71, i32* %16
br label %43
72: ; preds = %43
%73 = load i32*, i32** %15
%74 = call i32 (i32*, i8*, ...) @fprintf(i32* %73, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%75 = load i32*, i32** %15
%76 = call i32 @fclose(i32* %75)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"a\00"
@.str.1 = [27 x i8] c"Cannot save output to %s \0A\00"
@.str.2 = [2 x i8] c",\00"
@.str.3 = [5 x i8] c" \00"
@.str.4 = [6 x i8] c"S%i%s\00"
define void @AppendSolutionsMatrixZone(i32 %0, i32 %1, i32 %2, i32* nocapture %3, i8* %4, i32 %5, i32 %6) {
%8 = alloca [20 x i8]
%9 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 0
%10 = tail call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = tail call i32 @ShowErrorMessage(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %4)
br label %14
14: ; preds = %12, %7
%15 = icmp eq i32 %5, 3
%16 = select i1 %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0)
%17 = call i32 @strcpy(i8* %9, i8* %16)
%18 = icmp eq i32 %6, 1
br i1 %18, label %19, label %21
19: ; preds = %14
%20 = call i32 (i32*, i8*, ...) @fprintf(i32* %10, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %1, i8* %9)
br label %21
21: ; preds = %19, %14
%22 = icmp sgt i32 %2, 0
br i1 %22, label %23, label %40
23: ; preds = %21
%24 = zext i32 %2 to i64
%25 = load i32, i32* %3
%26 = icmp eq i32 %25, %0
%27 = select i1 %26, i32 49, i32 48
%28 = call i32 @fputc(i32 %27, i32* %10)
%29 = icmp eq i32 %2, 1
br i1 %29, label %40, label %30
30: ; preds = %23, %30
%31 = phi i64 [ %38, %30 ], [ 1, %23 ]
%32 = call i32 @fputs(i8* %9, i32* %10)
%33 = getelementptr inbounds i32, i32* %3, i64 %31
%34 = load i32, i32* %33
%35 = icmp eq i32 %34, %0
%36 = select i1 %35, i32 49, i32 48
%37 = call i32 @fputc(i32 %36, i32* %10)
%38 = add nuw nsw i64 %31, 1
%39 = icmp eq i64 %38, %24
br i1 %39, label %40, label %30
40: ; preds = %30, %23, %21
%41 = call i32 @fputc(i32 10, i32* %10)
%42 = call i32 @fclose(i32* %10)
ret void
}