#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int getopt(int, char **, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strncmp(char *, char *, int);
int /*<<< orphan*/ usageErr(char *);
int getMode(int argc, char **argv) {
  int opt;
  int flag1 = 0, flag2 = 0;
  int op_mode = 0;
  if ((argc != 3) & (argc != 4)) {
    fprintf(stderr, "\n---Incorrect input args---");
    usageErr(argv[0]);
    exit(EXIT_FAILURE);
  }
  if (!strncmp(argv[argc - 1], "-", 1)) {
    fprintf(stderr, "\n---Need <hostname> as final argument---\n");
    usageErr(argv[0]);
    exit(EXIT_FAILURE);
    ;
  }
  while ((opt = getopt(argc, argv, ":rf")) != -1) {
    switch (opt) {
    case 'r':
      flag1 += 1;
      break;
    case 'f':
      flag2 += 1;
      break;
    default:
      fprintf(stderr, "---Invalid [OPTION(S)]---\n");
      usageErr(argv[0]);
      exit(EXIT_FAILURE);
      ;
    }
  }
  if (((flag1 == 0) & (flag2 == 0)) | (flag1 > 1) | (flag2 > 1)) {
    fprintf(stderr, "\n---Duplicate or NULL options encountered---\n");
    fprintf(stderr, "...Server mode unalbe to be established...\n");
    usageErr(argv[0]);
    exit(EXIT_FAILURE);
    ;
  }
  if ((flag1 == 1) & (flag2 == 0)) {
    op_mode = 1;
  }
  if ((flag1 == 0) & (flag2 == 1)) {
    op_mode = 2;
  }
  if ((flag1 + flag2) == 2) {
    op_mode = 3;
  }
  return 1;
}


