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

/* Variables and functions */
int atoi(int /*<<< orphan*/);
int get_nprocs();
int get_nprocs_conf();
int getopt_long(int, char **, char *, struct option *, int /*<<< orphan*/ *);
int /*<<< orphan*/ optarg;
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  int nr = get_nprocs();
  int c, ign, all = 0;
  struct option opts[5] = {{"version", 0, 0, 0},
                           {"help", 0, 0, 1},
                           {"all", 0, 0, 2},
                           {"ignore", 1, 0, 3},
                           {0, 0, 0, 0}};
  while ((c = getopt_long(argc, argv, "", opts, NULL)) != -1) {
    switch (c) {
    case 0:
      printf("%s v0.1\n", argv[0]);
      return 0;
    case 1:
      printf("%s --version|--help|--all|--ignore=N\n", argv[0]);
      return 0;
    case 2:
      all = 1;
      break;
    case 3:
      ign = atoi(optarg);
      break;
    case '?':
      printf("wrong option, %s --help\n", argv[0]);
      return 1;
    }
  }
  if (all == 1)
    nr = get_nprocs_conf();
  nr = nr - ign;
  if (nr <= 0)
    nr = 1;
  printf("%d\n", nr);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1080 <get_nprocs@plt>
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x20(%rbp)
lea    -0xa0(%rbp),%rdi
lea    0x2c08(%rip),%rsi
mov    $0x78,%edx
call   1060 <memcpy@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    -0xa0(%rbp),%rcx
lea    0xe69(%rip),%rdx
xor    %eax,%eax
mov    %eax,%r8d
call   1040 <getopt_long@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
je     12bd <main+0x15d>
mov    -0x18(%rbp),%eax
mov    %eax,-0xa4(%rbp)
test   %eax,%eax
je     1233 <main+0xd3>
jmp    11e3 <main+0x83>
mov    -0xa4(%rbp),%eax
sub    $0x1,%eax
je     1254 <main+0xf4>
jmp    11f7 <main+0x97>
mov    -0xa4(%rbp),%eax
sub    $0x2,%eax
je     1275 <main+0x115>
jmp    120b <main+0xab>
mov    -0xa4(%rbp),%eax
sub    $0x3,%eax
je     1281 <main+0x121>
jmp    121f <main+0xbf>
mov    -0xa4(%rbp),%eax
sub    $0x3f,%eax
je     1297 <main+0x137>
jmp    12b8 <main+0x158>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xdd7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1303 <main+0x1a3>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xdbf(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1303 <main+0x1a3>
movl   $0x1,-0x20(%rbp)
jmp    12b8 <main+0x158>
mov    0x2d70(%rip),%rax
mov    (%rax),%edi
call   1070 <atoi@plt>
mov    %eax,-0x1c(%rbp)
jmp    12b8 <main+0x158>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xda2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1303 <main+0x1a3>
jmp    11a2 <main+0x42>
cmpl   $0x1,-0x20(%rbp)
jne    12d1 <main+0x171>
mov    $0x0,%al
call   1030 <get_nprocs_conf@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
sub    -0x1c(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jg     12eb <main+0x18b>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xd6b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %eax,%eax
mov    %rax,0x8(%rsp)
xor    %eax,%eax
call   1070 <get_nprocs@plt>
mov    %eax,%r14d
mov    0x2c92(%rip),%rax
mov    %rax,0x80(%rsp)
movaps 0x2c73(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0x2c57(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0x2c3b(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0x2c1f(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0x2c03(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0x2be7(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0x2bcb(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0xe53(%rip),%r12
lea    0x10(%rsp),%r13
lea    0xe13(%rip),%r15
nopl   (%rax)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
xor    %r8d,%r8d
call   1040 <getopt_long@plt>
lea    0x1(%rax),%ecx
cmp    $0x4,%ecx
jbe    1212 <main+0xc2>
cmp    $0x3f,%eax
jne    11f0 <main+0xa0>
jmp    123b <main+0xeb>
movslq (%r15,%rcx,4),%rax
add    %r15,%rax
jmp    *%rax
mov    $0x1,%eax
mov    %rax,0x8(%rsp)
jmp    11f0 <main+0xa0>
mov    0x2dca(%rip),%rax
mov    (%rax),%edi
call   1060 <atoi@plt>
mov    %eax,0x4(%rsp)
jmp    11f0 <main+0xa0>
mov    (%rbx),%rsi
lea    0xe16(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%ebx
jmp    12a6 <main+0x156>
cmpl   $0x1,0x8(%rsp)
jne    1264 <main+0x114>
xor    %eax,%eax
call   1030 <get_nprocs_conf@plt>
mov    %eax,%r14d
sub    0x4(%rsp),%r14d
test   %r14d,%r14d
mov    $0x1,%esi
cmovg  %r14d,%esi
lea    0xdf8(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <printf@plt>
jmp    12a6 <main+0x156>
mov    (%rbx),%rsi
lea    0xd9b(%rip),%rdi
jmp    129d <main+0x14d>
mov    (%rbx),%rsi
lea    0xd98(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebx,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.option = type { i8*, i32, i32, i32 }
@.str = [8 x i8] c"version\00"
@.str.1 = [5 x i8] c"help\00"
@.str.2 = [4 x i8] c"all\00"
@.str.3 = [7 x i8] c"ignore\00"
@__const.main.opts = [5 x %struct.option] [%struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i32 0, i32 0, i32 0 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i32 0, i32 0, i32 1 }, %struct.option { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), i32 0, i32 0, i32 2 }, %struct.option { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i32 0, i32 0), i32 1, i32 0, i32 3 }, %struct.option zeroinitializer]
@.str.4 = [1 x i8] zeroinitializer
@.str.5 = [9 x i8] c"%s v0.1\0A\00"
@.str.6 = [38 x i8] c"%s --version|--help|--all|--ignore=N\0A\00"
@optarg = global i32 0
@.str.7 = [25 x i8] c"wrong option, %s --help\0A\00"
@.str.8 = [4 x i8] c"%d\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 i32
%9 = alloca i32
%10 = alloca [5 x %struct.option]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = call i32 (...) @get_nprocs()
store i32 %11, i32* %6
store i32 0, i32* %9
%12 = bitcast [5 x %struct.option]* %10 to i8*
br label %13
13: ; preds = %40, %2
%14 = load i32, i32* %4
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds [5 x %struct.option], [5 x %struct.option]* %10, i64 0, i64 0
%17 = call i32 @getopt_long(i32 %14, i8** %15, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), %struct.option* %16, i32* null)
store i32 %17, i32* %7
%18 = icmp ne i32 %17, -1
br i1 %18, label %19, label %41
19: ; preds = %13
%20 = load i32, i32* %7
switch i32 %20, label %40 [
i32 0, label %21
i32 1, label %26
i32 2, label %31
i32 3, label %32
i32 63, label %35
]
21: ; preds = %19
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 0
%24 = load i8*, i8** %23
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* %24)
store i32 0, i32* %3
br label %56
26: ; preds = %19
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 0
%29 = load i8*, i8** %28
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0), i8* %29)
store i32 0, i32* %3
br label %56
31: ; preds = %19
store i32 1, i32* %9
br label %40
32: ; preds = %19
%33 = load i32, i32* @optarg
%34 = call i32 @atoi(i32 %33)
store i32 %34, i32* %8
br label %40
35: ; preds = %19
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 0
%38 = load i8*, i8** %37
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i8* %38)
store i32 1, i32* %3
br label %56
40: ; preds = %19, %32, %31
br label %13
41: ; preds = %13
%42 = load i32, i32* %9
%43 = icmp eq i32 %42, 1
br i1 %43, label %44, label %46
44: ; preds = %41
%45 = call i32 (...) @get_nprocs_conf()
store i32 %45, i32* %6
br label %46
46: ; preds = %44, %41
%47 = load i32, i32* %6
%48 = load i32, i32* %8
%49 = sub nsw i32 %47, %48
store i32 %49, i32* %6
%50 = load i32, i32* %6
%51 = icmp sle i32 %50, 0
br i1 %51, label %52, label %53
52: ; preds = %46
store i32 1, i32* %6
br label %53
53: ; preds = %52, %46
%54 = load i32, i32* %6
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i32 %54)
store i32 0, i32* %3
br label %56
56: ; preds = %53, %35, %26, %21
%57 = load i32, i32* %3
ret i32 %57
}

LLVM IR (-O2):
%struct.option = type { i8*, i32, i32, i32 }
@.str = [8 x i8] c"version\00"
@.str.1 = [5 x i8] c"help\00"
@.str.2 = [4 x i8] c"all\00"
@.str.3 = [7 x i8] c"ignore\00"
@__const.main.opts = [5 x %struct.option] [%struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i32 0, i32 0, i32 0 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i32 0, i32 0, i32 1 }, %struct.option { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), i32 0, i32 0, i32 2 }, %struct.option { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i32 0, i32 0), i32 1, i32 0, i32 3 }, %struct.option zeroinitializer]
@.str.4 = [1 x i8] zeroinitializer
@.str.5 = [9 x i8] c"%s v0.1\0A\00"
@.str.6 = [38 x i8] c"%s --version|--help|--all|--ignore=N\0A\00"
@optarg = global i32 0
@.str.7 = [25 x i8] c"wrong option, %s --help\0A\00"
@.str.8 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [5 x %struct.option]
%4 = tail call i32 (...) @get_nprocs()
%5 = bitcast [5 x %struct.option]* %3 to i8*
%6 = getelementptr inbounds [5 x %struct.option], [5 x %struct.option]* %3, i64 0, i64 0
br label %7
7: ; preds = %20, %2
%8 = phi i32 [ %22, %20 ], [ undef, %2 ]
%9 = phi i32 [ %11, %20 ], [ 0, %2 ]
br label %10
10: ; preds = %12, %7
%11 = phi i32 [ %9, %7 ], [ 1, %12 ]
br label %12
12: ; preds = %10, %12
%13 = call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), %struct.option* %6, i32* null)
switch i32 %13, label %12 [
i32 -1, label %26
i32 0, label %14
i32 1, label %17
i32 2, label %10
i32 3, label %20
i32 63, label %23
]
14: ; preds = %12
%15 = load i8*, i8** %1
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* %15)
br label %36
17: ; preds = %12
%18 = load i8*, i8** %1
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0), i8* %18)
br label %36
20: ; preds = %12
%21 = load i32, i32* @optarg
%22 = call i32 @atoi(i32 %21)
br label %7
23: ; preds = %12
%24 = load i8*, i8** %1
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i8* %24)
br label %36
26: ; preds = %12
%27 = icmp eq i32 %11, 1
br i1 %27, label %28, label %30
28: ; preds = %26
%29 = call i32 (...) @get_nprocs_conf()
br label %30
30: ; preds = %28, %26
%31 = phi i32 [ %29, %28 ], [ %4, %26 ]
%32 = sub nsw i32 %31, %8
%33 = icmp sgt i32 %32, 1
%34 = select i1 %33, i32 %32, i32 1
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i32 %34)
br label %36
36: ; preds = %30, %23, %17, %14
%37 = phi i32 [ 1, %23 ], [ 0, %17 ], [ 0, %14 ], [ 0, %30 ]
ret i32 %37
}