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

/* Variables and functions */
int getopt_long(int, char **, char *, struct option *, int *);
int /*<<< orphan*/ optarg;
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ setup_node(char *, char, char);
int /*<<< orphan*/ show_node(char *);
char *strdup(int /*<<< orphan*/);
int /*<<< orphan*/ strtoul(int /*<<< orphan*/, char **, int /*<<< orphan*/);
int main(int argc, char **argv) {
  char fctrl = -1, sigfwd = -1;
  char *node = NULL;
  while (1) {
    int option_index = -1;
    static struct option long_options[] = {{"hw-fctrl", 1, 0, 'f'},
                                           {"sig-fwd", 1, 0, 's'},
                                           {"node", 1, 0, 'n'},
                                           {0, 0, 0, 0}};
    char *endp;
    int val;
    int c = getopt_long(argc, argv, "f:s:n:", long_options, &option_index);
    if (c == -1)
      break;
    switch (c) {
    case 'f':
      fctrl = strtoul(optarg, &endp, 0) && 1;
      break;
    case 's':
      sigfwd = strtoul(optarg, &endp, 0) && 1;
      break;
    case 'n':
      node = strdup(optarg);
      break;
    }
  }
  if (node == NULL) {
    printf("ERROR: no node name\n");
    return 0;
  }
  if (fctrl < 0 && sigfwd < 0) {
    show_node(node);
    return 0;
  }
  setup_node(node, fctrl, sigfwd);
  return 0;
}


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)
movb   $0xff,-0x11(%rbp)
movb   $0xff,-0x12(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0xffffffff,-0x24(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe7b(%rip),%rdx
lea    0x2ebe(%rip),%rcx
lea    -0x24(%rbp),%r8
call   1040 <getopt_long@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0xffffffff,-0x38(%rbp)
jne    11bd <main+0x5d>
jmp    1286 <main+0x126>
mov    -0x38(%rbp),%eax
mov    %eax,-0x3c(%rbp)
sub    $0x66,%eax
je     11f3 <main+0x93>
jmp    11d1 <main+0x71>
mov    -0x3c(%rbp),%eax
sub    $0x6e,%eax
je     126f <main+0x10f>
jmp    11e2 <main+0x82>
mov    -0x3c(%rbp),%eax
sub    $0x73,%eax
je     1231 <main+0xd1>
jmp    1281 <main+0x121>
mov    0x2dfe(%rip),%rax
mov    (%rax),%edi
lea    -0x30(%rbp),%rsi
xor    %edx,%edx
call   1070 <strtoul@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x3d(%rbp)
je     1221 <main+0xc1>
mov    $0x1,%al
mov    %al,-0x3d(%rbp)
jmp    1221 <main+0xc1>
mov    -0x3d(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %al,-0x11(%rbp)
jmp    1281 <main+0x121>
mov    0x2dc0(%rip),%rax
mov    (%rax),%edi
lea    -0x30(%rbp),%rsi
xor    %edx,%edx
call   1070 <strtoul@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x3e(%rbp)
je     125f <main+0xff>
mov    $0x1,%al
mov    %al,-0x3e(%rbp)
jmp    125f <main+0xff>
mov    -0x3e(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %al,-0x12(%rbp)
jmp    1281 <main+0x121>
mov    0x2d82(%rip),%rax
mov    (%rax),%edi
call   1080 <strdup@plt>
mov    %rax,-0x20(%rbp)
jmp    1186 <main+0x26>
cmpq   $0x0,-0x20(%rbp)
jne    12a9 <main+0x149>
lea    0xd85(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12f2 <main+0x192>
movsbl -0x11(%rbp),%eax
cmp    $0x0,%eax
jge    12d8 <main+0x178>
movsbl -0x12(%rbp),%eax
cmp    $0x0,%eax
jge    12d8 <main+0x178>
mov    -0x20(%rbp),%rdi
call   1060 <show_node@plt>
movl   $0x0,-0x4(%rbp)
jmp    12f2 <main+0x192>
mov    -0x20(%rbp),%rdi
mov    -0x11(%rbp),%al
movsbl %al,%esi
movsbl -0x12(%rbp),%edx
call   1030 <setup_node@plt>
movl   $0x0,-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    $0x18,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
movb   $0xff,0x3(%rsp)
xor    %eax,%eax
mov    %rax,0x8(%rsp)
lea    0xe90(%rip),%r15
lea    0x2ed3(%rip),%r12
lea    0x4(%rsp),%r13
mov    0x2e5f(%rip),%r14
movb   $0xff,0x2(%rsp)
jmp    11ad <main+0x4d>
mov    (%r14),%edi
call   1080 <strdup@plt>
mov    %rax,0x8(%rsp)
movl   $0xffffffff,0x4(%rsp)
ff
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %r12,%rcx
mov    %r13,%r8
call   1050 <getopt_long@plt>
cmp    $0x6d,%eax
jle    11f0 <main+0x90>
cmp    $0x6e,%eax
je     11a0 <main+0x40>
cmp    $0x73,%eax
jne    11ad <main+0x4d>
mov    (%r14),%edi
lea    0x10(%rsp),%rsi
xor    %edx,%edx
call   1070 <strtoul@plt>
test   %eax,%eax
setne  0x3(%rsp)
jmp    11ad <main+0x4d>
nop
cmp    $0x66,%eax
jne    120d <main+0xad>
mov    (%r14),%edi
lea    0x10(%rsp),%rsi
xor    %edx,%edx
call   1070 <strtoul@plt>
test   %eax,%eax
setne  0x2(%rsp)
jmp    11ad <main+0x4d>
cmp    $0xffffffff,%eax
jne    11ad <main+0x4d>
mov    0x8(%rsp),%rdi
test   %rdi,%rdi
je     1233 <main+0xd3>
mov    0x2(%rsp),%cl
test   %cl,%cl
mov    0x3(%rsp),%al
jns    1241 <main+0xe1>
test   %al,%al
jns    1241 <main+0xe1>
call   1060 <show_node@plt>
jmp    124c <main+0xec>
lea    0xde3(%rip),%rdi
call   1030 <puts@plt>
jmp    124c <main+0xec>
movsbl %cl,%esi
movsbl %al,%edx
call   1040 <setup_node@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.option = type { i8*, i32, float, i32 }
@main.long_options = internal global [4 x %struct.option] [%struct.option { i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i32 0, i32 0), i32 1, float 0.000000e+00, i32 102 }, %struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0), i32 1, float 0.000000e+00, i32 115 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i32 1, float 0.000000e+00, i32 110 }, %struct.option zeroinitializer]
@.str = [9 x i8] c"hw-fctrl\00"
@.str.1 = [8 x i8] c"sig-fwd\00"
@.str.2 = [5 x i8] c"node\00"
@.str.3 = [7 x i8] c"f:s:n:\00"
@optarg = global i32 0
@.str.4 = [21 x i8] c"ERROR: no node name\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
%7 = alloca i8
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8 -1, i8* %6
store i8 -1, i8* %7
store i8* null, i8** %8
br label %13
13: ; preds = %2, %43
store i32 -1, i32* %9
%14 = load i32, i32* %4
%15 = load i8**, i8*** %5
%16 = call i32 @getopt_long(i32 %14, i8** %15, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), %struct.option* getelementptr inbounds ([4 x %struct.option], [4 x %struct.option]* @main.long_options, i64 0, i64 0), i32* %9)
store i32 %16, i32* %12
%17 = load i32, i32* %12
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %20
19: ; preds = %13
br label %44
20: ; preds = %13
%21 = load i32, i32* %12
switch i32 %21, label %43 [
i32 102, label %22
i32 115, label %31
i32 110, label %40
]
22: ; preds = %20
%23 = load i32, i32* @optarg
%24 = call i32 @strtoul(i32 %23, i8** %10, i32 0)
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %22
br label %27
27: ; preds = %26, %22
%28 = phi i1 [ false, %22 ], [ true, %26 ]
%29 = zext i1 %28 to i32
%30 = trunc i32 %29 to i8
store i8 %30, i8* %6
br label %43
31: ; preds = %20
%32 = load i32, i32* @optarg
%33 = call i32 @strtoul(i32 %32, i8** %10, i32 0)
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %31
br label %36
36: ; preds = %35, %31
%37 = phi i1 [ false, %31 ], [ true, %35 ]
%38 = zext i1 %37 to i32
%39 = trunc i32 %38 to i8
store i8 %39, i8* %7
br label %43
40: ; preds = %20
%41 = load i32, i32* @optarg
%42 = call i8* @strdup(i32 %41)
store i8* %42, i8** %8
br label %43
43: ; preds = %20, %40, %36, %27
br label %13
44: ; preds = %19
%45 = load i8*, i8** %8
%46 = icmp eq i8* %45, null
br i1 %46, label %47, label %49
47: ; preds = %44
%48 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %3
br label %65
49: ; preds = %44
%50 = load i8, i8* %6
%51 = sext i8 %50 to i32
%52 = icmp slt i32 %51, 0
br i1 %52, label %53, label %60
53: ; preds = %49
%54 = load i8, i8* %7
%55 = sext i8 %54 to i32
%56 = icmp slt i32 %55, 0
br i1 %56, label %57, label %60
57: ; preds = %53
%58 = load i8*, i8** %8
%59 = call i32 @show_node(i8* %58)
store i32 0, i32* %3
br label %65
60: ; preds = %53, %49
%61 = load i8*, i8** %8
%62 = load i8, i8* %6
%63 = load i8, i8* %7
%64 = call i32 @setup_node(i8* %61, i8 signext %62, i8 signext %63)
store i32 0, i32* %3
br label %65
65: ; preds = %60, %57, %47
%66 = load i32, i32* %3
ret i32 %66
}