x86 assembly (clang, -O0):
<getMode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x3,-0x4(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%eax
cmpl   $0x4,-0x4(%rbp)
setne  %cl
and    $0x1,%cl
movzbl %cl,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     11c7 <getMode+0x77>
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
lea    0xe58(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <usageErr@plt>
mov    0x2e18(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe3b(%rip),%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1221 <getMode+0xd1>
mov    0x2de7(%rip),%rax
mov    (%rax),%edi
lea    0xe1a(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <usageErr@plt>
mov    0x2dbe(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
jmp    1226 <getMode+0xd6>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe12(%rip),%rdx
call   1060 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     12ba <getMode+0x16a>
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x66,%eax
je     1278 <getMode+0x128>
jmp    1259 <getMode+0x109>
mov    -0x24(%rbp),%eax
sub    $0x72,%eax
jne    1286 <getMode+0x136>
jmp    126a <getMode+0x11a>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    12b5 <getMode+0x165>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    12b5 <getMode+0x165>
mov    0x2d53(%rip),%rax
mov    (%rax),%edi
lea    0xdb4(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <usageErr@plt>
mov    0x2d2a(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
jmp    1226 <getMode+0xd6>
cmpl   $0x0,-0x18(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%eax
cmpl   $0x0,-0x1c(%rbp)
sete   %cl
and    $0x1,%cl
movzbl %cl,%ecx
and    %ecx,%eax
cmpl   $0x1,-0x18(%rbp)
setg   %cl
and    $0x1,%cl
movzbl %cl,%ecx
or     %ecx,%eax
cmpl   $0x1,-0x1c(%rbp)
setg   %cl
and    $0x1,%cl
movzbl %cl,%ecx
or     %ecx,%eax
cmp    $0x0,%eax
je     1340 <getMode+0x1f0>
mov    0x2cdd(%rip),%rax
mov    (%rax),%edi
lea    0xd59(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2cc8(%rip),%rax
mov    (%rax),%edi
lea    0xd72(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <usageErr@plt>
mov    0x2c9f(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
cmpl   $0x1,-0x18(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%eax
cmpl   $0x0,-0x1c(%rbp)
sete   %cl
and    $0x1,%cl
movzbl %cl,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     136b <getMode+0x21b>
movl   $0x1,-0x20(%rbp)
cmpl   $0x0,-0x18(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%eax
cmpl   $0x1,-0x1c(%rbp)
sete   %cl
and    $0x1,%cl
movzbl %cl,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1396 <getMode+0x246>
movl   $0x2,-0x20(%rbp)
mov    -0x18(%rbp),%eax
add    -0x1c(%rbp),%eax
cmp    $0x2,%eax
jne    13ac <getMode+0x25c>
movl   $0x3,-0x20(%rbp)
mov    $0x1,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getMode>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %edi,%ebx
lea    -0x5(%rbx),%eax
cmp    $0xfffffffd,%eax
jbe    120e <getMode+0xbe>
lea    -0x1(%rbx),%eax
mov    (%r14,%rax,8),%rdi
lea    0xea3(%rip),%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1220 <getMode+0xd0>
xor    %r12d,%r12d
lea    0xeb3(%rip),%r15
xor    %ebp,%ebp
jmp    11a3 <getMode+0x53>
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebp
mov    %ebx,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   1060 <getopt@plt>
cmp    $0x66,%eax
je     11a0 <getMode+0x50>
cmp    $0xffffffff,%eax
je     11c5 <getMode+0x75>
cmp    $0x72,%eax
jne    11e3 <getMode+0x93>
add    $0x1,%r12d
jmp    11a3 <getMode+0x53>
cmp    $0x1,%ebp
jg     1232 <getMode+0xe2>
cmp    $0x1,%r12d
ja     1232 <getMode+0xe2>
or     %r12d,%ebp
je     1232 <getMode+0xe2>
mov    $0x1,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2df6(%rip),%rax
mov    (%rax),%edi
lea    0xe57(%rip),%rsi
call   1040 <fprintf@plt>
mov    (%r14),%rdi
call   1050 <usageErr@plt>
mov    0x2dd1(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    0x2dcb(%rip),%rax
mov    (%rax),%edi
lea    0xde2(%rip),%rsi
jmp    11f3 <getMode+0xa3>
mov    0x2db9(%rip),%rax
mov    (%rax),%edi
lea    0xdec(%rip),%rsi
jmp    11f3 <getMode+0xa3>
mov    0x2da7(%rip),%rbx
mov    (%rbx),%edi
lea    0xe23(%rip),%rsi
call   1040 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe43(%rip),%rsi
jmp    11f3 <getMode+0xa3>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [28 x i8] c"\0A---Incorrect input args---\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"-\00"
@.str.2 = [42 x i8] c"\0A---Need <hostname> as final argument---\0A\00"
@.str.3 = [4 x i8] c":rf\00"
@.str.4 = [27 x i8] c"---Invalid [OPTION(S)]---\0A\00"
@.str.5 = [46 x i8] c"\0A---Duplicate or NULL options encountered---\0A\00"
@.str.6 = [44 x i8] c"...Server mode unalbe to be established...\0A\00"
define i32 @getMode(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
%9 = load i32, i32* %3
%10 = icmp ne i32 %9, 3
%11 = zext i1 %10 to i32
%12 = load i32, i32* %3
%13 = icmp ne i32 %12, 4
%14 = zext i1 %13 to i32
%15 = and i32 %11, %14
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %26
17: ; preds = %2
%18 = load i32, i32* @stderr
%19 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%20 = load i8**, i8*** %4
%21 = getelementptr inbounds i8*, i8** %20, i64 0
%22 = load i8*, i8** %21
%23 = call i32 @usageErr(i8* %22)
%24 = load i32, i32* @EXIT_FAILURE
%25 = call i32 @exit(i32 %24)
unreachable
26: ; preds = %2
%27 = load i8**, i8*** %4
%28 = load i32, i32* %3
%29 = sub nsw i32 %28, 1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8*, i8** %27, i64 %30
%32 = load i8*, i8** %31
%33 = call i32 @strncmp(i8* %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%34 = icmp ne i32 %33, 0
br i1 %34, label %44, label %35
35: ; preds = %26
%36 = load i32, i32* @stderr
%37 = call i32 @fprintf(i32 %36, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
%38 = load i8**, i8*** %4
%39 = getelementptr inbounds i8*, i8** %38, i64 0
%40 = load i8*, i8** %39
%41 = call i32 @usageErr(i8* %40)
%42 = load i32, i32* @EXIT_FAILURE
%43 = call i32 @exit(i32 %42)
unreachable
44: ; preds = %26
br label %45
45: ; preds = %67, %44
%46 = load i32, i32* %3
%47 = load i8**, i8*** %4
%48 = call i32 @getopt(i32 %46, i8** %47, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
store i32 %48, i32* %5
%49 = icmp ne i32 %48, -1
br i1 %49, label %50, label %68
50: ; preds = %45
%51 = load i32, i32* %5
switch i32 %51, label %58 [
i32 114, label %52
i32 102, label %55
]
52: ; preds = %50
%53 = load i32, i32* %6
%54 = add nsw i32 %53, 1
store i32 %54, i32* %6
br label %67
55: ; preds = %50
%56 = load i32, i32* %7
%57 = add nsw i32 %56, 1
store i32 %57, i32* %7
br label %67
58: ; preds = %50
%59 = load i32, i32* @stderr
%60 = call i32 @fprintf(i32 %59, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
%61 = load i8**, i8*** %4
%62 = getelementptr inbounds i8*, i8** %61, i64 0
%63 = load i8*, i8** %62
%64 = call i32 @usageErr(i8* %63)
%65 = load i32, i32* @EXIT_FAILURE
%66 = call i32 @exit(i32 %65)
unreachable
67: ; preds = %55, %52
br label %45
68: ; preds = %45
%69 = load i32, i32* %6
%70 = icmp eq i32 %69, 0
%71 = zext i1 %70 to i32
%72 = load i32, i32* %7
%73 = icmp eq i32 %72, 0
%74 = zext i1 %73 to i32
%75 = and i32 %71, %74
%76 = load i32, i32* %6
%77 = icmp sgt i32 %76, 1
%78 = zext i1 %77 to i32
%79 = or i32 %75, %78
%80 = load i32, i32* %7
%81 = icmp sgt i32 %80, 1
%82 = zext i1 %81 to i32
%83 = or i32 %79, %82
%84 = icmp ne i32 %83, 0
br i1 %84, label %85, label %96
85: ; preds = %68
%86 = load i32, i32* @stderr
%87 = call i32 @fprintf(i32 %86, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.5, i64 0, i64 0))
%88 = load i32, i32* @stderr
%89 = call i32 @fprintf(i32 %88, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0))
%90 = load i8**, i8*** %4
%91 = getelementptr inbounds i8*, i8** %90, i64 0
%92 = load i8*, i8** %91
%93 = call i32 @usageErr(i8* %92)
%94 = load i32, i32* @EXIT_FAILURE
%95 = call i32 @exit(i32 %94)
unreachable
96: ; preds = %68
%97 = load i32, i32* %6
%98 = icmp eq i32 %97, 1
%99 = zext i1 %98 to i32
%100 = load i32, i32* %7
%101 = icmp eq i32 %100, 0
%102 = zext i1 %101 to i32
%103 = and i32 %99, %102
%104 = icmp ne i32 %103, 0
br i1 %104, label %105, label %106
105: ; preds = %96
store i32 1, i32* %8
br label %106
106: ; preds = %105, %96
%107 = load i32, i32* %6
%108 = icmp eq i32 %107, 0
%109 = zext i1 %108 to i32
%110 = load i32, i32* %7
%111 = icmp eq i32 %110, 1
%112 = zext i1 %111 to i32
%113 = and i32 %109, %112
%114 = icmp ne i32 %113, 0
br i1 %114, label %115, label %116
115: ; preds = %106
store i32 2, i32* %8
br label %116
116: ; preds = %115, %106
%117 = load i32, i32* %6
%118 = load i32, i32* %7
%119 = add nsw i32 %117, %118
%120 = icmp eq i32 %119, 2
br i1 %120, label %121, label %122
121: ; preds = %116
store i32 3, i32* %8
br label %122
122: ; preds = %121, %116
ret i32 1
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [28 x i8] c"\0A---Incorrect input args---\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"-\00"
@.str.2 = [42 x i8] c"\0A---Need <hostname> as final argument---\0A\00"
@.str.3 = [4 x i8] c":rf\00"
@.str.4 = [27 x i8] c"---Invalid [OPTION(S)]---\0A\00"
@.str.5 = [46 x i8] c"\0A---Duplicate or NULL options encountered---\0A\00"
@.str.6 = [44 x i8] c"...Server mode unalbe to be established...\0A\00"
define i32 @getMode(i32 %0, i8** %1) {
%3 = add i32 %0, -5
%4 = icmp ult i32 %3, -2
br i1 %4, label %5, label %12
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%8 = load i8*, i8** %1
%9 = tail call i32 @usageErr(i8* %8)
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %2
%13 = add nsw i32 %0, -1
%14 = zext i32 %13 to i64
%15 = getelementptr inbounds i8*, i8** %1, i64 %14
%16 = load i8*, i8** %15
%17 = tail call i32 @strncmp(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %31
19: ; preds = %12
%20 = load i32, i32* @stderr
%21 = tail call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
%22 = load i8*, i8** %1
%23 = tail call i32 @usageErr(i8* %22)
%24 = load i32, i32* @EXIT_FAILURE
%25 = tail call i32 @exit(i32 %24)
unreachable
26: ; preds = %31, %34
%27 = phi i32 [ %35, %34 ], [ %33, %31 ]
%28 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
switch i32 %28, label %36 [
i32 -1, label %43
i32 114, label %29
i32 102, label %34
]
29: ; preds = %26
%30 = add nuw nsw i32 %32, 1
br label %31
31: ; preds = %12, %29
%32 = phi i32 [ %30, %29 ], [ 0, %12 ]
%33 = phi i32 [ %27, %29 ], [ 0, %12 ]
br label %26
34: ; preds = %26
%35 = add nsw i32 %27, 1
br label %26
36: ; preds = %26
%37 = load i32, i32* @stderr
%38 = tail call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
%39 = load i8*, i8** %1
%40 = tail call i32 @usageErr(i8* %39)
%41 = load i32, i32* @EXIT_FAILURE
%42 = tail call i32 @exit(i32 %41)
unreachable
43: ; preds = %26
%44 = or i32 %27, %32
%45 = icmp eq i32 %44, 0
%46 = icmp ugt i32 %32, 1
%47 = or i1 %46, %45
%48 = icmp sgt i32 %27, 1
%49 = or i1 %48, %47
br i1 %49, label %50, label %59
50: ; preds = %43
%51 = load i32, i32* @stderr
%52 = tail call i32 @fprintf(i32 %51, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.5, i64 0, i64 0))
%53 = load i32, i32* @stderr
%54 = tail call i32 @fprintf(i32 %53, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0))
%55 = load i8*, i8** %1
%56 = tail call i32 @usageErr(i8* %55)
%57 = load i32, i32* @EXIT_FAILURE
%58 = tail call i32 @exit(i32 %57)
unreachable
59: ; preds = %43
ret i32 1
}