#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 */
typedef int int32_t;

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
int atoi(int /*<<< orphan*/);
int /*<<< orphan*/ check_string_is_number(int /*<<< orphan*/);
int /*<<< orphan*/ client(int, int, int);
int /*<<< orphan*/ client_server(int, int, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int getopt(int, char **, char *);
int /*<<< orphan*/ optarg;
int /*<<< orphan*/ print_help(char **);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  int32_t opt;
  int cflag = 0;
  int signal = -1;
  int id = -1;
  while ((opt = getopt(argc, argv, "h?ci:s:")) != -1) {
    switch (opt) {
    case 'c':
      cflag = 1;
      break;
    case 'i':
      if (!check_string_is_number(optarg)) {
        fprintf(stderr,
                "The argument of option 'i' is not a (positive) number.\n");
        print_help(argv);
        return EXIT_FAILURE;
      }
      id = atoi(optarg);
      break;
    case 's':
      if (!check_string_is_number(optarg)) {
        fprintf(stderr,
                "The argument of option 's' is not a (positive) number.\n");
        print_help(argv);
        return EXIT_FAILURE;
      }
      signal = atoi(optarg);
      break;
    case '?':
    case 'h':
    default:
      print_help(argv);
      return EXIT_FAILURE;
    }
  }
  if (signal < 0) {
    fprintf(stderr, "The argument of option 's' is missing or is < 0.\n");
    print_help(argv);
    return EXIT_FAILURE;
  }
  if (id < 0) {
    fprintf(stderr, "The argument of option 'i' is missing or is < 0.\n");
    print_help(argv);
    return EXIT_FAILURE;
  }
  int number_of_communications = 0;
  if (cflag) {
    number_of_communications = 1;
    client(id, signal, number_of_communications);
  } else {
    number_of_communications = 4;
    client_server(id, signal, number_of_communications);
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0xffffffff,-0x1c(%rbp)
movl   $0xffffffff,-0x20(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe57(%rip),%rdx
call   1060 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     12fa <main+0x18a>
mov    -0x14(%rbp),%eax
mov    %eax,-0x28(%rbp)
sub    $0x3f,%eax
je     12d6 <main+0x166>
jmp    11ce <main+0x5e>
mov    -0x28(%rbp),%eax
sub    $0x63,%eax
je     1212 <main+0xa2>
jmp    11df <main+0x6f>
mov    -0x28(%rbp),%eax
sub    $0x68,%eax
je     12d6 <main+0x166>
jmp    11f0 <main+0x80>
mov    -0x28(%rbp),%eax
sub    $0x69,%eax
je     121e <main+0xae>
jmp    1201 <main+0x91>
mov    -0x28(%rbp),%eax
sub    $0x73,%eax
je     127a <main+0x10a>
jmp    12db <main+0x16b>
movl   $0x1,-0x18(%rbp)
jmp    12f5 <main+0x185>
mov    0x2dd3(%rip),%rax
mov    (%rax),%edi
call   1030 <check_string_is_number@plt>
cmp    $0x0,%eax
jne    1264 <main+0xf4>
mov    0x2d9c(%rip),%rax
mov    (%rax),%edi
lea    0xdc3(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1080 <print_help@plt>
mov    0x2d76(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    13b8 <main+0x248>
mov    0x2d8d(%rip),%rax
mov    (%rax),%edi
call   1070 <atoi@plt>
mov    %eax,-0x20(%rbp)
jmp    12f5 <main+0x185>
mov    0x2d77(%rip),%rax
mov    (%rax),%edi
call   1030 <check_string_is_number@plt>
cmp    $0x0,%eax
jne    12c0 <main+0x150>
mov    0x2d40(%rip),%rax
mov    (%rax),%edi
lea    0xd9f(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1080 <print_help@plt>
mov    0x2d1a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    13b8 <main+0x248>
mov    0x2d31(%rip),%rax
mov    (%rax),%edi
call   1070 <atoi@plt>
mov    %eax,-0x1c(%rbp)
jmp    12f5 <main+0x185>
jmp    12db <main+0x16b>
mov    -0x10(%rbp),%rdi
call   1080 <print_help@plt>
mov    0x2ce5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    13b8 <main+0x248>
jmp    119b <main+0x2b>
cmpl   $0x0,-0x1c(%rbp)
jge    1333 <main+0x1c3>
mov    0x2ccd(%rip),%rax
mov    (%rax),%edi
lea    0xd64(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1080 <print_help@plt>
mov    0x2ca7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    13b8 <main+0x248>
cmpl   $0x0,-0x20(%rbp)
jge    136c <main+0x1fc>
mov    0x2c94(%rip),%rax
mov    (%rax),%edi
lea    0xd5d(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1080 <print_help@plt>
mov    0x2c6e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    13b8 <main+0x248>
movl   $0x0,-0x24(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     1397 <main+0x227>
movl   $0x1,-0x24(%rbp)
mov    -0x20(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x24(%rbp),%edx
call   1090 <client@plt>
jmp    13ac <main+0x23c>
movl   $0x4,-0x24(%rbp)
mov    -0x20(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x24(%rbp),%edx
call   1040 <client_server@plt>
mov    0x2c15(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %edi,%ebp
mov    $0xffffffff,%r14d
mov    $0x1,%al
mov    %eax,0x4(%rsp)
lea    0xe6d(%rip),%r15
mov    0x2e5e(%rip),%r13
mov    $0xffffffff,%ebx
nop
mov    %ebp,%edi
mov    %r12,%rsi
mov    %r15,%rdx
call   1060 <getopt@plt>
cmp    $0x69,%eax
jne    11cc <main+0x5c>
mov    0x0(%r13),%edi
call   1030 <check_string_is_number@plt>
test   %eax,%eax
je     1229 <main+0xb9>
mov    0x0(%r13),%edi
call   1070 <atoi@plt>
mov    %eax,%ebx
jmp    11a0 <main+0x30>
cmp    $0xffffffff,%eax
je     1208 <main+0x98>
cmp    $0x63,%eax
je     11fe <main+0x8e>
cmp    $0x73,%eax
jne    1262 <main+0xf2>
mov    0x0(%r13),%edi
call   1030 <check_string_is_number@plt>
test   %eax,%eax
je     129a <main+0x12a>
mov    0x0(%r13),%edi
call   1070 <atoi@plt>
mov    %eax,%r14d
jmp    11a0 <main+0x30>
movl   $0x0,0x4(%rsp)
jmp    11a0 <main+0x30>
test   %r14d,%r14d
js     123b <main+0xcb>
test   %ebx,%ebx
js     124d <main+0xdd>
testb  $0x1,0x4(%rsp)
je     1282 <main+0x112>
mov    %ebx,%edi
mov    %r14d,%esi
mov    $0x4,%edx
call   1040 <client_server@plt>
jmp    1291 <main+0x121>
mov    0x2da8(%rip),%rax
mov    (%rax),%edi
lea    0xdcf(%rip),%rsi
jmp    125d <main+0xed>
mov    0x2d96(%rip),%rax
mov    (%rax),%edi
lea    0xe2d(%rip),%rsi
jmp    125d <main+0xed>
mov    0x2d84(%rip),%rax
mov    (%rax),%edi
lea    0xe4d(%rip),%rsi
call   1050 <fprintf@plt>
mov    %r12,%rdi
call   1080 <print_help@plt>
mov    0x2d5f(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %ebx,%edi
mov    %r14d,%esi
mov    $0x1,%edx
call   1090 <client@plt>
mov    0x2d30(%rip),%rax
jmp    1271 <main+0x101>
mov    0x2d37(%rip),%rax
mov    (%rax),%edi
lea    0xd96(%rip),%rsi
jmp    125d <main+0xed>

LLVM IR (-O0):
@.str = [8 x i8] c"h?ci:s:\00"
@optarg = global i32 0
@stderr = global i32 0
@.str.1 = [56 x i8] c"The argument of option 'i' is not a (positive) number.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [56 x i8] c"The argument of option 's' is not a (positive) number.\0A\00"
@.str.3 = [50 x i8] c"The argument of option 's' is missing or is < 0.\0A\00"
@.str.4 = [50 x i8] c"The argument of option 'i' is missing or is < 0.\0A\00"
@EXIT_SUCCESS = global i32 0
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 i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
store i32 -1, i32* %8
store i32 -1, i32* %9
br label %11
11: ; preds = %50, %2
%12 = load i32, i32* %4
%13 = load i8**, i8*** %5
%14 = call i32 @getopt(i32 %12, i8** %13, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i32 %14, i32* %6
%15 = icmp ne i32 %14, -1
br i1 %15, label %16, label %51
16: ; preds = %11
%17 = load i32, i32* %6
switch i32 %17, label %46 [
i32 99, label %18
i32 105, label %19
i32 115, label %32
i32 63, label %45
i32 104, label %45
]
18: ; preds = %16
store i32 1, i32* %7
br label %50
19: ; preds = %16
%20 = load i32, i32* @optarg
%21 = call i32 @check_string_is_number(i32 %20)
%22 = icmp ne i32 %21, 0
br i1 %22, label %29, label %23
23: ; preds = %19
%24 = load i32, i32* @stderr
%25 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0))
%26 = load i8**, i8*** %5
%27 = call i32 @print_help(i8** %26)
%28 = load i32, i32* @EXIT_FAILURE
store i32 %28, i32* %3
br label %84
29: ; preds = %19
%30 = load i32, i32* @optarg
%31 = call i32 @atoi(i32 %30)
store i32 %31, i32* %9
br label %50
32: ; preds = %16
%33 = load i32, i32* @optarg
%34 = call i32 @check_string_is_number(i32 %33)
%35 = icmp ne i32 %34, 0
br i1 %35, label %42, label %36
36: ; preds = %32
%37 = load i32, i32* @stderr
%38 = call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.2, i64 0, i64 0))
%39 = load i8**, i8*** %5
%40 = call i32 @print_help(i8** %39)
%41 = load i32, i32* @EXIT_FAILURE
store i32 %41, i32* %3
br label %84
42: ; preds = %32
%43 = load i32, i32* @optarg
%44 = call i32 @atoi(i32 %43)
store i32 %44, i32* %8
br label %50
45: ; preds = %16, %16
br label %46
46: ; preds = %16, %45
%47 = load i8**, i8*** %5
%48 = call i32 @print_help(i8** %47)
%49 = load i32, i32* @EXIT_FAILURE
store i32 %49, i32* %3
br label %84
50: ; preds = %42, %29, %18
br label %11
51: ; preds = %11
%52 = load i32, i32* %8
%53 = icmp slt i32 %52, 0
br i1 %53, label %54, label %60
54: ; preds = %51
%55 = load i32, i32* @stderr
%56 = call i32 @fprintf(i32 %55, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0))
%57 = load i8**, i8*** %5
%58 = call i32 @print_help(i8** %57)
%59 = load i32, i32* @EXIT_FAILURE
store i32 %59, i32* %3
br label %84
60: ; preds = %51
%61 = load i32, i32* %9
%62 = icmp slt i32 %61, 0
br i1 %62, label %63, label %69
63: ; preds = %60
%64 = load i32, i32* @stderr
%65 = call i32 @fprintf(i32 %64, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0))
%66 = load i8**, i8*** %5
%67 = call i32 @print_help(i8** %66)
%68 = load i32, i32* @EXIT_FAILURE
store i32 %68, i32* %3
br label %84
69: ; preds = %60
store i32 0, i32* %10
%70 = load i32, i32* %7
%71 = icmp ne i32 %70, 0
br i1 %71, label %72, label %77
72: ; preds = %69
store i32 1, i32* %10
%73 = load i32, i32* %9
%74 = load i32, i32* %8
%75 = load i32, i32* %10
%76 = call i32 @client(i32 %73, i32 %74, i32 %75)
br label %82
77: ; preds = %69
store i32 4, i32* %10
%78 = load i32, i32* %9
%79 = load i32, i32* %8
%80 = load i32, i32* %10
%81 = call i32 @client_server(i32 %78, i32 %79, i32 %80)
br label %82
82: ; preds = %77, %72
%83 = load i32, i32* @EXIT_SUCCESS
store i32 %83, i32* %3
br label %84
84: ; preds = %82, %63, %54, %46, %36, %23
%85 = load i32, i32* %3
ret i32 %85
}

LLVM IR (-O2):
@.str = [8 x i8] c"h?ci:s:\00"
@optarg = global i32 0
@stderr = global i32 0
@.str.1 = [56 x i8] c"The argument of option 'i' is not a (positive) number.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [56 x i8] c"The argument of option 's' is not a (positive) number.\0A\00"
@.str.3 = [50 x i8] c"The argument of option 's' is missing or is < 0.\0A\00"
@.str.4 = [50 x i8] c"The argument of option 'i' is missing or is < 0.\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %10, %2
%4 = phi i1 [ true, %2 ], [ false, %10 ]
%5 = phi i32 [ -1, %2 ], [ %8, %10 ]
%6 = phi i32 [ -1, %2 ], [ %11, %10 ]
br label %7
7: ; preds = %3, %32
%8 = phi i32 [ %5, %3 ], [ %34, %32 ]
%9 = phi i32 [ %6, %3 ], [ %11, %32 ]
br label %10
10: ; preds = %7, %21
%11 = phi i32 [ %23, %21 ], [ %9, %7 ]
%12 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
switch i32 %12, label %35 [
i32 -1, label %37
i32 99, label %3
i32 105, label %13
i32 115, label %24
]
13: ; preds = %10
%14 = load i32, i32* @optarg
%15 = tail call i32 @check_string_is_number(i32 %14)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %13
%18 = load i32, i32* @stderr
%19 = tail call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0))
%20 = tail call i32 @print_help(i8** %1)
br label %54
21: ; preds = %13
%22 = load i32, i32* @optarg
%23 = tail call i32 @atoi(i32 %22)
br label %10
24: ; preds = %10
%25 = load i32, i32* @optarg
%26 = tail call i32 @check_string_is_number(i32 %25)
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %32
28: ; preds = %24
%29 = load i32, i32* @stderr
%30 = tail call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.2, i64 0, i64 0))
%31 = tail call i32 @print_help(i8** %1)
br label %54
32: ; preds = %24
%33 = load i32, i32* @optarg
%34 = tail call i32 @atoi(i32 %33)
br label %7
35: ; preds = %10
%36 = tail call i32 @print_help(i8** %1)
br label %54
37: ; preds = %10
%38 = icmp slt i32 %8, 0
br i1 %38, label %39, label %43
39: ; preds = %37
%40 = load i32, i32* @stderr
%41 = tail call i32 @fprintf(i32 %40, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0))
%42 = tail call i32 @print_help(i8** %1)
br label %54
43: ; preds = %37
%44 = icmp slt i32 %11, 0
br i1 %44, label %45, label %49
45: ; preds = %43
%46 = load i32, i32* @stderr
%47 = tail call i32 @fprintf(i32 %46, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0))
%48 = tail call i32 @print_help(i8** %1)
br label %54
49: ; preds = %43
br i1 %4, label %52, label %50
50: ; preds = %49
%51 = tail call i32 @client(i32 %11, i32 %8, i32 1)
br label %54
52: ; preds = %49
%53 = tail call i32 @client_server(i32 %11, i32 %8, i32 4)
br label %54
54: ; preds = %50, %52, %45, %39, %35, %28, %17
%55 = phi i32* [ @EXIT_FAILURE, %35 ], [ @EXIT_FAILURE, %28 ], [ @EXIT_FAILURE, %17 ], [ @EXIT_FAILURE, %39 ], [ @EXIT_FAILURE, %45 ], [ @EXIT_SUCCESS, %52 ], [ @EXIT_SUCCESS, %50 ]
%56 = load i32, i32* %55
ret i32 %56
}