#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, Debug = 0;
  char *pFields[10];
  int line_nub = 0;
  while ((c = getopt(argc, argv, "?hd:")) != EOF) {
    switch (c) {
    case 'd':
      Debug = 1;
      break;
    case '?':
    case 'h':
      fprintf(stderr, "usage: %s -dh?\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,-0x130(%rbp)
movl   $0x0,-0x184(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe05(%rip),%rdx
call   10d0 <getopt@plt>
mov    %eax,-0x12c(%rbp)
mov    0x2dd3(%rip),%rcx
cmp    (%rcx),%eax
je     128e <main+0xce>
mov    -0x12c(%rbp),%eax
mov    %eax,-0x188(%rbp)
sub    $0x3f,%eax
je     1266 <main+0xa6>
jmp    122f <main+0x6f>
mov    -0x188(%rbp),%eax
sub    $0x64,%eax
je     1257 <main+0x97>
jmp    1243 <main+0x83>
mov    -0x188(%rbp),%eax
sub    $0x68,%eax
je     1266 <main+0xa6>
jmp    1289 <main+0xc9>
movl   $0x1,-0x130(%rbp)
jmp    1289 <main+0xc9>
mov    0x2d63(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd88(%rip),%rsi
call   1090 <fprintf@plt>
xor    %edi,%edi
call   10e0 <exit@plt>
jmp    11ed <main+0x2d>
movl   $0x0,-0x128(%rbp)
cmpl   $0xa,-0x128(%rbp)
jge    12cc <main+0x10c>
movslq -0x128(%rbp),%rax
movq   $0x0,-0x180(%rbp,%rax,8)
mov    -0x128(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x128(%rbp)
jmp    1298 <main+0xd8>
mov    0x2d15(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1332 <main+0x172>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd22(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    132d <main+0x16d>
mov    0x2cc3(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xcf9(%rip),%rsi
call   1090 <fprintf@plt>
mov    $0xffffffff,%edi
call   10e0 <exit@plt>
jmp    1332 <main+0x172>
movl   $0xffffffff,-0x184(%rbp)
ff ff ff
lea    0xcea(%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     141f <main+0x25f>
lea    -0x120(%rbp),%rdi
call   1070 <line_chk@plt>
cmp    $0x0,%rax
jge    1382 <main+0x1c2>
jmp    1348 <main+0x188>
lea    -0x120(%rbp),%rdi
lea    -0x180(%rbp),%rdx
mov    $0xa,%esi
call   1060 <line2fields@plt>
mov    %eax,-0x124(%rbp)
cmp    $0x0,%eax
jle    141a <main+0x25a>
mov    -0x184(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x184(%rbp)
cmpl   $0x0,-0x184(%rbp)
jne    13dc <main+0x21c>
mov    -0x124(%rbp),%edi
lea    -0x180(%rbp),%rsi
call   10a0 <make_box@plt>
jmp    140e <main+0x24e>
mov    -0x124(%rbp),%edi
lea    -0x180(%rbp),%rsi
call   1030 <make_pin@plt>
cmp    $0x0,%rax
jge    1409 <main+0x249>
lea    -0x180(%rbp),%rdi
call   10b0 <fields_free@plt>
jmp    141f <main+0x25f>
jmp    140e <main+0x24e>
lea    -0x180(%rbp),%rdi
call   10b0 <fields_free@plt>
jmp    1348 <main+0x188>
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    0xdf6(%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    0xdcf(%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    0xdb0(%rip),%rsi
call   1090 <fprintf@plt>
mov    $0xffffffff,%edi
call   10e0 <exit@plt>
mov    0x2d6b(%rip),%rax
mov    (%rax),%r14
lea    0xda6(%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 = [5 x i8] c"?hd:\00"
@EOF = global i32 0
@stderr = global i32 0
@.str.1 = [16 x i8] c"usage: %s -dh?\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 i32
%12 = alloca [10 x i8*]
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %11
store i32 0, i32* %13
br label %14
14: ; preds = %30, %2
%15 = load i32, i32* %4
%16 = load i8**, i8*** %5
%17 = call i32 @getopt(i32 %15, i8** %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 %17, i32* %10
%18 = load i32, i32* @EOF
%19 = icmp ne i32 %17, %18
br i1 %19, label %20, label %31
20: ; preds = %14
%21 = load i32, i32* %10
switch i32 %21, label %30 [
i32 100, label %22
i32 63, label %23
i32 104, label %23
]
22: ; preds = %20
store i32 1, i32* %11
br label %30
23: ; preds = %20, %20
%24 = load i32, i32* @stderr
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 0
%27 = load i8*, i8** %26
%28 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %27)
%29 = call i32 @exit(i32 0)
unreachable
30: ; preds = %20, %22
br label %14
31: ; preds = %14
store i32 0, i32* %9
br label %32
32: ; preds = %39, %31
%33 = load i32, i32* %9
%34 = icmp slt i32 %33, 10
br i1 %34, label %35, label %42
35: ; preds = %32
%36 = load i32, i32* %9
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [10 x i8*], [10 x i8*]* %12, i64 0, i64 %37
store i8* null, i8** %38
br label %39
39: ; preds = %35
%40 = load i32, i32* %9
%41 = add nsw i32 %40, 1
store i32 %41, i32* %9
br label %32
42: ; preds = %32
%43 = load i32*, i32** @stdin
store i32* %43, i32** %6
%44 = load i32, i32* %4
%45 = icmp sgt i32 %44, 1
br i1 %45, label %46, label %60
46: ; preds = %42
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 1
%49 = load i8*, i8** %48
%50 = call i32* @fopen(i8* %49, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %50, i32** %6
%51 = icmp eq i32* %50, null
br i1 %51, label %52, label %59
52: ; preds = %46
%53 = load i32, i32* @stderr
%54 = load i8**, i8*** %5
%55 = getelementptr inbounds i8*, i8** %54, i64 1
%56 = load i8*, i8** %55
%57 = call i32 @fprintf(i32 %53, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %56)
%58 = call i32 @exit(i32 -1)
unreachable
59: ; preds = %46
br label %60
60: ; preds = %59, %42
store i32 -1, i32* %13
%61 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
br label %62
62: ; preds = %98, %71, %60
%63 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%64 = load i32*, i32** %6
%65 = call i32* @fgets(i8* %63, i32 255, i32* %64)
%66 = icmp ne i32* %65, null
br i1 %66, label %67, label %99
67: ; preds = %62
%68 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%69 = call i64 @line_chk(i8* %68)
%70 = icmp slt i64 %69, 0
br i1 %70, label %71, label %72
71: ; preds = %67
br label %62
72: ; preds = %67
%73 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%74 = getelementptr inbounds [10 x i8*], [10 x i8*]* %12, i64 0, i64 0
%75 = call i32 @line2fields(i8* %73, i32 10, i8** %74)
store i32 %75, i32* %8
%76 = icmp sgt i32 %75, 0
br i1 %76, label %77, label %98
77: ; preds = %72
%78 = load i32, i32* %13
%79 = add nsw i32 %78, 1
store i32 %79, i32* %13
%80 = load i32, i32* %13
%81 = icmp eq i32 %80, 0
br i1 %81, label %82, label %86
82: ; preds = %77
%83 = load i32, i32* %8
%84 = getelementptr inbounds [10 x i8*], [10 x i8*]* %12, i64 0, i64 0
%85 = call i32 @make_box(i32 %83, i8** %84)
br label %95
86: ; preds = %77
%87 = load i32, i32* %8
%88 = getelementptr inbounds [10 x i8*], [10 x i8*]* %12, i64 0, i64 0
%89 = call i64 @make_pin(i32 %87, i8** %88)
%90 = icmp slt i64 %89, 0
br i1 %90, label %91, label %94
91: ; preds = %86
%92 = getelementptr inbounds [10 x i8*], [10 x i8*]* %12, i64 0, i64 0
%93 = call i32 @fields_free(i8** %92)
br label %99
94: ; preds = %86
br label %95
95: ; preds = %94, %82
%96 = getelementptr inbounds [10 x i8*], [10 x i8*]* %12, i64 0, i64 0
%97 = call i32 @fields_free(i8** %96)
br label %98
98: ; preds = %95, %72
br label %62
99: ; preds = %91, %62
%100 = load i32*, i32** %6
%101 = call i32 @fclose(i32* %100)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"?hd:\00"
@EOF = global i32 0
@stderr = global i32 0
@.str.1 = [16 x i8] c"usage: %s -dh?\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 ([5 x i8], [5 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 104, label %15
i32 63, 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 ([16 x i8], [16 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
}