#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 */

/* Variables and functions */
int /*<<< orphan*/ _SC_NPROCESSORS_ONLN;
int /*<<< orphan*/ _SC_PAGE_SIZE;
int getopt(int, char **, char *);
size_t optind;
int /*<<< orphan*/ print_help();
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strcmp(char *, char *);
char *sysconf(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  int opt;
  while ((opt = getopt(argc, argv, ":h")) != -1) {
    switch (opt) {
    case 'h':
      print_help();
      return 0;
    default:
      print_help();
      return 1;
    }
  }
  if (argc != 2) {
    print_help();
    return 1;
  }
  if (!strcmp(argv[optind], "_NPROCESSORS_ONLN")) {
    printf("%ld\n", sysconf(_SC_NPROCESSORS_ONLN));
  } else if (!strcmp(argv[optind], "PAGESIZE") ||
             !strcmp(argv[optind], "PAGE_SIZE")) {
    printf("%ld\n", sysconf(_SC_PAGE_SIZE));
  } else {
    printf("tst_getconf: Unrecognized variable \'%s\'\n", argv[optind]);
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe8c(%rip),%rdx
call   1060 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     11bc <main+0x6c>
mov    -0x14(%rbp),%eax
sub    $0x68,%eax
jne    11a9 <main+0x59>
jmp    1196 <main+0x46>
mov    $0x0,%al
call   1070 <print_help@plt>
movl   $0x0,-0x4(%rbp)
jmp    12c8 <main+0x178>
mov    $0x0,%al
call   1070 <print_help@plt>
movl   $0x1,-0x4(%rbp)
jmp    12c8 <main+0x178>
cmpl   $0x2,-0x8(%rbp)
je     11d9 <main+0x89>
mov    $0x0,%al
call   1070 <print_help@plt>
movl   $0x1,-0x4(%rbp)
jmp    12c8 <main+0x178>
mov    -0x10(%rbp),%rax
mov    0x2dfc(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe11(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1222 <main+0xd2>
mov    0x2de1(%rip),%rax
mov    (%rax),%edi
call   1050 <sysconf@plt>
mov    %rax,%rsi
lea    0xdfd(%rip),%rdi
call   1030 <printf@plt>
jmp    12c1 <main+0x171>
mov    -0x10(%rbp),%rax
mov    0x2db3(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xddf(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
je     1270 <main+0x120>
mov    -0x10(%rbp),%rax
mov    0x2d8c(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xdc1(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1292 <main+0x142>
mov    0x2d59(%rip),%rax
mov    (%rax),%edi
call   1050 <sysconf@plt>
mov    %rax,%rsi
lea    0xd8d(%rip),%rdi
call   1030 <printf@plt>
jmp    12bc <main+0x16c>
mov    -0x10(%rbp),%rax
mov    0x2d43(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xd82(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12c8 <main+0x178>
jmp    12c1 <main+0x171>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xea1(%rip),%rdx
call   1060 <getopt@plt>
cmp    $0xffffffff,%eax
je     117c <main+0x2c>
cmp    $0x68,%eax
jne    11de <main+0x8e>
xor    %ebx,%ebx
xor    %eax,%eax
call   1070 <print_help@plt>
jmp    1214 <main+0xc4>
cmp    $0x2,%ebp
jne    11de <main+0x8e>
mov    0x2e58(%rip),%rax
mov    (%rax),%rax
mov    (%rbx,%rax,8),%rbx
lea    0xe6d(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11ec <main+0x9c>
lea    0xe71(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11f5 <main+0xa5>
lea    0xe67(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11f5 <main+0xa5>
lea    0xe5e(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    $0xffffffff,%ebx
jmp    1214 <main+0xc4>
xor    %eax,%eax
call   1070 <print_help@plt>
mov    $0x1,%ebx
jmp    1214 <main+0xc4>
mov    0x2df5(%rip),%rax
jmp    11fc <main+0xac>
mov    0x2dd4(%rip),%rax
mov    (%rax),%edi
call   1050 <sysconf@plt>
lea    0xe0b(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c":h\00"
@optind = global i64 0
@.str.1 = [18 x i8] c"_NPROCESSORS_ONLN\00"
@.str.2 = [5 x i8] c"%ld\0A\00"
@_SC_NPROCESSORS_ONLN = global i32 0
@.str.3 = [9 x i8] c"PAGESIZE\00"
@.str.4 = [10 x i8] c"PAGE_SIZE\00"
@_SC_PAGE_SIZE = global i32 0
@.str.5 = [41 x i8] c"tst_getconf: Unrecognized variable '%s'\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %7
7: ; preds = %2
%8 = load i32, i32* %4
%9 = load i8**, i8*** %5
%10 = call i32 @getopt(i32 %8, i8** %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 %10, i32* %6
%11 = icmp ne i32 %10, -1
br i1 %11, label %12, label %18
12: ; preds = %7
%13 = load i32, i32* %6
switch i32 %13, label %16 [
i32 104, label %14
]
14: ; preds = %12
%15 = call i32 (...) @print_help()
store i32 0, i32* %3
br label %60
16: ; preds = %12
%17 = call i32 (...) @print_help()
store i32 1, i32* %3
br label %60
18: ; preds = %7
%19 = load i32, i32* %4
%20 = icmp ne i32 %19, 2
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = call i32 (...) @print_help()
store i32 1, i32* %3
br label %60
23: ; preds = %18
%24 = load i8**, i8*** %5
%25 = load i64, i64* @optind
%26 = getelementptr inbounds i8*, i8** %24, i64 %25
%27 = load i8*, i8** %26
%28 = call i32 @strcmp(i8* %27, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%29 = icmp ne i32 %28, 0
br i1 %29, label %34, label %30
30: ; preds = %23
%31 = load i32, i32* @_SC_NPROCESSORS_ONLN
%32 = call i8* @sysconf(i32 %31)
%33 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %32)
br label %59
34: ; preds = %23
%35 = load i8**, i8*** %5
%36 = load i64, i64* @optind
%37 = getelementptr inbounds i8*, i8** %35, i64 %36
%38 = load i8*, i8** %37
%39 = call i32 @strcmp(i8* %38, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %48
41: ; preds = %34
%42 = load i8**, i8*** %5
%43 = load i64, i64* @optind
%44 = getelementptr inbounds i8*, i8** %42, i64 %43
%45 = load i8*, i8** %44
%46 = call i32 @strcmp(i8* %45, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%47 = icmp ne i32 %46, 0
br i1 %47, label %52, label %48
48: ; preds = %41, %34
%49 = load i32, i32* @_SC_PAGE_SIZE
%50 = call i8* @sysconf(i32 %49)
%51 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %50)
br label %58
52: ; preds = %41
%53 = load i8**, i8*** %5
%54 = load i64, i64* @optind
%55 = getelementptr inbounds i8*, i8** %53, i64 %54
%56 = load i8*, i8** %55
%57 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0), i8* %56)
store i32 -1, i32* %3
br label %60
58: ; preds = %48
br label %59
59: ; preds = %58, %30
store i32 0, i32* %3
br label %60
60: ; preds = %59, %52, %21, %16, %14
%61 = load i32, i32* %3
ret i32 %61
}

LLVM IR (-O2):
@.str = [3 x i8] c":h\00"
@optind = global i64 0
@.str.1 = [18 x i8] c"_NPROCESSORS_ONLN\00"
@.str.2 = [5 x i8] c"%ld\0A\00"
@_SC_NPROCESSORS_ONLN = global i32 0
@.str.3 = [9 x i8] c"PAGESIZE\00"
@.str.4 = [10 x i8] c"PAGE_SIZE\00"
@_SC_PAGE_SIZE = global i32 0
@.str.5 = [41 x i8] c"tst_getconf: Unrecognized variable '%s'\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
switch i32 %3, label %6 [
i32 -1, label %8
i32 104, label %4
]
4: ; preds = %2
%5 = tail call i32 (...) @print_help()
br label %34
6: ; preds = %2
%7 = tail call i32 (...) @print_help()
br label %34
8: ; preds = %2
%9 = icmp eq i32 %0, 2
br i1 %9, label %12, label %10
10: ; preds = %8
%11 = tail call i32 (...) @print_help()
br label %34
12: ; preds = %8
%13 = load i64, i64* @optind
%14 = getelementptr inbounds i8*, i8** %1, i64 %13
%15 = load i8*, i8** %14
%16 = tail call i32 @strcmp(i8* dereferenceable(1) %15, i8* dereferenceable(18) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %12
%19 = load i32, i32* @_SC_NPROCESSORS_ONLN
%20 = tail call i8* @sysconf(i32 %19)
%21 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %20)
br label %34
22: ; preds = %12
%23 = tail call i32 @strcmp(i8* dereferenceable(1) %15, i8* dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%24 = icmp eq i32 %23, 0
br i1 %24, label %28, label %25
25: ; preds = %22
%26 = tail call i32 @strcmp(i8* dereferenceable(1) %15, i8* dereferenceable(10) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %32
28: ; preds = %25, %22
%29 = load i32, i32* @_SC_PAGE_SIZE
%30 = tail call i8* @sysconf(i32 %29)
%31 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %30)
br label %34
32: ; preds = %25
%33 = tail call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0), i8* %15)
br label %34
34: ; preds = %18, %28, %32, %10, %6, %4
%35 = phi i32 [ 0, %4 ], [ 1, %6 ], [ 1, %10 ], [ -1, %32 ], [ 0, %28 ], [ 0, %18 ]
ret i32 %35
}