#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 /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putc(char, int /*<<< orphan*/ *);
void writePlanFile(int layout[], int maxSeats, char plate[]) {
  FILE *plan;
  int i, c;
  plan = fopen("layout.txt", "w");
  fprintf(plan, "%s\n", plate);
  for (i = 0; i < (maxSeats - 5); i += 4) {
    for (c = 0; c <= 3; c++) {
      putc(layout[i + c] ? '*' : '_', plan);
      if (c == 1) {
        putc(' ', plan);
      }
    }
    fprintf(plan, "\n");
  }
  for (i = maxSeats - 5; i < maxSeats; i++) {
    putc(layout[i] ? '*' : '_', plan);
  }
  fprintf(plan, "\n");
  fclose(plan);
  printf("H pinakida kai to diagramma theseon apothikeytikan sto layout.txt\n");
}


x86 assembly (clang, -O0):
<writePlanFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
lea    0xe96(%rip),%rdi
lea    0xe9a(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe84(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x5,%ecx
cmp    %ecx,%eax
jge    1230 <writePlanFile+0xe0>
movl   $0x0,-0x28(%rbp)
cmpl   $0x3,-0x28(%rbp)
jg     1210 <writePlanFile+0xc0>
mov    -0x8(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    -0x28(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
mov    $0x5f,%eax
mov    $0x2a,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    -0x20(%rbp),%rsi
movsbl %al,%edi
call   1050 <putc@plt>
cmpl   $0x1,-0x28(%rbp)
jne    11fd <writePlanFile+0xad>
mov    -0x20(%rbp),%rsi
mov    $0x20,%edi
call   1050 <putc@plt>
jmp    1202 <writePlanFile+0xb2>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11af <writePlanFile+0x5f>
mov    -0x20(%rbp),%rdi
lea    0xdf4(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x24(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x24(%rbp)
jmp    1197 <writePlanFile+0x47>
mov    -0xc(%rbp),%eax
sub    $0x5,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    127a <writePlanFile+0x12a>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    $0x5f,%eax
mov    $0x2a,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    -0x20(%rbp),%rsi
movsbl %al,%edi
call   1050 <putc@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1239 <writePlanFile+0xe9>
mov    -0x20(%rbp),%rdi
lea    0xd8a(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xd75(%rip),%rdi
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writePlanFile>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%rbp
mov    %esi,%r15d
mov    %rdi,%r14
lea    0xec2(%rip),%rdi
lea    0xe7e(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
lea    0xe71(%rip),%rsi
mov    %rax,%rdi
mov    %rbp,%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
lea    -0x5(%r15),%r12d
cmp    $0x6,%r15d
jl     123e <writePlanFile+0xde>
xor    %ebp,%ebp
mov    $0x5f,%r13d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmpl   $0x0,(%r14,%rbp,4)
mov    $0x2a,%edi
cmove  %r13d,%edi
mov    %rbx,%rsi
call   1060 <putc@plt>
cmpl   $0x0,0x4(%r14,%rbp,4)
mov    $0x2a,%edi
cmove  %r13d,%edi
mov    %rbx,%rsi
call   1060 <putc@plt>
mov    $0x20,%edi
mov    %rbx,%rsi
call   1060 <putc@plt>
cmpl   $0x0,0x8(%r14,%rbp,4)
mov    $0x2a,%edi
cmove  %r13d,%edi
mov    %rbx,%rsi
call   1060 <putc@plt>
cmpl   $0x0,0xc(%r14,%rbp,4)
mov    $0x2a,%edi
cmove  %r13d,%edi
mov    %rbx,%rsi
call   1060 <putc@plt>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1050 <fputc@plt>
add    $0x4,%rbp
cmp    %ebp,%r12d
jg     11c0 <writePlanFile+0x60>
movslq %r12d,%rbp
movslq %r15d,%r13
cmpl   $0x0,(%r14,%rbp,4)
mov    $0x5f,%r12d
mov    $0x2a,%r15d
mov    $0x2a,%edi
cmove  %r12d,%edi
mov    %rbx,%rsi
call   1060 <putc@plt>
lea    0x1(%rbp),%rax
cmp    %r13,%rax
jge    12c9 <writePlanFile+0x169>
cmpl   $0x0,0x4(%r14,%rbp,4)
mov    $0x2a,%edi
cmove  %r12d,%edi
mov    %rbx,%rsi
call   1060 <putc@plt>
cmpl   $0x0,0x8(%r14,%rbp,4)
mov    $0x2a,%edi
cmove  %r12d,%edi
mov    %rbx,%rsi
call   1060 <putc@plt>
cmpl   $0x0,0xc(%r14,%rbp,4)
mov    $0x2a,%edi
cmove  %r12d,%edi
mov    %rbx,%rsi
call   1060 <putc@plt>
cmpl   $0x0,0x10(%r14,%rbp,4)
cmove  %r12d,%r15d
mov    %r15d,%edi
mov    %rbx,%rsi
call   1060 <putc@plt>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1050 <fputc@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
lea    0xd21(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"layout.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [67 x i8] c"H pinakida kai to diagramma theseon apothikeytikan sto layout.txt\0A\00"
define void @writePlanFile(i32* %0, i32 %1, i8* %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%10 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %10, i32** %7
%11 = load i32*, i32** %7
%12 = load i8*, i8** %6
%13 = call i32 (i32*, i8*, ...) @fprintf(i32* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %12)
store i32 0, i32* %8
br label %14
14: ; preds = %49, %3
%15 = load i32, i32* %8
%16 = load i32, i32* %5
%17 = sub nsw i32 %16, 5
%18 = icmp slt i32 %15, %17
br i1 %18, label %19, label %52
19: ; preds = %14
store i32 0, i32* %9
br label %20
20: ; preds = %43, %19
%21 = load i32, i32* %9
%22 = icmp sle i32 %21, 3
br i1 %22, label %23, label %46
23: ; preds = %20
%24 = load i32*, i32** %4
%25 = load i32, i32* %8
%26 = load i32, i32* %9
%27 = add nsw i32 %25, %26
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i32, i32* %24, i64 %28
%30 = load i32, i32* %29
%31 = icmp ne i32 %30, 0
%32 = zext i1 %31 to i64
%33 = select i1 %31, i32 42, i32 95
%34 = trunc i32 %33 to i8
%35 = load i32*, i32** %7
%36 = call i32 @putc(i8 signext %34, i32* %35)
%37 = load i32, i32* %9
%38 = icmp eq i32 %37, 1
br i1 %38, label %39, label %42
39: ; preds = %23
%40 = load i32*, i32** %7
%41 = call i32 @putc(i8 signext 32, i32* %40)
br label %42
42: ; preds = %39, %23
br label %43
43: ; preds = %42
%44 = load i32, i32* %9
%45 = add nsw i32 %44, 1
store i32 %45, i32* %9
br label %20
46: ; preds = %20
%47 = load i32*, i32** %7
%48 = call i32 (i32*, i8*, ...) @fprintf(i32* %47, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %49
49: ; preds = %46
%50 = load i32, i32* %8
%51 = add nsw i32 %50, 4
store i32 %51, i32* %8
br label %14
52: ; preds = %14
%53 = load i32, i32* %5
%54 = sub nsw i32 %53, 5
store i32 %54, i32* %8
br label %55
55: ; preds = %71, %52
%56 = load i32, i32* %8
%57 = load i32, i32* %5
%58 = icmp slt i32 %56, %57
br i1 %58, label %59, label %74
59: ; preds = %55
%60 = load i32*, i32** %4
%61 = load i32, i32* %8
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i32, i32* %60, i64 %62
%64 = load i32, i32* %63
%65 = icmp ne i32 %64, 0
%66 = zext i1 %65 to i64
%67 = select i1 %65, i32 42, i32 95
%68 = trunc i32 %67 to i8
%69 = load i32*, i32** %7
%70 = call i32 @putc(i8 signext %68, i32* %69)
br label %71
71: ; preds = %59
%72 = load i32, i32* %8
%73 = add nsw i32 %72, 1
store i32 %73, i32* %8
br label %55
74: ; preds = %55
%75 = load i32*, i32** %7
%76 = call i32 (i32*, i8*, ...) @fprintf(i32* %75, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%77 = load i32*, i32** %7
%78 = call i32 @fclose(i32* %77)
%79 = call i32 @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.4, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"layout.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@str = [66 x i8] c"H pinakida kai to diagramma theseon apothikeytikan sto layout.txt\00"
define void @writePlanFile(i32* nocapture %0, i32 %1, i8* %2) {
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%6 = add i32 %1, -5
%7 = icmp sgt i32 %1, 5
br i1 %7, label %18, label %8
8: ; preds = %18, %3
%9 = sext i32 %6 to i64
%10 = sext i32 %1 to i64
%11 = getelementptr inbounds i32, i32* %0, i64 %9
%12 = load i32, i32* %11
%13 = icmp eq i32 %12, 0
%14 = select i1 %13, i8 95, i8 42
%15 = tail call i32 @putc(i8 signext %14, i32* %4)
%16 = add nsw i64 %9, 1
%17 = icmp slt i64 %16, %10
br i1 %17, label %48, label %72
18: ; preds = %3, %18
%19 = phi i64 [ %45, %18 ], [ 0, %3 ]
%20 = getelementptr inbounds i32, i32* %0, i64 %19
%21 = load i32, i32* %20
%22 = icmp eq i32 %21, 0
%23 = select i1 %22, i8 95, i8 42
%24 = tail call i32 @putc(i8 signext %23, i32* %4)
%25 = or i64 %19, 1
%26 = getelementptr inbounds i32, i32* %0, i64 %25
%27 = load i32, i32* %26
%28 = icmp eq i32 %27, 0
%29 = select i1 %28, i8 95, i8 42
%30 = tail call i32 @putc(i8 signext %29, i32* %4)
%31 = tail call i32 @putc(i8 signext 32, i32* %4)
%32 = or i64 %19, 2
%33 = getelementptr inbounds i32, i32* %0, i64 %32
%34 = load i32, i32* %33
%35 = icmp eq i32 %34, 0
%36 = select i1 %35, i8 95, i8 42
%37 = tail call i32 @putc(i8 signext %36, i32* %4)
%38 = or i64 %19, 3
%39 = getelementptr inbounds i32, i32* %0, i64 %38
%40 = load i32, i32* %39
%41 = icmp eq i32 %40, 0
%42 = select i1 %41, i8 95, i8 42
%43 = tail call i32 @putc(i8 signext %42, i32* %4)
%44 = tail call i32 @fputc(i32 10, i32* %4)
%45 = add nuw i64 %19, 4
%46 = trunc i64 %45 to i32
%47 = icmp sgt i32 %6, %46
br i1 %47, label %18, label %8
48: ; preds = %8
%49 = getelementptr inbounds i32, i32* %0, i64 %16
%50 = load i32, i32* %49
%51 = icmp eq i32 %50, 0
%52 = select i1 %51, i8 95, i8 42
%53 = tail call i32 @putc(i8 signext %52, i32* %4)
%54 = add nsw i64 %9, 2
%55 = getelementptr inbounds i32, i32* %0, i64 %54
%56 = load i32, i32* %55
%57 = icmp eq i32 %56, 0
%58 = select i1 %57, i8 95, i8 42
%59 = tail call i32 @putc(i8 signext %58, i32* %4)
%60 = add nsw i64 %9, 3
%61 = getelementptr inbounds i32, i32* %0, i64 %60
%62 = load i32, i32* %61
%63 = icmp eq i32 %62, 0
%64 = select i1 %63, i8 95, i8 42
%65 = tail call i32 @putc(i8 signext %64, i32* %4)
%66 = add nsw i64 %9, 4
%67 = getelementptr inbounds i32, i32* %0, i64 %66
%68 = load i32, i32* %67
%69 = icmp eq i32 %68, 0
%70 = select i1 %69, i8 95, i8 42
%71 = tail call i32 @putc(i8 signext %70, i32* %4)
br label %72
72: ; preds = %48, %8
%73 = tail call i32 @fputc(i32 10, i32* %4)
%74 = tail call i32 @fclose(i32* %4)
%75 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @str, i64 0, i64 0))
ret void
}