#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 IPPROTO_TCP;
int /*<<< orphan*/ die_usage();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcasecmp(char const *, char *);
int parse_proto(const char *proto) {
  if (!strcasecmp(proto, "MPTCP"))
    return 262;
  if (!strcasecmp(proto, "TCP"))
    return IPPROTO_TCP;
  fprintf(stderr, "Unknown protocol: %s\n.", proto);
  die_usage();
  return 0;
}


x86 assembly (clang, -O0):
<parse_proto>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeb9(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    1161 <parse_proto+0x31>
movl   $0x106,-0x4(%rbp)
jmp    11b2 <parse_proto+0x82>
mov    -0x10(%rbp),%rdi
lea    0xe96(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    118b <parse_proto+0x5b>
mov    0x2e67(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11b2 <parse_proto+0x82>
mov    0x2e46(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe67(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x0,%al
call   1050 <die_usage@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_proto>:
push   %rbx
mov    %rdi,%rbx
lea    0xec5(%rip),%rsi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     117a <parse_proto+0x4a>
lea    0xeb7(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     1181 <parse_proto+0x51>
mov    0x2e7a(%rip),%rax
mov    (%rax),%edi
lea    0xe9f(%rip),%rsi
mov    %rbx,%rdx
call   1040 <fprintf@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <die_usage@plt>
jmp    118a <parse_proto+0x5a>
mov    $0x106,%ebx
jmp    118a <parse_proto+0x5a>
mov    0x2e60(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"MPTCP\00"
@.str.1 = [4 x i8] c"TCP\00"
@IPPROTO_TCP = global i32 0
@stderr = global i32 0
@.str.2 = [23 x i8] c"Unknown protocol: %s\0A.\00"
define i32 @parse_proto(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i32 @strcasecmp(i8* %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%6 = icmp ne i32 %5, 0
br i1 %6, label %8, label %7
7: ; preds = %1
store i32 262, i32* %2
br label %19
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i32 @strcasecmp(i8* %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp ne i32 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %8
%13 = load i32, i32* @IPPROTO_TCP
store i32 %13, i32* %2
br label %19
14: ; preds = %8
%15 = load i32, i32* @stderr
%16 = load i8*, i8** %3
%17 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %16)
%18 = call i32 (...) @die_usage()
store i32 0, i32* %2
br label %19
19: ; preds = %14, %12, %7
%20 = load i32, i32* %2
ret i32 %20
}

LLVM IR (-O2):
@.str = [6 x i8] c"MPTCP\00"
@.str.1 = [4 x i8] c"TCP\00"
@IPPROTO_TCP = global i32 0
@stderr = global i32 0
@.str.2 = [23 x i8] c"Unknown protocol: %s\0A.\00"
define i32 @parse_proto(i8* %0) {
%2 = tail call i32 @strcasecmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32 %2, 0
br i1 %3, label %13, label %4
4: ; preds = %1
%5 = tail call i32 @strcasecmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = load i32, i32* @IPPROTO_TCP
br label %13
9: ; preds = %4
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%12 = tail call i32 (...) @die_usage()
br label %13
13: ; preds = %1, %9, %7
%14 = phi i32 [ 0, %9 ], [ %8, %7 ], [ 262, %1 ]
ret i32 %14
}