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

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ abort();
int /*<<< orphan*/ bad_option(char *, char **);
scalar_t__ error_count();
int getopt_long(int const, char **, char const *, struct option *, int *);
int /*<<< orphan*/ input_from_file(char *);
int optind;
scalar_t__ parse();
int process_command(int, char **);
int scan_cmd(int, int, char **);
int syntax_cmd(int argc, char **argv) {
  static struct option long_options[] = {{0, 0, 0, 0}};
  const int next_cmd = scan_cmd(2, argc, argv);
  int c, index = 0;
  const char *spec = "";
  while ((c = getopt_long(next_cmd, argv, spec, long_options, &index)) != -1) {
    switch (c) {
    case 0:
      break;
    case '?':
      bad_option("syntax", argv);
    default:
      abort();
    }
  }
  for (int i = optind; i < next_cmd; i++) {
    input_from_file(argv[i]);
    while (parse())
      ;
  }
  if (error_count() > 0)
    return EXIT_FAILURE;
  argc -= next_cmd - 1;
  argv += next_cmd - 1;
  return argc > 1 ? process_command(argc, argv) : EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<syntax_cmd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    $0x2,%edi
call   1090 <scan_cmd@plt>
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xe55(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    0x2ea9(%rip),%rcx
lea    -0x1c(%rbp),%r8
call   1050 <getopt_long@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
je     1221 <syntax_cmd+0xa1>
mov    -0x18(%rbp),%eax
mov    %eax,-0x30(%rbp)
test   %eax,%eax
je     1200 <syntax_cmd+0x80>
jmp    11ef <syntax_cmd+0x6f>
mov    -0x30(%rbp),%eax
sub    $0x3f,%eax
je     1205 <syntax_cmd+0x85>
jmp    1215 <syntax_cmd+0x95>
jmp    121c <syntax_cmd+0x9c>
mov    -0x10(%rbp),%rsi
lea    0xdf0(%rip),%rdi
call   1070 <bad_option@plt>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    11b5 <syntax_cmd+0x35>
mov    0x2dc0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1273 <syntax_cmd+0xf3>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1080 <input_from_file@plt>
mov    $0x0,%al
call   10a0 <parse@plt>
cmp    $0x0,%rax
je     1260 <syntax_cmd+0xe0>
jmp    124a <syntax_cmd+0xca>
jmp    1265 <syntax_cmd+0xe5>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    122d <syntax_cmd+0xad>
mov    $0x0,%al
call   1060 <error_count@plt>
cmp    $0x0,%rax
jle    1295 <syntax_cmd+0x115>
mov    0x2d4d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12eb <syntax_cmd+0x16b>
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x8(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    12d9 <syntax_cmd+0x159>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1040 <process_command@plt>
mov    %eax,-0x34(%rbp)
jmp    12e5 <syntax_cmd+0x165>
mov    0x2cf0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<syntax_cmd>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r13
mov    %edi,%r14d
mov    $0x2,%edi
mov    %r14d,%esi
mov    %r13,%rdx
call   1090 <scan_cmd@plt>
mov    %eax,%r15d
movl   $0x0,0x4(%rsp)
lea    0xe53(%rip),%r12
lea    0x2eb6(%rip),%rbp
lea    0x4(%rsp),%rbx
nop
mov    %r15d,%edi
mov    %r13,%rsi
mov    %r12,%rdx
mov    %rbp,%rcx
mov    %rbx,%r8
call   1050 <getopt_long@plt>
test   %eax,%eax
je     11c0 <syntax_cmd+0x40>
cmp    $0xffffffff,%eax
jne    1277 <syntax_cmd+0xf7>
mov    0x2e00(%rip),%rax
movslq (%rax),%rbx
cmp    %r15d,%ebx
jge    1225 <syntax_cmd+0xa5>
movslq %r15d,%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x0(%r13,%rbx,8),%rdi
call   1080 <input_from_file@plt>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   10a0 <parse@plt>
test   %rax,%rax
jne    1210 <syntax_cmd+0x90>
add    $0x1,%rbx
cmp    %rbp,%rbx
jne    1200 <syntax_cmd+0x80>
xor    %eax,%eax
call   1060 <error_count@plt>
test   %rax,%rax
jle    123a <syntax_cmd+0xba>
mov    0x2da0(%rip),%rax
jmp    1266 <syntax_cmd+0xe6>
add    $0xffffffff,%r15d
sub    %r15d,%r14d
cmp    $0x2,%r14d
jl     125f <syntax_cmd+0xdf>
movslq %r15d,%rax
lea    0x0(,%rax,8),%rsi
add    %r13,%rsi
mov    %r14d,%edi
call   1040 <process_command@plt>
jmp    1268 <syntax_cmd+0xe8>
mov    0x2d6a(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
cmp    $0x3f,%eax
jne    128b <syntax_cmd+0x10b>
lea    0xd7d(%rip),%rdi
mov    %r13,%rsi
call   1070 <bad_option@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
%struct.option = type { i32, i32, i32, i32 }
@syntax_cmd.long_options = internal global [1 x %struct.option] zeroinitializer
@.str = [1 x i8] zeroinitializer
@.str.1 = [7 x i8] c"syntax\00"
@optind = global i32 0
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @syntax_cmd(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = load i8**, i8*** %5
%13 = call i32 @scan_cmd(i32 2, i32 %11, i8** %12)
store i32 %13, i32* %6
store i32 0, i32* %8
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %9
br label %14
14: ; preds = %28, %2
%15 = load i32, i32* %6
%16 = load i8**, i8*** %5
%17 = load i8*, i8** %9
%18 = call i32 @getopt_long(i32 %15, i8** %16, i8* %17, %struct.option* getelementptr inbounds ([1 x %struct.option], [1 x %struct.option]* @syntax_cmd.long_options, i64 0, i64 0), i32* %8)
store i32 %18, i32* %7
%19 = icmp ne i32 %18, -1
br i1 %19, label %20, label %29
20: ; preds = %14
%21 = load i32, i32* %7
switch i32 %21, label %26 [
i32 0, label %22
i32 63, label %23
]
22: ; preds = %20
br label %28
23: ; preds = %20
%24 = load i8**, i8*** %5
%25 = call i32 @bad_option(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8** %24)
br label %26
26: ; preds = %20, %23
%27 = call i32 (...) @abort()
unreachable
28: ; preds = %22
br label %14
29: ; preds = %14
%30 = load i32, i32* @optind
store i32 %30, i32* %10
br label %31
31: ; preds = %47, %29
%32 = load i32, i32* %10
%33 = load i32, i32* %6
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %50
35: ; preds = %31
%36 = load i8**, i8*** %5
%37 = load i32, i32* %10
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8*, i8** %36, i64 %38
%40 = load i8*, i8** %39
%41 = call i32 @input_from_file(i8* %40)
br label %42
42: ; preds = %45, %35
%43 = call i64 (...) @parse()
%44 = icmp ne i64 %43, 0
br i1 %44, label %45, label %46
45: ; preds = %42
br label %42
46: ; preds = %42
br label %47
47: ; preds = %46
%48 = load i32, i32* %10
%49 = add nsw i32 %48, 1
store i32 %49, i32* %10
br label %31
50: ; preds = %31
%51 = call i64 (...) @error_count()
%52 = icmp sgt i64 %51, 0
br i1 %52, label %53, label %55
53: ; preds = %50
%54 = load i32, i32* @EXIT_FAILURE
store i32 %54, i32* %3
br label %75
55: ; preds = %50
%56 = load i32, i32* %6
%57 = sub nsw i32 %56, 1
%58 = load i32, i32* %4
%59 = sub nsw i32 %58, %57
store i32 %59, i32* %4
%60 = load i32, i32* %6
%61 = sub nsw i32 %60, 1
%62 = load i8**, i8*** %5
%63 = sext i32 %61 to i64
%64 = getelementptr inbounds i8*, i8** %62, i64 %63
store i8** %64, i8*** %5
%65 = load i32, i32* %4
%66 = icmp sgt i32 %65, 1
br i1 %66, label %67, label %71
67: ; preds = %55
%68 = load i32, i32* %4
%69 = load i8**, i8*** %5
%70 = call i32 @process_command(i32 %68, i8** %69)
br label %73
71: ; preds = %55
%72 = load i32, i32* @EXIT_SUCCESS
br label %73
73: ; preds = %71, %67
%74 = phi i32 [ %70, %67 ], [ %72, %71 ]
store i32 %74, i32* %3
br label %75
75: ; preds = %73, %53
%76 = load i32, i32* %3
ret i32 %76
}

LLVM IR (-O2):
%struct.option = type { i32, i32, i32, i32 }
@syntax_cmd.long_options = internal global [1 x %struct.option] zeroinitializer
@.str = [1 x i8] zeroinitializer
@.str.1 = [7 x i8] c"syntax\00"
@optind = global i32 0
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @syntax_cmd(i32 %0, i8** %1) {
%3 = alloca i32
%4 = tail call i32 @scan_cmd(i32 2, i32 %0, i8** %1)
%5 = bitcast i32* %3 to i8*
store i32 0, i32* %3
br label %6
6: ; preds = %6, %2
%7 = call i32 @getopt_long(i32 %4, i8** %1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %struct.option* getelementptr inbounds ([1 x %struct.option], [1 x %struct.option]* @syntax_cmd.long_options, i64 0, i64 0), i32* %3)
switch i32 %7, label %10 [
i32 -1, label %12
i32 0, label %6
i32 63, label %8
]
8: ; preds = %6
%9 = call i32 @bad_option(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8** %1)
br label %10
10: ; preds = %6, %8
%11 = call i32 (...) @abort()
unreachable
12: ; preds = %6
%13 = load i32, i32* @optind
%14 = icmp slt i32 %13, %4
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = sext i32 %13 to i64
%17 = sext i32 %4 to i64
br label %21
18: ; preds = %29, %12
%19 = call i64 (...) @error_count()
%20 = icmp sgt i64 %19, 0
br i1 %20, label %32, label %34
21: ; preds = %15, %29
%22 = phi i64 [ %16, %15 ], [ %30, %29 ]
%23 = getelementptr inbounds i8*, i8** %1, i64 %22
%24 = load i8*, i8** %23
%25 = call i32 @input_from_file(i8* %24)
br label %26
26: ; preds = %26, %21
%27 = call i64 (...) @parse()
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %26
29: ; preds = %26
%30 = add nsw i64 %22, 1
%31 = icmp eq i64 %30, %17
br i1 %31, label %18, label %21
32: ; preds = %18
%33 = load i32, i32* @EXIT_FAILURE
br label %44
34: ; preds = %18
%35 = add nsw i32 %4, -1
%36 = sub nsw i32 %0, %35
%37 = icmp sgt i32 %36, 1
br i1 %37, label %38, label %42
38: ; preds = %34
%39 = sext i32 %35 to i64
%40 = getelementptr inbounds i8*, i8** %1, i64 %39
%41 = call i32 @process_command(i32 %36, i8** %40)
br label %44
42: ; preds = %34
%43 = load i32, i32* @EXIT_SUCCESS
br label %44
44: ; preds = %38, %42, %32
%45 = phi i32 [ %33, %32 ], [ %41, %38 ], [ %43, %42 ]
ret i32 %45
}