#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 EINVAL;
int /*<<< orphan*/ strcasecmp(char const *, char *);
int wrc_ptp_start();
int wrc_ptp_stop();
int cmd_ptp(const char *args[]) {
  if (!strcasecmp(args[0], "start"))
    return wrc_ptp_start();
  else if (!strcasecmp(args[0], "stop"))
    return wrc_ptp_stop();
  else
    return -EINVAL;
  return 0;
}


x86 assembly (clang, -O0):
<cmd_ptp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xeb6(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    1167 <cmd_ptp+0x37>
mov    $0x0,%al
call   1050 <wrc_ptp_start@plt>
mov    %eax,-0x4(%rbp)
jmp    11a0 <cmd_ptp+0x70>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe91(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    1192 <cmd_ptp+0x62>
mov    $0x0,%al
call   1040 <wrc_ptp_stop@plt>
mov    %eax,-0x4(%rbp)
jmp    11a0 <cmd_ptp+0x70>
xor    %eax,%eax
mov    0x2e45(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmd_ptp>:
push   %rbx
mov    (%rdi),%rbx
lea    0xec5(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     1167 <cmd_ptp+0x37>
lea    0xeb8(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     116f <cmd_ptp+0x3f>
mov    0x2e7f(%rip),%rcx
xor    %eax,%eax
sub    (%rcx),%eax
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
jmp    1050 <wrc_ptp_start@plt>
xor    %eax,%eax
pop    %rbx
jmp    1040 <wrc_ptp_stop@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"start\00"
@.str.1 = [5 x i8] c"stop\00"
@EINVAL = global i32 0
define i32 @cmd_ptp(i8** %0) {
%2 = alloca i32
%3 = alloca i8**
store i8** %0, i8*** %3
%4 = load i8**, i8*** %3
%5 = getelementptr inbounds i8*, i8** %4, i64 0
%6 = load i8*, i8** %5
%7 = call i32 @strcasecmp(i8* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%8 = icmp ne i32 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %1
%10 = call i32 (...) @wrc_ptp_start()
store i32 %10, i32* %2
br label %22
11: ; preds = %1
%12 = load i8**, i8*** %3
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 @strcasecmp(i8* %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp ne i32 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %11
%18 = call i32 (...) @wrc_ptp_stop()
store i32 %18, i32* %2
br label %22
19: ; preds = %11
%20 = load i32, i32* @EINVAL
%21 = sub nsw i32 0, %20
store i32 %21, i32* %2
br label %22
22: ; preds = %19, %17, %9
%23 = load i32, i32* %2
ret i32 %23
}

LLVM IR (-O2):
@.str = [6 x i8] c"start\00"
@.str.1 = [5 x i8] c"stop\00"
@EINVAL = global i32 0
define i32 @cmd_ptp(i8** nocapture %0) {
%2 = load i8*, i8** %0
%3 = tail call i32 @strcasecmp(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = tail call i32 (...) @wrc_ptp_start()
br label %15
7: ; preds = %1
%8 = tail call i32 @strcasecmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = tail call i32 (...) @wrc_ptp_stop()
br label %15
12: ; preds = %7
%13 = load i32, i32* @EINVAL
%14 = sub nsw i32 0, %13
br label %15
15: ; preds = %12, %10, %5
%16 = phi i32 [ %14, %12 ], [ %11, %10 ], [ %6, %5 ]
ret i32 %16
}