#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*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ http_read(int, char **);
int /*<<< orphan*/ stdout;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ time_service();
int /*<<< orphan*/ udp_timeclient(int, char **);
int /*<<< orphan*/ udp_timeclient2(int, char **);
int /*<<< orphan*/ udp_timeserver(int, char **);
int main(int argc, char *argv[]) {
  if (argc == 1) {
    fprintf(stdout, "\trunning time service");
    time_service();
  } else if (argc == 4) {
    if (strcmp(argv[3], "tcpc") == 0) {
      http_read(argc, argv);
    } else if (strcmp(argv[3], "udpc") == 0) {
      udp_timeclient(argc, argv);
    } else if (strcmp(argv[3], "udpc2") == 0) {
      udp_timeclient2(argc, argv);
    } else if (strcmp(argv[3], "udps") == 0) {
      udp_timeserver(argc, argv);
    } else {
      fprintf(stdout,
              "\tusage  : %s <hostname/ip> <service/port> [tcpc|udpc|udps]\n",
              argv[0]);
    }
  } else {
    fprintf(stdout, "\tusage  : %s <hostname/ip> <service/port>\n", argv[0]);
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    11b3 <main+0x43>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
lea    0xe60(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x0,%al
call   1090 <time_service@plt>
jmp    12da <main+0x16a>
cmpl   $0x4,-0x8(%rbp)
jne    12ab <main+0x13b>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xe4a(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    11ec <main+0x7c>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <http_read@plt>
jmp    12a6 <main+0x136>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xe20(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    121b <main+0xab>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <udp_timeclient@plt>
jmp    12a1 <main+0x131>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xdf6(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    124a <main+0xda>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1040 <udp_timeclient2@plt>
jmp    129c <main+0x12c>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xdcd(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1279 <main+0x109>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1070 <udp_timeserver@plt>
jmp    1297 <main+0x127>
mov    0x2d60(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd9b(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    129c <main+0x12c>
jmp    12a1 <main+0x131>
jmp    12a6 <main+0x136>
jmp    12d5 <main+0x165>
mov    0x2d2e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xda5(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12e1 <main+0x171>
jmp    12da <main+0x16a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
cmp    $0x4,%edi
je     11a7 <main+0x37>
mov    0x2e60(%rip),%rax
cmp    $0x1,%edi
jne    1219 <main+0xa9>
mov    (%rax),%edi
lea    0xe6e(%rip),%rsi
xor    %ebx,%ebx
xor    %eax,%eax
call   1080 <fprintf@plt>
xor    %eax,%eax
call   1090 <time_service@plt>
jmp    126f <main+0xff>
mov    0x18(%rbx),%rdi
lea    0xe64(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1233 <main+0xc3>
mov    0x18(%rbx),%rdi
lea    0xe54(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1242 <main+0xd2>
mov    0x18(%rbx),%rdi
lea    0xe44(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1251 <main+0xe1>
mov    0x18(%rbx),%rdi
lea    0xe35(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1260 <main+0xf0>
mov    0x2dde(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe1d(%rip),%rsi
xor    %ebx,%ebx
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    126f <main+0xff>
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe42(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0xffffffff,%ebx
jmp    126f <main+0xff>
mov    $0x4,%edi
mov    %rbx,%rsi
call   1050 <http_read@plt>
jmp    126d <main+0xfd>
mov    $0x4,%edi
mov    %rbx,%rsi
call   1030 <udp_timeclient@plt>
jmp    126d <main+0xfd>
mov    $0x4,%edi
mov    %rbx,%rsi
call   1040 <udp_timeclient2@plt>
jmp    126d <main+0xfd>
mov    $0x4,%edi
mov    %rbx,%rsi
call   1070 <udp_timeserver@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [22 x i8] c"\09running time service\00"
@.str.1 = [5 x i8] c"tcpc\00"
@.str.2 = [5 x i8] c"udpc\00"
@.str.3 = [6 x i8] c"udpc2\00"
@.str.4 = [5 x i8] c"udps\00"
@.str.5 = [60 x i8] c"\09usage : %s <hostname/ip> <service/port> [tcpc|udpc|udps]\0A\00"
@.str.6 = [43 x i8] c"\09usage : %s <hostname/ip> <service/port>\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = load i32, i32* @stdout
%10 = call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%11 = call i32 (...) @time_service()
br label %72
12: ; preds = %2
%13 = load i32, i32* %4
%14 = icmp eq i32 %13, 4
br i1 %14, label %15, label %65
15: ; preds = %12
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 3
%18 = load i8*, i8** %17
%19 = call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %15
%22 = load i32, i32* %4
%23 = load i8**, i8*** %5
%24 = call i32 @http_read(i32 %22, i8** %23)
br label %64
25: ; preds = %15
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 3
%28 = load i8*, i8** %27
%29 = call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %35
31: ; preds = %25
%32 = load i32, i32* %4
%33 = load i8**, i8*** %5
%34 = call i32 @udp_timeclient(i32 %32, i8** %33)
br label %63
35: ; preds = %25
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 3
%38 = load i8*, i8** %37
%39 = call i64 @strcmp(i8* %38, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %45
41: ; preds = %35
%42 = load i32, i32* %4
%43 = load i8**, i8*** %5
%44 = call i32 @udp_timeclient2(i32 %42, i8** %43)
br label %62
45: ; preds = %35
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i64 3
%48 = load i8*, i8** %47
%49 = call i64 @strcmp(i8* %48, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%50 = icmp eq i64 %49, 0
br i1 %50, label %51, label %55
51: ; preds = %45
%52 = load i32, i32* %4
%53 = load i8**, i8*** %5
%54 = call i32 @udp_timeserver(i32 %52, i8** %53)
br label %61
55: ; preds = %45
%56 = load i32, i32* @stdout
%57 = load i8**, i8*** %5
%58 = getelementptr inbounds i8*, i8** %57, i64 0
%59 = load i8*, i8** %58
%60 = call i32 (i32, i8*, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.5, i64 0, i64 0), i8* %59)
br label %61
61: ; preds = %55, %51
br label %62
62: ; preds = %61, %41
br label %63
63: ; preds = %62, %31
br label %64
64: ; preds = %63, %21
br label %71
65: ; preds = %12
%66 = load i32, i32* @stdout
%67 = load i8**, i8*** %5
%68 = getelementptr inbounds i8*, i8** %67, i64 0
%69 = load i8*, i8** %68
%70 = call i32 (i32, i8*, ...) @fprintf(i32 %66, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0), i8* %69)
store i32 -1, i32* %3
br label %73
71: ; preds = %64
br label %72
72: ; preds = %71, %8
store i32 0, i32* %3
br label %73
73: ; preds = %72, %65
%74 = load i32, i32* %3
ret i32 %74
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [22 x i8] c"\09running time service\00"
@.str.1 = [5 x i8] c"tcpc\00"
@.str.2 = [5 x i8] c"udpc\00"
@.str.3 = [6 x i8] c"udpc2\00"
@.str.4 = [5 x i8] c"udps\00"
@.str.5 = [60 x i8] c"\09usage : %s <hostname/ip> <service/port> [tcpc|udpc|udps]\0A\00"
@.str.6 = [43 x i8] c"\09usage : %s <hostname/ip> <service/port>\0A\00"
define i32 @main(i32 %0, i8** %1) {
switch i32 %0, label %36 [
i32 1, label %3
i32 4, label %7
]
3: ; preds = %2
%4 = load i32, i32* @stdout
%5 = tail call i32 (i32, i8*, ...) @fprintf(i32 %4, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 (...) @time_service()
br label %40
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 3
%9 = load i8*, i8** %8
%10 = tail call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = tail call i32 @http_read(i32 4, i8** %1)
br label %40
14: ; preds = %7
%15 = load i8*, i8** %8
%16 = tail call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = tail call i32 @udp_timeclient(i32 4, i8** %1)
br label %40
20: ; preds = %14
%21 = load i8*, i8** %8
%22 = tail call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = tail call i32 @udp_timeclient2(i32 4, i8** %1)
br label %40
26: ; preds = %20
%27 = load i8*, i8** %8
%28 = tail call i64 @strcmp(i8* %27, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = tail call i32 @udp_timeserver(i32 4, i8** %1)
br label %40
32: ; preds = %26
%33 = load i32, i32* @stdout
%34 = load i8*, i8** %1
%35 = tail call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.5, i64 0, i64 0), i8* %34)
br label %40
36: ; preds = %2
%37 = load i32, i32* @stdout
%38 = load i8*, i8** %1
%39 = tail call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0), i8* %38)
br label %40
40: ; preds = %3, %12, %24, %32, %30, %18, %36
%41 = phi i32 [ -1, %36 ], [ 0, %18 ], [ 0, %30 ], [ 0, %32 ], [ 0, %24 ], [ 0, %12 ], [ 0, %3 ]
ret i32 %41
}