#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*/ activate_current_message();
int /*<<< orphan*/ activate_next_message();
int /*<<< orphan*/ activate_prev_message();
void cmd_msg(const char *pf, char **args) {
  char dir = 0;
  while (*pf) {
    switch (*pf) {
    case 'n':
    case 'p':
      dir = *pf;
      break;
    }
    pf++;
  }
  if (dir == 'n') {
    activate_next_message();
  } else if (dir == 'p') {
    activate_prev_message();
  } else {
    activate_current_message();
  }
}


x86 assembly (clang, -O0):
<cmd_msg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x0,-0x11(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     1194 <cmd_msg+0x64>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x18(%rbp)
sub    $0x6e,%eax
je     117a <cmd_msg+0x4a>
jmp    1169 <cmd_msg+0x39>
mov    -0x18(%rbp),%eax
sub    $0x70,%eax
jne    1183 <cmd_msg+0x53>
jmp    117a <cmd_msg+0x4a>
mov    -0x8(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x11(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1144 <cmd_msg+0x14>
movsbl -0x11(%rbp),%eax
cmp    $0x6e,%eax
jne    11ad <cmd_msg+0x7d>
mov    $0x0,%al
call   1050 <activate_next_message@plt>
jmp    11d2 <cmd_msg+0xa2>
movsbl -0x11(%rbp),%eax
cmp    $0x70,%eax
jne    11c6 <cmd_msg+0x96>
mov    $0x0,%al
call   1030 <activate_prev_message@plt>
jmp    11cd <cmd_msg+0x9d>
mov    $0x0,%al
call   1040 <activate_current_message@plt>
jmp    11d2 <cmd_msg+0xa2>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmd_msg>:
mov    (%rdi),%cl
test   %cl,%cl
je     116b <cmd_msg+0x3b>
add    $0x1,%rdi
xor    %eax,%eax
jmp    114d <cmd_msg+0x1d>
xchg   %ax,%ax
mov    %ecx,%eax
movzbl (%rdi),%ecx
add    $0x1,%rdi
test   %cl,%cl
je     115c <cmd_msg+0x2c>
movsbl %cl,%edx
cmp    $0x70,%edx
je     1140 <cmd_msg+0x10>
cmp    $0x6e,%edx
je     1140 <cmd_msg+0x10>
jmp    1142 <cmd_msg+0x12>
cmp    $0x70,%al
je     1172 <cmd_msg+0x42>
cmp    $0x6e,%al
jne    116b <cmd_msg+0x3b>
xor    %eax,%eax
jmp    1050 <activate_next_message@plt>
xor    %eax,%eax
jmp    1040 <activate_current_message@plt>
xor    %eax,%eax
jmp    1030 <activate_prev_message@plt>

LLVM IR (-O0):
define void @cmd_msg(i8* %0, i8** %1) {
%3 = alloca i8*
%4 = alloca i8**
%5 = alloca i8
store i8* %0, i8** %3
store i8** %1, i8*** %4
store i8 0, i8* %5
br label %6
6: ; preds = %17, %2
%7 = load i8*, i8** %3
%8 = load i8, i8* %7
%9 = icmp ne i8 %8, 0
br i1 %9, label %10, label %20
10: ; preds = %6
%11 = load i8*, i8** %3
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
switch i32 %13, label %17 [
i32 110, label %14
i32 112, label %14
]
14: ; preds = %10, %10
%15 = load i8*, i8** %3
%16 = load i8, i8* %15
store i8 %16, i8* %5
br label %17
17: ; preds = %10, %14
%18 = load i8*, i8** %3
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %3
br label %6
20: ; preds = %6
%21 = load i8, i8* %5
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 110
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = call i32 (...) @activate_next_message()
br label %35
26: ; preds = %20
%27 = load i8, i8* %5
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 112
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = call i32 (...) @activate_prev_message()
br label %34
32: ; preds = %26
%33 = call i32 (...) @activate_current_message()
br label %34
34: ; preds = %32, %30
br label %35
35: ; preds = %34, %24
ret void
}

LLVM IR (-O2):
define void @cmd_msg(i8* nocapture %0, i8** nocapture readnone %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %21, label %5
5: ; preds = %2, %11
%6 = phi i8 [ %14, %11 ], [ %3, %2 ]
%7 = phi i8 [ %12, %11 ], [ 0, %2 ]
%8 = phi i8* [ %13, %11 ], [ %0, %2 ]
%9 = sext i8 %6 to i32
switch i32 %9, label %11 [
i32 110, label %10
i32 112, label %10
]
10: ; preds = %5, %5
br label %11
11: ; preds = %5, %10
%12 = phi i8 [ %7, %5 ], [ %6, %10 ]
%13 = getelementptr inbounds i8, i8* %8, i64 1
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 0
br i1 %15, label %16, label %5
16: ; preds = %11
switch i8 %12, label %21 [
i8 110, label %17
i8 112, label %19
]
17: ; preds = %16
%18 = tail call i32 (...) @activate_next_message()
br label %23
19: ; preds = %16
%20 = tail call i32 (...) @activate_prev_message()
br label %23
21: ; preds = %2, %16
%22 = tail call i32 (...) @activate_current_message()
br label %23
23: ; preds = %19, %21, %17
ret void
}