#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*/ delchar(char *);
int /*<<< orphan*/ rtrim(char **);
void strip_exec_field_codes(char **exec) {
  if (!**exec || !*exec)
    return;
  for (char *p = *exec; *p; p++) {
    if (*p == '\\') {
      delchar(p);
      continue;
    }
    if (*p == '%') {
      delchar(p);
      if (*p == '\0')
        break;
      if (*p != '%')
        delchar(p);
    }
  }
  rtrim(exec);
}


x86 assembly (clang, -O0):
<strip_exec_field_codes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
cmpb   $0x0,(%rax)
je     114a <strip_exec_field_codes+0x2a>
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
jne    114f <strip_exec_field_codes+0x2f>
jmp    11f0 <strip_exec_field_codes+0xd0>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     11e7 <strip_exec_field_codes+0xc7>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    1185 <strip_exec_field_codes+0x65>
mov    -0x10(%rbp),%rdi
call   1030 <delchar@plt>
jmp    11d6 <strip_exec_field_codes+0xb6>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x25,%eax
jne    11d1 <strip_exec_field_codes+0xb1>
mov    -0x10(%rbp),%rdi
call   1030 <delchar@plt>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11b3 <strip_exec_field_codes+0x93>
jmp    11e7 <strip_exec_field_codes+0xc7>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x25,%eax
je     11cc <strip_exec_field_codes+0xac>
mov    -0x10(%rbp),%rdi
call   1030 <delchar@plt>
jmp    11d1 <strip_exec_field_codes+0xb1>
jmp    11d6 <strip_exec_field_codes+0xb6>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    115a <strip_exec_field_codes+0x3a>
mov    -0x8(%rbp),%rdi
call   1040 <rtrim@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strip_exec_field_codes>:
push   %r14
push   %rbx
push   %rax
mov    (%rdi),%rbx
mov    (%rbx),%al
test   %al,%al
je     1182 <strip_exec_field_codes+0x62>
mov    %rdi,%r14
jmp    1150 <strip_exec_field_codes+0x30>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1030 <delchar@plt>
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
cmp    $0x25,%al
je     1160 <strip_exec_field_codes+0x40>
cmp    $0x5c,%al
je     1140 <strip_exec_field_codes+0x20>
test   %al,%al
jne    1148 <strip_exec_field_codes+0x28>
jmp    1173 <strip_exec_field_codes+0x53>
xchg   %ax,%ax
mov    %rbx,%rdi
call   1030 <delchar@plt>
movzbl (%rbx),%eax
cmp    $0x25,%al
je     1148 <strip_exec_field_codes+0x28>
test   %al,%al
jne    1140 <strip_exec_field_codes+0x20>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <rtrim@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @strip_exec_field_codes(i8** %0) {
%2 = alloca i8**
%3 = alloca i8*
store i8** %0, i8*** %2
%4 = load i8**, i8*** %2
%5 = load i8*, i8** %4
%6 = load i8, i8* %5
%7 = icmp ne i8 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %1
%9 = load i8**, i8*** %2
%10 = load i8*, i8** %9
%11 = icmp ne i8* %10, null
br i1 %11, label %13, label %12
12: ; preds = %8, %1
br label %57
13: ; preds = %8
%14 = load i8**, i8*** %2
%15 = load i8*, i8** %14
store i8* %15, i8** %3
br label %16
16: ; preds = %51, %13
%17 = load i8*, i8** %3
%18 = load i8, i8* %17
%19 = icmp ne i8 %18, 0
br i1 %19, label %20, label %54
20: ; preds = %16
%21 = load i8*, i8** %3
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 92
br i1 %24, label %25, label %28
25: ; preds = %20
%26 = load i8*, i8** %3
%27 = call i32 @delchar(i8* %26)
br label %51
28: ; preds = %20
%29 = load i8*, i8** %3
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 37
br i1 %32, label %33, label %50
33: ; preds = %28
%34 = load i8*, i8** %3
%35 = call i32 @delchar(i8* %34)
%36 = load i8*, i8** %3
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %41
40: ; preds = %33
br label %54
41: ; preds = %33
%42 = load i8*, i8** %3
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp ne i32 %44, 37
br i1 %45, label %46, label %49
46: ; preds = %41
%47 = load i8*, i8** %3
%48 = call i32 @delchar(i8* %47)
br label %49
49: ; preds = %46, %41
br label %50
50: ; preds = %49, %28
br label %51
51: ; preds = %50, %25
%52 = load i8*, i8** %3
%53 = getelementptr inbounds i8, i8* %52, i32 1
store i8* %53, i8** %3
br label %16
54: ; preds = %40, %16
%55 = load i8**, i8*** %2
%56 = call i32 @rtrim(i8** %55)
br label %57
57: ; preds = %54, %12
ret void
}

LLVM IR (-O2):
define void @strip_exec_field_codes(i8** %0) {
%2 = load i8*, i8** %0
%3 = load i8, i8* %2
%4 = icmp eq i8 %3, 0
br i1 %4, label %18, label %5
5: ; preds = %1, %13
%6 = phi i8 [ %15, %13 ], [ %3, %1 ]
%7 = phi i8* [ %14, %13 ], [ %2, %1 ]
switch i8 %6, label %13 [
i8 0, label %16
i8 92, label %11
i8 37, label %8
]
8: ; preds = %5
%9 = tail call i32 @delchar(i8* %7)
%10 = load i8, i8* %7
switch i8 %10, label %11 [
i8 0, label %16
i8 37, label %13
]
11: ; preds = %8, %5
%12 = tail call i32 @delchar(i8* %7)
br label %13
13: ; preds = %11, %8, %5
%14 = getelementptr inbounds i8, i8* %7, i64 1
%15 = load i8, i8* %14
br label %5
16: ; preds = %8, %5
%17 = tail call i32 @rtrim(i8** %0)
br label %18
18: ; preds = %1, %16
ret void
}