#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*/ exit(int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ string_trim_right(char *, char *, char *);
int main(int argc, char **argv) {
  char *src = NULL;
  char *module = NULL;
  char dst[256];
  printf("******************************\n");
  src = "agege g egegge ge\t\n#\n";
  module = "\t\n#";
  dst[0] = '\0';
  if (string_trim_right(src, dst, module) < 0) {
    printf("函数调用错误！\n");
    exit(-1);
  }
  printf("源字符串:%s\n"
         "模式字符串:%s\n"
         "结果字符串:%s\n\n",
         src, module, dst);
  printf("******************************\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb2(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xebd(%rip),%rax
mov    %rax,-0x20(%rbp)
movb   $0x0,-0x120(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x120(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1040 <string_trim_right@plt>
cmp    $0x0,%rax
jge    11ba <main+0x8a>
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    -0x120(%rbp),%rcx
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x108,%rsp
lea    0xf04(%rip),%rdi
call   1030 <puts@plt>
movb   $0x0,(%rsp)
lea    0xea2(%rip),%rdi
lea    0xeb1(%rip),%rdx
mov    %rsp,%rsi
call   1050 <string_trim_right@plt>
test   %rax,%rax
js     11a7 <main+0x67>
lea    0xea1(%rip),%rdi
lea    0xe80(%rip),%rsi
lea    0xe8f(%rip),%rdx
mov    %rsp,%rcx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeba(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x108,%rsp
ret
lea    0xec3(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [32 x i8] c"******************************\0A\00"
@.str.1 = [22 x i8] c"agege g egegge ge\09\0A#\0A\00"
@.str.2 = [4 x i8] c"\09\0A#\00"
@.str.3 = [23 x i8] c"\E5\87\BD\E6\95\B0\E8\B0\83\E7\94\A8\E9\94\99\E8\AF\AF\EF\BC\81\0A\00"
@.str.4 = [56 x i8] c"\E6\BA\90\E5\AD\97\E7\AC\A6\E4\B8\B2:%s\0A\E6\A8\A1\E5\BC\8F\E5\AD\97\E7\AC\A6\E4\B8\B2:%s\0A\E7\BB\93\E6\9E\9C\E5\AD\97\E7\AC\A6\E4\B8\B2:%s\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca [256 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %6
store i8* null, i8** %7
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8** %6
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8** %7
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
store i8 0, i8* %10
%11 = load i8*, i8** %6
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%13 = load i8*, i8** %7
%14 = call i64 @string_trim_right(i8* %11, i8* %12, i8* %13)
%15 = icmp slt i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %2
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%18 = call i32 @exit(i32 -1)
unreachable
19: ; preds = %2
%20 = load i8*, i8** %6
%21 = load i8*, i8** %7
%22 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.4, i64 0, i64 0), i8* %20, i8* %21, i8* %22)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [22 x i8] c"agege g egegge ge\09\0A#\0A\00"
@.str.2 = [4 x i8] c"\09\0A#\00"
@.str.4 = [56 x i8] c"\E6\BA\90\E5\AD\97\E7\AC\A6\E4\B8\B2:%s\0A\E6\A8\A1\E5\BC\8F\E5\AD\97\E7\AC\A6\E4\B8\B2:%s\0A\E7\BB\93\E6\9E\9C\E5\AD\97\E7\AC\A6\E4\B8\B2:%s\0A\0A\00"
@str.5 = [31 x i8] c"******************************\00"
@str.6 = [22 x i8] c"\E5\87\BD\E6\95\B0\E8\B0\83\E7\94\A8\E9\94\99\E8\AF\AF\EF\BC\81\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.5, i64 0, i64 0))
store i8 0, i8* %4
%6 = call i64 @string_trim_right(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.6, i64 0, i64 0))
%10 = call i32 @exit(i32 -1)
unreachable
11: ; preds = %2
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.5, i64 0, i64 0))
ret i32 0
}