#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*/ printf(char *, char *);
int /*<<< orphan*/ trim_end_lf(char *);
int main(void) {
  char str[] = "ABCDE\n";
  printf("str = [%s]\n", str);
  trim_end_lf(str);
  printf("str = [%s]\n", str);
  trim_end_lf(str);
  printf("str = [%s]\n", str);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xecb(%rip),%eax
mov    %eax,-0xb(%rbp)
mov    0xec5(%rip),%ax
mov    %ax,-0x7(%rbp)
mov    0xebd(%rip),%al
mov    %al,-0x5(%rbp)
lea    -0xb(%rbp),%rsi
lea    0xeb0(%rip),%rdi
call   1040 <printf@plt>
lea    -0xb(%rbp),%rdi
call   1030 <trim_end_lf@plt>
lea    -0xb(%rbp),%rsi
lea    0xe97(%rip),%rdi
call   1040 <printf@plt>
lea    -0xb(%rbp),%rdi
call   1030 <trim_end_lf@plt>
lea    -0xb(%rbp),%rsi
lea    0xe7e(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
movl   $0xa4544,0x3(%rsp)
movl   $0x44434241,(%rsp)
lea    0xecd(%rip),%r14
mov    %rsp,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <trim_end_lf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <trim_end_lf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.str = [7 x i8] c"ABCDE\0A\00"
@.str = [12 x i8] c"str = [%s]\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [7 x i8]
store i32 0, i32* %1
%3 = bitcast [7 x i8]* %2 to i8*
%4 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 0
%5 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 0
%7 = call i32 @trim_end_lf(i8* %6)
%8 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 0
%9 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 0
%11 = call i32 @trim_end_lf(i8* %10)
%12 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 0
%13 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %12)
ret i32 0
}

LLVM IR (-O2):
@__const.main.str = [7 x i8] c"ABCDE\0A\00"
@.str = [12 x i8] c"str = [%s]\0A\00"
define i32 @main() {
%1 = alloca [7 x i8]
%2 = getelementptr inbounds [7 x i8], [7 x i8]* %1, i64 0, i64 0
%3 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %2)
%4 = call i32 @trim_end_lf(i8* %2)
%5 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %2)
%6 = call i32 @trim_end_lf(i8* %2)
%7 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %2)
ret i32 0
}