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

/* Variables and functions */
int EOF;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fields_free(char **);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int getopt(int, char **, char *);
int line2fields(char *, int, char **);
scalar_t__ line_chk(char *);
int /*<<< orphan*/ make_box(int, char **);
scalar_t__ make_pin(int, char **);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
int main(int argc, char **argv) {
  FILE *stream;
  char LineBuf[256];
  int fldcnt, i, c;
  char *pFields[10];
  int line_nub = 0;
  while ((c = getopt(argc, argv, "?h:")) != EOF) {
    switch (c) {
    case '?':
    case 'h':
      fprintf(stderr, "usage: %s -h?\n", argv[0]);
      exit(0);
      break;
    }
  }
  for (i = 0; i < 10; i++)
    pFields[i] = NULL;
  stream = stdin;
  if (argc > 1) {
    if ((stream = fopen(argv[1], "r")) == NULL) {
      fprintf(stderr, "Cannot open file: %s\n", argv[1]);
      exit(-1);
    }
  }
  line_nub = -1;
  printf("v 20030525\n");
  while (fgets(LineBuf, sizeof(LineBuf) - 1, stream) != NULL) {
    if (line_chk(LineBuf) < 0)
      continue;
    if ((fldcnt = line2fields(LineBuf, 10, pFields)) > 0) {
      line_nub++;
      if (line_nub == 0)
        make_box(fldcnt, pFields);
      else if (make_pin(fldcnt, pFields) < 0) {
        fields_free(pFields);
        break;
      }
      fields_free(pFields);
    }
  }
  fclose(stream);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x190,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x184(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe0f(%rip),%rdx
call   10d0 <getopt@plt>
mov    %eax,-0x12c(%rbp)
mov    0x2ddd(%rip),%rcx
cmp    (%rcx),%eax
je     1261 <main+0xa1>
mov    -0x12c(%rbp),%eax
mov    %eax,-0x188(%rbp)
sub    $0x3f,%eax
je     1239 <main+0x79>
jmp    1225 <main+0x65>
mov    -0x188(%rbp),%eax
sub    $0x68,%eax
jne    125c <main+0x9c>
jmp    1239 <main+0x79>
mov    0x2d90(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdb4(%rip),%rsi
call   1090 <fprintf@plt>
xor    %edi,%edi
call   10e0 <exit@plt>
jmp    11e3 <main+0x23>
movl   $0x0,-0x128(%rbp)
cmpl   $0xa,-0x128(%rbp)
jge    129f <main+0xdf>
movslq -0x128(%rbp),%rax
movq   $0x0,-0x180(%rbp,%rax,8)
mov    -0x128(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x128(%rbp)
jmp    126b <main+0xab>
mov    0x2d42(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1305 <main+0x145>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd4d(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1300 <main+0x140>
mov    0x2cf0(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xd24(%rip),%rsi
call   1090 <fprintf@plt>
mov    $0xffffffff,%edi
call   10e0 <exit@plt>
jmp    1305 <main+0x145>
movl   $0xffffffff,-0x184(%rbp)
ff ff ff
lea    0xd15(%rip),%rdi
call   1050 <printf@plt>
lea    -0x120(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0xff,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     13f2 <main+0x232>
lea    -0x120(%rbp),%rdi
call   1070 <line_chk@plt>
cmp    $0x0,%rax
jge    1355 <main+0x195>
jmp    131b <main+0x15b>
lea    -0x120(%rbp),%rdi
lea    -0x180(%rbp),%rdx
mov    $0xa,%esi
call   1060 <line2fields@plt>
mov    %eax,-0x124(%rbp)
cmp    $0x0,%eax
jle    13ed <main+0x22d>
mov    -0x184(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x184(%rbp)
cmpl   $0x0,-0x184(%rbp)
jne    13af <main+0x1ef>
mov    -0x124(%rbp),%edi
lea    -0x180(%rbp),%rsi
call   10a0 <make_box@plt>
jmp    13e1 <main+0x221>
mov    -0x124(%rbp),%edi
lea    -0x180(%rbp),%rsi
call   1030 <make_pin@plt>
cmp    $0x0,%rax
jge    13dc <main+0x21c>
lea    -0x180(%rbp),%rdi
call   10b0 <fields_free@plt>
jmp    13f2 <main+0x232>
jmp    13e1 <main+0x221>
lea    -0x180(%rbp),%rdi
call   10b0 <fields_free@plt>
jmp    131b <main+0x15b>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x190,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x158,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xe27(%rip),%r14
mov    0x2e00(%rip),%r15
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   10d0 <getopt@plt>
cmp    (%r15),%eax
je     121b <main+0x5b>
cmp    $0x68,%eax
je     11fc <main+0x3c>
cmp    $0x3f,%eax
jne    11e0 <main+0x20>
mov    0x2dcd(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xdf5(%rip),%rsi
call   1090 <fprintf@plt>
xor    %edi,%edi
call   10e0 <exit@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
cmp    $0x1,%ebp
jle    1276 <main+0xb6>
mov    0x8(%rbx),%rdi
lea    0xdcd(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,%r14
test   %rax,%rax
jne    1280 <main+0xc0>
mov    0x2d76(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xdae(%rip),%rsi
call   1090 <fprintf@plt>
mov    $0xffffffff,%edi
call   10e0 <exit@plt>
mov    0x2d6b(%rip),%rax
mov    (%rax),%r14
lea    0xda4(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%ebp
lea    0x50(%rsp),%rbx
mov    %rsp,%r15
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    $0xff,%esi
mov    %r14,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     1302 <main+0x142>
mov    %rbx,%rdi
call   1070 <line_chk@plt>
test   %rax,%rax
js     12a0 <main+0xe0>
mov    %rbx,%rdi
mov    $0xa,%esi
mov    %r15,%rdx
call   1060 <line2fields@plt>
test   %eax,%eax
jle    12a0 <main+0xe0>
mov    %eax,%edi
mov    %r15,%rsi
inc    %ebp
jne    12e6 <main+0x126>
call   10a0 <make_box@plt>
jmp    12f0 <main+0x130>
call   1040 <make_pin@plt>
test   %rax,%rax
js     12fa <main+0x13a>
mov    %r15,%rdi
call   10b0 <fields_free@plt>
jmp    12a0 <main+0xe0>
mov    %rsp,%rdi
call   10b0 <fields_free@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0x158,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"?h:\00"
@EOF = global i32 0
@stderr = global i32 0
@.str.1 = [15 x i8] c"usage: %s -h?\0A\00"
@stdin = global i32* null
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [22 x i8] c"Cannot open file: %s\0A\00"
@.str.4 = [12 x i8] c"v 20030525\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [256 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [10 x i8*]
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %12
br label %13
13: ; preds = %28, %2
%14 = load i32, i32* %4
%15 = load i8**, i8*** %5
%16 = call i32 @getopt(i32 %14, i8** %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32 %16, i32* %10
%17 = load i32, i32* @EOF
%18 = icmp ne i32 %16, %17
br i1 %18, label %19, label %29
19: ; preds = %13
%20 = load i32, i32* %10
switch i32 %20, label %28 [
i32 63, label %21
i32 104, label %21
]
21: ; preds = %19, %19
%22 = load i32, i32* @stderr
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 0
%25 = load i8*, i8** %24
%26 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %25)
%27 = call i32 @exit(i32 0)
unreachable
28: ; preds = %19
br label %13
29: ; preds = %13
store i32 0, i32* %9
br label %30
30: ; preds = %37, %29
%31 = load i32, i32* %9
%32 = icmp slt i32 %31, 10
br i1 %32, label %33, label %40
33: ; preds = %30
%34 = load i32, i32* %9
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [10 x i8*], [10 x i8*]* %11, i64 0, i64 %35
store i8* null, i8** %36
br label %37
37: ; preds = %33
%38 = load i32, i32* %9
%39 = add nsw i32 %38, 1
store i32 %39, i32* %9
br label %30
40: ; preds = %30
%41 = load i32*, i32** @stdin
store i32* %41, i32** %6
%42 = load i32, i32* %4
%43 = icmp sgt i32 %42, 1
br i1 %43, label %44, label %58
44: ; preds = %40
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 1
%47 = load i8*, i8** %46
%48 = call i32* @fopen(i8* %47, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %48, i32** %6
%49 = icmp eq i32* %48, null
br i1 %49, label %50, label %57
50: ; preds = %44
%51 = load i32, i32* @stderr
%52 = load i8**, i8*** %5
%53 = getelementptr inbounds i8*, i8** %52, i64 1
%54 = load i8*, i8** %53
%55 = call i32 @fprintf(i32 %51, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %54)
%56 = call i32 @exit(i32 -1)
unreachable
57: ; preds = %44
br label %58
58: ; preds = %57, %40
store i32 -1, i32* %12
%59 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
br label %60
60: ; preds = %96, %69, %58
%61 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%62 = load i32*, i32** %6
%63 = call i32* @fgets(i8* %61, i32 255, i32* %62)
%64 = icmp ne i32* %63, null
br i1 %64, label %65, label %97
65: ; preds = %60
%66 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%67 = call i64 @line_chk(i8* %66)
%68 = icmp slt i64 %67, 0
br i1 %68, label %69, label %70
69: ; preds = %65
br label %60
70: ; preds = %65
%71 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%72 = getelementptr inbounds [10 x i8*], [10 x i8*]* %11, i64 0, i64 0
%73 = call i32 @line2fields(i8* %71, i32 10, i8** %72)
store i32 %73, i32* %8
%74 = icmp sgt i32 %73, 0
br i1 %74, label %75, label %96
75: ; preds = %70
%76 = load i32, i32* %12
%77 = add nsw i32 %76, 1
store i32 %77, i32* %12
%78 = load i32, i32* %12
%79 = icmp eq i32 %78, 0
br i1 %79, label %80, label %84
80: ; preds = %75
%81 = load i32, i32* %8
%82 = getelementptr inbounds [10 x i8*], [10 x i8*]* %11, i64 0, i64 0
%83 = call i32 @make_box(i32 %81, i8** %82)
br label %93
84: ; preds = %75
%85 = load i32, i32* %8
%86 = getelementptr inbounds [10 x i8*], [10 x i8*]* %11, i64 0, i64 0
%87 = call i64 @make_pin(i32 %85, i8** %86)
%88 = icmp slt i64 %87, 0
br i1 %88, label %89, label %92
89: ; preds = %84
%90 = getelementptr inbounds [10 x i8*], [10 x i8*]* %11, i64 0, i64 0
%91 = call i32 @fields_free(i8** %90)
br label %97
92: ; preds = %84
br label %93
93: ; preds = %92, %80
%94 = getelementptr inbounds [10 x i8*], [10 x i8*]* %11, i64 0, i64 0
%95 = call i32 @fields_free(i8** %94)
br label %96
96: ; preds = %93, %70
br label %60
97: ; preds = %89, %60
%98 = load i32*, i32** %6
%99 = call i32 @fclose(i32* %98)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"?h:\00"
@EOF = global i32 0
@stderr = global i32 0
@.str.1 = [15 x i8] c"usage: %s -h?\0A\00"
@stdin = global i32* null
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [22 x i8] c"Cannot open file: %s\0A\00"
@str = [11 x i8] c"v 20030525\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [256 x i8]
%4 = alloca [10 x i8*]
%5 = bitcast [10 x i8*]* %4 to i8*
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
br label %7
7: ; preds = %14, %2
%8 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* @EOF
%10 = icmp eq i32 %8, %9
br i1 %10, label %11, label %14
11: ; preds = %7
%12 = load i32*, i32** @stdin
%13 = icmp sgt i32 %0, 1
br i1 %13, label %20, label %30
14: ; preds = %7
switch i32 %8, label %7 [
i32 63, label %15
i32 104, label %15
]
15: ; preds = %14, %14
%16 = load i32, i32* @stderr
%17 = load i8*, i8** %1
%18 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = tail call i32 @exit(i32 0)
unreachable
20: ; preds = %11
%21 = getelementptr inbounds i8*, i8** %1, i64 1
%22 = load i8*, i8** %21
%23 = tail call i32* @fopen(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %30
25: ; preds = %20
%26 = load i32, i32* @stderr
%27 = load i8*, i8** %21
%28 = tail call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %27)
%29 = tail call i32 @exit(i32 -1)
unreachable
30: ; preds = %20, %11
%31 = phi i32* [ %23, %20 ], [ %12, %11 ]
%32 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
%33 = getelementptr inbounds [10 x i8*], [10 x i8*]* %4, i64 0, i64 0
br label %34
34: ; preds = %56, %30
%35 = phi i32 [ %47, %56 ], [ -1, %30 ]
br label %36
36: ; preds = %34, %43
br label %37
37: ; preds = %36, %40
%38 = call i32* @fgets(i8* %6, i32 255, i32* %31)
%39 = icmp eq i32* %38, null
br i1 %39, label %58, label %40
40: ; preds = %37
%41 = call i64 @line_chk(i8* %6)
%42 = icmp slt i64 %41, 0
br i1 %42, label %37, label %43
43: ; preds = %40
%44 = call i32 @line2fields(i8* %6, i32 10, i8** %33)
%45 = icmp sgt i32 %44, 0
br i1 %45, label %46, label %36
46: ; preds = %43
%47 = add nsw i32 %35, 1
%48 = icmp eq i32 %47, 0
br i1 %48, label %49, label %51
49: ; preds = %46
%50 = call i32 @make_box(i32 %44, i8** %33)
br label %56
51: ; preds = %46
%52 = call i64 @make_pin(i32 %44, i8** %33)
%53 = icmp slt i64 %52, 0
br i1 %53, label %54, label %56
54: ; preds = %51
%55 = call i32 @fields_free(i8** %33)
br label %58
56: ; preds = %51, %49
%57 = call i32 @fields_free(i8** %33)
br label %34
58: ; preds = %37, %54
%59 = call i32 @fclose(i32* %31)
ret i32 0
}