#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);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ remove_eol(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int strlen(char *);
int test_remove_eol() {
  char str[20];
  int i;
  printf("test_remove_eol...");
  sprintf(str, "%s", "test string");
  str[11] = 13;
  str[12] = 0;
  remove_eol(str);
  assert(strlen(str) == 11);
  for (i = 0; i < strlen(str); i++) {
    assert(str[i] != 13);
  }
  printf("ok\n");
  return 1;
}


x86 assembly (clang, -O0):
<test_remove_eol>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xea1(%rip),%rdi
call   1040 <printf@plt>
lea    -0x20(%rbp),%rdi
lea    0xea4(%rip),%rsi
lea    0xea0(%rip),%rdx
call   1070 <sprintf@plt>
movb   $0xd,-0x15(%rbp)
movb   $0x0,-0x14(%rbp)
lea    -0x20(%rbp),%rdi
call   1060 <remove_eol@plt>
lea    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0xb,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
lea    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
cmp    %ecx,%eax
jge    11ef <test_remove_eol+0x9f>
movslq -0x24(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%eax
cmp    $0xd,%eax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11ac <test_remove_eol+0x5c>
lea    0xe2c(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_remove_eol>:
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xea2(%rip),%rdi
call   1050 <printf@plt>
movabs $0x7274732074736574,%rax
73 74 72
mov    %rax,(%rsp)
movl   $0x676e69,0x8(%rsp)
movb   $0xd,0xb(%rsp)
movb   $0x0,0xc(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1070 <remove_eol@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
xor    %edi,%edi
cmp    $0xb,%eax
sete   %dil
call   1060 <assert@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    11e2 <test_remove_eol+0x92>
xor    %ebx,%ebx
mov    %rsp,%r14
cs nopw 0x0(%rax,%rax,1)
nop
xor    %edi,%edi
cmpb   $0xd,(%rsp,%rbx,1)
setne  %dil
call   1060 <assert@plt>
add    $0x1,%rbx
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     11c0 <test_remove_eol+0x70>
lea    0xe36(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [19 x i8] c"test_remove_eol...\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [12 x i8] c"test string\00"
@.str.3 = [4 x i8] c"ok\0A\00"
define i32 @test_remove_eol() {
%1 = alloca [20 x i8]
%2 = alloca i32
%3 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%5 = call i32 @sprintf(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%6 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 11
store i8 13, i8* %6
%7 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 12
store i8 0, i8* %7
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%9 = call i32 @remove_eol(i8* %8)
%10 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%11 = call i32 @strlen(i8* %10)
%12 = icmp eq i32 %11, 11
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
store i32 0, i32* %2
br label %15
15: ; preds = %29, %0
%16 = load i32, i32* %2
%17 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%18 = call i32 @strlen(i8* %17)
%19 = icmp slt i32 %16, %18
br i1 %19, label %20, label %32
20: ; preds = %15
%21 = load i32, i32* %2
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %25, 13
%27 = zext i1 %26 to i32
%28 = call i32 @assert(i32 %27)
br label %29
29: ; preds = %20
%30 = load i32, i32* %2
%31 = add nsw i32 %30, 1
store i32 %31, i32* %2
br label %15
32: ; preds = %15
%33 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
ret i32 1
}

LLVM IR (-O2):
@.str = [19 x i8] c"test_remove_eol...\00"
@.str.2 = [12 x i8] c"test string\00"
@str = [3 x i8] c"ok\00"
define i32 @test_remove_eol() {
%1 = alloca [20 x i8]
%2 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 11
store i8 13, i8* %4
%5 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 12
store i8 0, i8* %5
%6 = call i32 @remove_eol(i8* %2)
%7 = call i32 @strlen(i8* %2)
%8 = icmp eq i32 %7, 11
%9 = zext i1 %8 to i32
%10 = call i32 @assert(i32 %9)
%11 = call i32 @strlen(i8* %2)
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %24
13: ; preds = %0, %13
%14 = phi i64 [ %20, %13 ], [ 0, %0 ]
%15 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 %14
%16 = load i8, i8* %15
%17 = icmp ne i8 %16, 13
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
%20 = add nuw nsw i64 %14, 1
%21 = call i32 @strlen(i8* %2)
%22 = sext i32 %21 to i64
%23 = icmp slt i64 %20, %22
br i1 %23, label %13, label %24
24: ; preds = %13, %0
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
ret i32 1
}