#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 *, char *, char *);
int runSerial(char *);
int runUDP(char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  if (argc < 2) {
    fprintf(stderr, "Usage:\n\t%s serial <serial_device>\n\t%s udp <adapter>\n",
            argv[0], argv[0]);
    return 1;
  }
  if (strcmp("serial", argv[1]) == 0) {
    return runSerial(argv[2]);
  } else {
    return runUDP(argv[2]);
  }
  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   $0x2,-0x8(%rbp)
jge    118f <main+0x4f>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
lea    0xe82(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11d2 <main+0x92>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe97(%rip),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11c2 <main+0x82>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <runSerial@plt>
mov    %eax,-0x4(%rbp)
jmp    11d2 <main+0x92>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1040 <runUDP@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
cmp    $0x1,%edi
jg     116b <main+0x2b>
mov    0x2e90(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rcx
lea    0xea4(%rip),%rsi
mov    %rcx,%rdx
call   1060 <fprintf@plt>
mov    $0x1,%eax
pop    %rbx
ret
mov    0x8(%rbx),%rsi
lea    0xebf(%rip),%rdi
call   1050 <strcmp@plt>
mov    0x10(%rbx),%rdi
test   %rax,%rax
je     118a <main+0x4a>
pop    %rbx
jmp    1040 <runUDP@plt>
pop    %rbx
jmp    1030 <runSerial@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [53 x i8] c"Usage:\0A\09%s serial <serial_device>\0A\09%s udp <adapter>\0A\00"
@.str.1 = [7 x i8] c"serial\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 slt i32 %6, 2
br i1 %7, label %8, label %17
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 0
%12 = load i8*, i8** %11
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), i8* %12, i8* %15)
store i32 1, i32* %3
br label %33
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i64 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %28
23: ; preds = %17
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 2
%26 = load i8*, i8** %25
%27 = call i32 @runSerial(i8* %26)
store i32 %27, i32* %3
br label %33
28: ; preds = %17
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 2
%31 = load i8*, i8** %30
%32 = call i32 @runUDP(i8* %31)
store i32 %32, i32* %3
br label %33
33: ; preds = %28, %23, %8
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [53 x i8] c"Usage:\0A\09%s serial <serial_device>\0A\09%s udp <adapter>\0A\00"
@.str.1 = [7 x i8] c"serial\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), i8* %6, i8* %6)
br label %19
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i64 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = icmp eq i64 %11, 0
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
br i1 %12, label %15, label %17
15: ; preds = %8
%16 = tail call i32 @runSerial(i8* %14)
br label %19
17: ; preds = %8
%18 = tail call i32 @runUDP(i8* %14)
br label %19
19: ; preds = %17, %15, %4
%20 = phi i32 [ 1, %4 ], [ %16, %15 ], [ %18, %17 ]
ret i32 %20
}