LLVM IR (-O2):
%struct.option = type { i8*, i32, float, i32 }
@main.long_options = internal global [4 x %struct.option] [%struct.option { i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i32 0, i32 0), i32 1, float 0.000000e+00, i32 102 }, %struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0), i32 1, float 0.000000e+00, i32 115 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i32 1, float 0.000000e+00, i32 110 }, %struct.option zeroinitializer]
@.str = [9 x i8] c"hw-fctrl\00"
@.str.1 = [8 x i8] c"sig-fwd\00"
@.str.2 = [5 x i8] c"node\00"
@.str.3 = [7 x i8] c"f:s:n:\00"
@optarg = global i32 0
@str = [20 x i8] c"ERROR: no node name\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = bitcast i32* %3 to i8*
%6 = bitcast i8** %4 to i8*
br label %7
7: ; preds = %25, %2
%8 = phi i8 [ -1, %2 ], [ %26, %25 ]
%9 = phi i8* [ null, %2 ], [ %27, %25 ]
%10 = phi i8 [ -1, %2 ], [ %28, %25 ]
store i32 -1, i32* %3
%11 = call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), %struct.option* getelementptr inbounds ([4 x %struct.option], [4 x %struct.option]* @main.long_options, i64 0, i64 0), i32* %3)
switch i32 %11, label %25 [
i32 -1, label %29
i32 102, label %12
i32 115, label %17
i32 110, label %22
]
12: ; preds = %7
%13 = load i32, i32* @optarg
%14 = call i32 @strtoul(i32 %13, i8** %4, i32 0)
%15 = icmp ne i32 %14, 0
%16 = zext i1 %15 to i8
br label %25
17: ; preds = %7
%18 = load i32, i32* @optarg
%19 = call i32 @strtoul(i32 %18, i8** %4, i32 0)
%20 = icmp ne i32 %19, 0
%21 = zext i1 %20 to i8
br label %25
22: ; preds = %7
%23 = load i32, i32* @optarg
%24 = call i8* @strdup(i32 %23)
br label %25
25: ; preds = %12, %17, %22, %7
%26 = phi i8 [ %8, %22 ], [ %21, %17 ], [ %8, %12 ], [ %8, %7 ]
%27 = phi i8* [ %24, %22 ], [ %9, %17 ], [ %9, %12 ], [ %9, %7 ]
%28 = phi i8 [ %10, %22 ], [ %10, %17 ], [ %16, %12 ], [ %10, %7 ]
br label %7
29: ; preds = %7
%30 = icmp eq i8* %9, null
br i1 %30, label %31, label %33
31: ; preds = %29
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
br label %41
33: ; preds = %29
%34 = icmp slt i8 %10, 0
%35 = icmp slt i8 %8, 0
%36 = select i1 %34, i1 %35, i1 false
br i1 %36, label %37, label %39
37: ; preds = %33
%38 = call i32 @show_node(i8* %9)
br label %41
39: ; preds = %33
%40 = call i32 @setup_node(i8* %9, i8 signext %10, i8 signext %8)
br label %41
41: ; preds = %39, %37, %31
ret i32 0
}