#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 */
scalar_t__ is_null_or_empty(char const *);
char *strstr(char const *, char *);
const char *ma_get_clean_cmd(const char cmd[]) {
  const char *clean_cmd;
  const char *const break_point = strstr(cmd, "%pc");
  if (break_point == NULL) {
    return NULL;
  }
  clean_cmd = break_point + 3;
  return is_null_or_empty(clean_cmd) ? NULL : clean_cmd;
}


x86 assembly (clang, -O0):
<ma_get_clean_cmd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xec9(%rip),%rsi
call   1040 <strstr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1158 <ma_get_clean_cmd+0x38>
movq   $0x0,-0x8(%rbp)
jmp    1192 <ma_get_clean_cmd+0x72>
mov    -0x20(%rbp),%rax
add    $0x3,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <is_null_or_empty@plt>
cmp    $0x0,%rax
je     1182 <ma_get_clean_cmd+0x62>
xor    %eax,%eax
mov    %rax,-0x28(%rbp)
jmp    118a <ma_get_clean_cmd+0x6a>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ma_get_clean_cmd>:
push   %rbx
lea    0xed8(%rip),%rsi
call   1040 <strstr@plt>
test   %rax,%rax
je     114f <ma_get_clean_cmd+0x2f>
mov    %rax,%rbx
add    $0x3,%rbx
mov    %rbx,%rdi
call   1030 <is_null_or_empty@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
cmove  %rbx,%rax
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%pc\00"
define i8* @ma_get_clean_cmd(i8* %0) {
%2 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i8* %2, null
br i1 %3, label %9, label %4
4: ; preds = %1
%5 = getelementptr inbounds i8, i8* %2, i64 3
%6 = tail call i64 @is_null_or_empty(i8* %5)
%7 = icmp eq i64 %6, 0
%8 = select i1 %7, i8* %5, i8* null
br label %9
9: ; preds = %1, %4
%10 = phi i8* [ %8, %4 ], [ null, %1 ]
ret i8* %10
}