#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*/ assert(int);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ truncate_nl(char *);
void test_truncate_nl(void) {
  char s[] = "hello libsystem"
             "\n\r";
  assert(!(strcmp((s), ("hello libsystem")) == 0));
  truncate_nl(s);
  assert((strcmp((s), ("hello libsystem")) == 0));
}


x86 assembly (clang, -O0):
<test_truncate_nl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xec1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xebe(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xebb(%rip),%ax
mov    %ax,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
lea    0xeae(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    -0x20(%rbp),%rdi
call   1050 <truncate_nl@plt>
lea    -0x20(%rbp),%rdi
lea    0xe82(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_truncate_nl>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movaps 0xec2(%rip),%xmm0
movaps %xmm0,(%rsp)
movw   $0xd,0x10(%rsp)
lea    0xec2(%rip),%r14
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1040 <assert@plt>
mov    %rbx,%rdi
call   1050 <truncate_nl@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1040 <assert@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.test_truncate_nl.s = [18 x i8] c"hello libsystem\0A\0D\00"
@.str = [16 x i8] c"hello libsystem\00"
define void @test_truncate_nl() {
%1 = alloca [18 x i8]
%2 = bitcast [18 x i8]* %1 to i8*
%3 = getelementptr inbounds [18 x i8], [18 x i8]* %1, i64 0, i64 0
%4 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
%6 = xor i1 %5, true
%7 = zext i1 %6 to i32
%8 = call i32 @assert(i32 %7)
%9 = getelementptr inbounds [18 x i8], [18 x i8]* %1, i64 0, i64 0
%10 = call i32 @truncate_nl(i8* %9)
%11 = getelementptr inbounds [18 x i8], [18 x i8]* %1, i64 0, i64 0
%12 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
ret void
}

LLVM IR (-O2):
@__const.test_truncate_nl.s = [18 x i8] c"hello libsystem\0A\0D\00"
@.str = [16 x i8] c"hello libsystem\00"
define void @test_truncate_nl() {
%1 = alloca [18 x i8]
%2 = getelementptr inbounds [18 x i8], [18 x i8]* %1, i64 0, i64 0
%3 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%4 = icmp ne i64 %3, 0
%5 = zext i1 %4 to i32
%6 = call i32 @assert(i32 %5)
%7 = call i32 @truncate_nl(i8* %2)
%8 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
ret void
}