#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*/ assert(char const *);
scalar_t__ strncmp(char const *, char *, int);
int msg_gettype(const char *msg) {
  assert(msg);
  if (0 == strncmp(msg, "hello", 5)) {
    return 1;
  } else if (0 == strncmp(msg, "bye", 3)) {
    return 1 << 2;
  } else if (0 == strncmp(msg, "get", 3)) {
    return 1 << 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<msg_gettype>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <assert@plt>
mov    -0x10(%rbp),%rdi
lea    0xec0(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1164 <msg_gettype+0x44>
movl   $0x1,-0x4(%rbp)
jmp    11d3 <msg_gettype+0xb3>
mov    -0x10(%rbp),%rdi
lea    0xe97(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1193 <msg_gettype+0x73>
movl   $0x4,-0x4(%rbp)
jmp    11d3 <msg_gettype+0xb3>
mov    -0x10(%rbp),%rdi
lea    0xe6c(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    11c2 <msg_gettype+0xa2>
movl   $0x2,-0x4(%rbp)
jmp    11d3 <msg_gettype+0xb3>
jmp    11c7 <msg_gettype+0xa7>
jmp    11cc <msg_gettype+0xac>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<msg_gettype>:
push   %rbx
mov    %rdi,%rbx
call   1040 <assert@plt>
lea    0xed0(%rip),%rsi
mov    %rbx,%rdi
mov    $0x5,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     117e <msg_gettype+0x5e>
lea    0xebd(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1185 <msg_gettype+0x65>
lea    0xea8(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
sete   %al
add    %eax,%eax
pop    %rbx
ret
mov    $0x1,%eax
pop    %rbx
ret
mov    $0x4,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"hello\00"
@.str.1 = [4 x i8] c"bye\00"
@.str.2 = [4 x i8] c"get\00"
define i32 @msg_gettype(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i32 @assert(i8* %4)
%6 = load i8*, i8** %3
%7 = call i64 @strncmp(i8* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 5)
%8 = icmp eq i64 0, %7
br i1 %8, label %9, label %10
9: ; preds = %1
store i32 1, i32* %2
br label %23
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = call i64 @strncmp(i8* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
%13 = icmp eq i64 0, %12
br i1 %13, label %14, label %15
14: ; preds = %10
store i32 4, i32* %2
br label %23
15: ; preds = %10
%16 = load i8*, i8** %3
%17 = call i64 @strncmp(i8* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 3)
%18 = icmp eq i64 0, %17
br i1 %18, label %19, label %20
19: ; preds = %15
store i32 2, i32* %2
br label %23
20: ; preds = %15
br label %21
21: ; preds = %20
br label %22
22: ; preds = %21
store i32 0, i32* %2
br label %23
23: ; preds = %22, %19, %14, %9
%24 = load i32, i32* %2
ret i32 %24
}

LLVM IR (-O2):
@.str = [6 x i8] c"hello\00"
@.str.1 = [4 x i8] c"bye\00"
@.str.2 = [4 x i8] c"get\00"
define i32 @msg_gettype(i8* %0) {
%2 = tail call i32 @assert(i8* %0)
%3 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 5)
%4 = icmp eq i64 %3, 0
br i1 %4, label %12, label %5
5: ; preds = %1
%6 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
%7 = icmp eq i64 %6, 0
br i1 %7, label %12, label %8
8: ; preds = %5
%9 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 3)
%10 = icmp eq i64 %9, 0
%11 = select i1 %10, i32 2, i32 0
br label %12
12: ; preds = %8, %5, %1
%13 = phi i32 [ 1, %1 ], [ 4, %5 ], [ %11, %8 ]
ret i32 %13
}