#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 */
struct option {
  char *member_0;
  char member_3;
  int /*<<< orphan*/ member_2;
  int /*<<< orphan*/ const member_1;
};

/* Variables and functions */
int /*<<< orphan*/ abort();
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int getopt_long(int, char **, char *, struct option *, int /*<<< orphan*/ *);
int group_dist(char *, char *, char *, int, int);
#define no_argument 129
int /*<<< orphan*/ printUsage();
#define required_argument 128
int /*<<< orphan*/ stderr;
int main(int argc, const char *argv[]) {
  int c;
  int ok;
  char *infile, *layer, *group_attr;
  int manhattan, median;
  extern int optind;
  extern int optopt;
  extern char *optarg;
  if (argc < 4) {
    printUsage();
    return (0);
  }
  infile = layer = group_attr = NULL;
  median = manhattan = 0;
  while (1) {
    static struct option long_options[] = {
        {"help", no_argument, 0, 'h'},
        {"input", required_argument, 0, 'i'},
        {"layer", required_argument, 0, 'l'},
        {"group_attr", required_argument, 0, 'g'},
        {"median", no_argument, 0, 'm'},
        {"manhattan", no_argument, 0, 't'},
        {0, 0, 0, 0}};
    c = getopt_long(argc, (char **)argv, "hi:l:g:", long_options, NULL);
    if (c == -1) {
      break;
    }
    switch (c) {
    case 'h':
      printUsage();
      return 0;
    case 'i':
      infile = optarg;
      break;
    case 'l':
      layer = optarg;
      break;
    case 'g':
      group_attr = optarg;
      break;
    case 'm':
      median = 1;
      break;
    case 't':
      manhattan = 1;
      break;
    case '?':
      return 1;
    default:
      printUsage();
      abort();
    }
  }
  if (infile == NULL) {
    fprintf(stderr, "Error. You must provide a input file.\n");
    exit(1);
  }
  if (group_attr == NULL) {
    fprintf(stderr, "Error. Specify an group attribute.\n");
    exit(1);
  }
  ok = group_dist(infile, layer, group_attr, median, manhattan);
  return ok;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    1193 <main+0x33>
mov    $0x0,%al
call   1070 <printUsage@plt>
movl   $0x0,-0x4(%rbp)
jmp    130b <main+0x1ab>
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xf3e(%rip),%rdx
lea    0x2e92(%rip),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1040 <getopt_long@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    11ea <main+0x8a>
jmp    1296 <main+0x136>
mov    -0x14(%rbp),%eax
add    $0xffffffc1,%eax
mov    %eax,%ecx
mov    %rcx,-0x40(%rbp)
sub    $0x35,%eax
ja     1283 <main+0x123>
mov    -0x40(%rbp),%rax
lea    0xdf6(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1070 <printUsage@plt>
movl   $0x0,-0x4(%rbp)
jmp    130b <main+0x1ab>
mov    0x2db3(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    1291 <main+0x131>
mov    0x2da0(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
jmp    1291 <main+0x131>
mov    0x2d8d(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
jmp    1291 <main+0x131>
movl   $0x1,-0x38(%rbp)
jmp    1291 <main+0x131>
movl   $0x1,-0x34(%rbp)
jmp    1291 <main+0x131>
movl   $0x1,-0x4(%rbp)
jmp    130b <main+0x1ab>
mov    $0x0,%al
call   1070 <printUsage@plt>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    11b9 <main+0x59>
cmpq   $0x0,-0x20(%rbp)
jne    12c0 <main+0x160>
mov    0x2d30(%rip),%rax
mov    (%rax),%edi
lea    0xe5c(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
cmpq   $0x0,-0x30(%rbp)
jne    12ea <main+0x18a>
mov    0x2d06(%rip),%rax
mov    (%rax),%edi
lea    0xe59(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x38(%rbp),%ecx
mov    -0x34(%rbp),%r8d
call   1050 <group_dist@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
cmp    $0x4,%edi
jge    118d <main+0x2d>
xor    %ebx,%ebx
xor    %eax,%eax
call   1070 <printUsage@plt>
mov    %ebx,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %eax,%eax
mov    %rax,0x10(%rsp)
lea    0xf65(%rip),%r14
lea    0x2eb9(%rip),%r15
lea    0xe52(%rip),%r13
xor    %eax,%eax
mov    %rax,0x8(%rsp)
xor    %eax,%eax
mov    %rax,0x20(%rsp)
xor    %eax,%eax
mov    %rax,0x18(%rsp)
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ecx,%r12d
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %r15,%rcx
xor    %r8d,%r8d
call   1040 <getopt_long@plt>
mov    $0x1,%ecx
cmp    $0x6d,%eax
je     11d0 <main+0x70>
lea    -0x3f(%rax),%ecx
cmp    $0x35,%ecx
ja     124d <main+0xed>
movslq 0x0(%r13,%rcx,4),%rax
add    %r13,%rax
jmp    *%rax
mov    0x2dd7(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x18(%rsp)
mov    %r12d,%ecx
jmp    11d0 <main+0x70>
mov    0x2dc3(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x20(%rsp)
mov    %r12d,%ecx
jmp    11d0 <main+0x70>
mov    0x2daf(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x8(%rsp)
mov    %r12d,%ecx
jmp    11d0 <main+0x70>
mov    $0x1,%eax
mov    %rax,0x10(%rsp)
mov    %r12d,%ecx
jmp    11d0 <main+0x70>
cmp    $0xffffffff,%eax
jne    1290 <main+0x130>
mov    0x20(%rsp),%rdi
test   %rdi,%rdi
je     129e <main+0x13e>
mov    0x18(%rsp),%rdx
test   %rdx,%rdx
je     12b0 <main+0x150>
mov    0x8(%rsp),%rsi
mov    %r12d,%ecx
mov    0x10(%rsp),%r8
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <group_dist@plt>
mov    $0x1,%ebx
jmp    117c <main+0x1c>
xor    %eax,%eax
call   1070 <printUsage@plt>
xor    %eax,%eax
call   1030 <abort@plt>
mov    0x2d33(%rip),%rax
mov    (%rax),%edi
lea    0xe5f(%rip),%rsi
jmp    12c0 <main+0x160>
mov    0x2d21(%rip),%rax
mov    (%rax),%edi
lea    0xe74(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.option = type { i8*, i8, i32, i32 }
@main.long_options = internal global [7 x %struct.option] [%struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8 -127, i32 0, i32 104 }, %struct.option { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0), i8 -128, i32 0, i32 105 }, %struct.option { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0), i8 -128, i32 0, i32 108 }, %struct.option { i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i32 0, i32 0), i8 -128, i32 0, i32 103 }, %struct.option { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i32 0, i32 0), i8 -127, i32 0, i32 109 }, %struct.option { i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i32 0, i32 0), i8 -127, i32 0, i32 116 }, %struct.option zeroinitializer]
@.str = [5 x i8] c"help\00"
@.str.1 = [6 x i8] c"input\00"
@.str.2 = [6 x i8] c"layer\00"
@.str.3 = [11 x i8] c"group_attr\00"
@.str.4 = [7 x i8] c"median\00"
@.str.5 = [10 x i8] c"manhattan\00"
@.str.6 = [8 x i8] c"hi:l:g:\00"
@optarg = external global i8*
@stderr = global i32 0
@.str.7 = [39 x i8] c"Error. You must provide a input file.\0A\00"
@.str.8 = [36 x i8] c"Error. Specify an group attribute.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 4
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = call i32 (...) @printUsage()
store i32 0, i32* %3
br label %64
17: ; preds = %2
store i8* null, i8** %10
store i8* null, i8** %9
store i8* null, i8** %8
store i32 0, i32* %11
store i32 0, i32* %12
br label %18
18: ; preds = %17, %41
%19 = load i32, i32* %4
%20 = load i8**, i8*** %5
%21 = call i32 @getopt_long(i32 %19, i8** %20, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), %struct.option* getelementptr inbounds ([7 x %struct.option], [7 x %struct.option]* @main.long_options, i64 0, i64 0), i32* null)
store i32 %21, i32* %6
%22 = load i32, i32* %6
%23 = icmp eq i32 %22, -1
br i1 %23, label %24, label %25
24: ; preds = %18
br label %42
25: ; preds = %18
%26 = load i32, i32* %6
switch i32 %26, label %38 [
i32 104, label %27
i32 105, label %29
i32 108, label %31
i32 103, label %33
i32 109, label %35
i32 116, label %36
i32 63, label %37
]
27: ; preds = %25
%28 = call i32 (...) @printUsage()
store i32 0, i32* %3
br label %64
29: ; preds = %25
%30 = load i8*, i8** @optarg
store i8* %30, i8** %8
br label %41
31: ; preds = %25
%32 = load i8*, i8** @optarg
store i8* %32, i8** %9
br label %41
33: ; preds = %25
%34 = load i8*, i8** @optarg
store i8* %34, i8** %10
br label %41
35: ; preds = %25
store i32 1, i32* %12
br label %41
36: ; preds = %25
store i32 1, i32* %11
br label %41
37: ; preds = %25
store i32 1, i32* %3
br label %64
38: ; preds = %25
%39 = call i32 (...) @printUsage()
%40 = call i32 (...) @abort()
unreachable
41: ; preds = %36, %35, %33, %31, %29
br label %18
42: ; preds = %24
%43 = load i8*, i8** %8
%44 = icmp eq i8* %43, null
br i1 %44, label %45, label %49
45: ; preds = %42
%46 = load i32, i32* @stderr
%47 = call i32 @fprintf(i32 %46, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.7, i64 0, i64 0))
%48 = call i32 @exit(i32 1)
unreachable
49: ; preds = %42
%50 = load i8*, i8** %10
%51 = icmp eq i8* %50, null
br i1 %51, label %52, label %56
52: ; preds = %49
%53 = load i32, i32* @stderr
%54 = call i32 @fprintf(i32 %53, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.8, i64 0, i64 0))
%55 = call i32 @exit(i32 1)
unreachable
56: ; preds = %49
%57 = load i8*, i8** %8
%58 = load i8*, i8** %9
%59 = load i8*, i8** %10
%60 = load i32, i32* %12
%61 = load i32, i32* %11
%62 = call i32 @group_dist(i8* %57, i8* %58, i8* %59, i32 %60, i32 %61)
store i32 %62, i32* %7
%63 = load i32, i32* %7
store i32 %63, i32* %3
br label %64
64: ; preds = %56, %37, %27, %15
%65 = load i32, i32* %3
ret i32 %65
}

LLVM IR (-O2):
%struct.option = type { i8*, i8, i32, i32 }
@main.long_options = internal global [7 x %struct.option] [%struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8 -127, i32 0, i32 104 }, %struct.option { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0), i8 -128, i32 0, i32 105 }, %struct.option { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0), i8 -128, i32 0, i32 108 }, %struct.option { i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i32 0, i32 0), i8 -128, i32 0, i32 103 }, %struct.option { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i32 0, i32 0), i8 -127, i32 0, i32 109 }, %struct.option { i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i32 0, i32 0), i8 -127, i32 0, i32 116 }, %struct.option zeroinitializer]
@.str = [5 x i8] c"help\00"
@.str.1 = [6 x i8] c"input\00"
@.str.2 = [6 x i8] c"layer\00"
@.str.3 = [11 x i8] c"group_attr\00"
@.str.4 = [7 x i8] c"median\00"
@.str.5 = [10 x i8] c"manhattan\00"
@.str.6 = [8 x i8] c"hi:l:g:\00"
@optarg = external global i8*
@stderr = global i32 0
@.str.7 = [39 x i8] c"Error. You must provide a input file.\0A\00"
@.str.8 = [36 x i8] c"Error. Specify an group attribute.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = icmp slt i32 %0, 4
br i1 %3, label %4, label %13
4: ; preds = %2
%5 = tail call i32 (...) @printUsage()
br label %52
6: ; preds = %32, %6
%7 = phi i32 [ 1, %6 ], [ %34, %32 ]
%8 = tail call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), %struct.option* getelementptr inbounds ([7 x %struct.option], [7 x %struct.option]* @main.long_options, i64 0, i64 0), i32* null)
switch i32 %8, label %35 [
i32 -1, label %38
i32 104, label %9
i32 105, label %11
i32 108, label %19
i32 103, label %26
i32 109, label %6
i32 116, label %32
i32 63, label %52
]
9: ; preds = %6
%10 = tail call i32 (...) @printUsage()
br label %52
11: ; preds = %6
%12 = load i8*, i8** @optarg
br label %13
13: ; preds = %2, %11
%14 = phi i8* [ %12, %11 ], [ null, %2 ]
%15 = phi i8* [ %22, %11 ], [ null, %2 ]
%16 = phi i8* [ %29, %11 ], [ null, %2 ]
%17 = phi i32 [ %33, %11 ], [ 0, %2 ]
%18 = phi i32 [ %7, %11 ], [ 0, %2 ]
br label %21
19: ; preds = %6
%20 = load i8*, i8** @optarg
br label %21
21: ; preds = %13, %19
%22 = phi i8* [ %15, %13 ], [ %20, %19 ]
%23 = phi i8* [ %16, %13 ], [ %29, %19 ]
%24 = phi i32 [ %17, %13 ], [ %33, %19 ]
%25 = phi i32 [ %18, %13 ], [ %7, %19 ]
br label %28
26: ; preds = %6
%27 = load i8*, i8** @optarg
br label %28
28: ; preds = %21, %26
%29 = phi i8* [ %23, %21 ], [ %27, %26 ]
%30 = phi i32 [ %24, %21 ], [ %33, %26 ]
%31 = phi i32 [ %25, %21 ], [ %7, %26 ]
br label %32
32: ; preds = %6, %28
%33 = phi i32 [ %30, %28 ], [ 1, %6 ]
%34 = phi i32 [ %31, %28 ], [ %7, %6 ]
br label %6
35: ; preds = %6
%36 = tail call i32 (...) @printUsage()
%37 = tail call i32 (...) @abort()
unreachable
38: ; preds = %6
%39 = icmp eq i8* %14, null
br i1 %39, label %40, label %44
40: ; preds = %38
%41 = load i32, i32* @stderr
%42 = tail call i32 @fprintf(i32 %41, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.7, i64 0, i64 0))
%43 = tail call i32 @exit(i32 1)
unreachable
44: ; preds = %38
%45 = icmp eq i8* %29, null
br i1 %45, label %46, label %50
46: ; preds = %44
%47 = load i32, i32* @stderr
%48 = tail call i32 @fprintf(i32 %47, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.8, i64 0, i64 0))
%49 = tail call i32 @exit(i32 1)
unreachable
50: ; preds = %44
%51 = tail call i32 @group_dist(i8* %14, i8* %22, i8* %29, i32 %7, i32 %33)
br label %52
52: ; preds = %6, %50, %9, %4
%53 = phi i32 [ 0, %4 ], [ %51, %50 ], [ 0, %9 ], [ 1, %6 ]
ret i32 %53
}