#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*/ deleteRepeatChars(char *, char);
void deleteTrailingCharFromLines(char s[], int c) {
  for (int i = 0; (i < 1000) && (s[i] != '\0'); i++) {
    if (s[i] == '\n' && s[i - 1 == c]) {
      for (int j = i - 1; j > 0 && (s[j] == c); j--) {
        s[j] = '\n';
      }
      deleteRepeatChars(s, '\n');
    }
  }
}


x86 assembly (clang, -O0):
<deleteTrailingCharFromLines>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
xor    %eax,%eax
cmpl   $0x3e8,-0x10(%rbp)
mov    %al,-0x15(%rbp)
jge    114d <deleteTrailingCharFromLines+0x3d>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    115d <deleteTrailingCharFromLines+0x4d>
jmp    1210 <deleteTrailingCharFromLines+0x100>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    11fd <deleteTrailingCharFromLines+0xed>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
cmp    -0xc(%rbp),%ecx
sete   %cl
and    $0x1,%cl
movzbl %cl,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11fd <deleteTrailingCharFromLines+0xed>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x14(%rbp)
mov    %al,-0x16(%rbp)
jle    11c5 <deleteTrailingCharFromLines+0xb5>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    -0xc(%rbp),%eax
sete   %al
mov    %al,-0x16(%rbp)
mov    -0x16(%rbp),%al
test   $0x1,%al
jne    11d5 <deleteTrailingCharFromLines+0xc5>
jmp    11ef <deleteTrailingCharFromLines+0xdf>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0xa,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    11a1 <deleteTrailingCharFromLines+0x91>
mov    -0x8(%rbp),%rdi
mov    $0xa,%esi
call   1030 <deleteRepeatChars@plt>
jmp    1202 <deleteTrailingCharFromLines+0xf2>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <deleteTrailingCharFromLines+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<deleteTrailingCharFromLines>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r15d
mov    %rdi,%rbx
movslq %esi,%r14
xor    %ebp,%ebp
jmp    1141 <deleteTrailingCharFromLines+0x31>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
test   %al,%al
je     1194 <deleteTrailingCharFromLines+0x84>
add    $0x1,%rbp
cmp    $0x3e8,%rbp
je     1194 <deleteTrailingCharFromLines+0x84>
mov    (%rbx,%rbp,1),%al
cmp    $0xa,%al
jne    1130 <deleteTrailingCharFromLines+0x20>
lea    -0x1(%rbp),%rax
xor    %ecx,%ecx
cmp    %r14,%rax
sete   %cl
cmpb   $0x0,(%rbx,%rcx,1)
je     1134 <deleteTrailingCharFromLines+0x24>
cmp    $0x2,%rbp
jb     1185 <deleteTrailingCharFromLines+0x75>
mov    %ebp,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0xffffffff,%eax
movsbl (%rbx,%rax,1),%ecx
cmp    %r15d,%ecx
jne    1185 <deleteTrailingCharFromLines+0x75>
movb   $0xa,(%rbx,%rax,1)
cmp    $0x1,%eax
jg     1170 <deleteTrailingCharFromLines+0x60>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1030 <deleteRepeatChars@plt>
jmp    1134 <deleteTrailingCharFromLines+0x24>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @deleteTrailingCharFromLines(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %7
7: ; preds = %69, %2
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 1000
br i1 %9, label %10, label %18
10: ; preds = %7
%11 = load i8*, i8** %3
%12 = load i32, i32* %5
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %11, i64 %13
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 0
br label %18
18: ; preds = %10, %7
%19 = phi i1 [ false, %7 ], [ %17, %10 ]
br i1 %19, label %20, label %72
20: ; preds = %18
%21 = load i8*, i8** %3
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 10
br i1 %27, label %28, label %68
28: ; preds = %20
%29 = load i8*, i8** %3
%30 = load i32, i32* %5
%31 = sub nsw i32 %30, 1
%32 = load i32, i32* %4
%33 = icmp eq i32 %31, %32
%34 = zext i1 %33 to i32
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %29, i64 %35
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %68
40: ; preds = %28
%41 = load i32, i32* %5
%42 = sub nsw i32 %41, 1
store i32 %42, i32* %6
br label %43
43: ; preds = %62, %40
%44 = load i32, i32* %6
%45 = icmp sgt i32 %44, 0
br i1 %45, label %46, label %55
46: ; preds = %43
%47 = load i8*, i8** %3
%48 = load i32, i32* %6
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8, i8* %47, i64 %49
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = load i32, i32* %4
%54 = icmp eq i32 %52, %53
br label %55
55: ; preds = %46, %43
%56 = phi i1 [ false, %43 ], [ %54, %46 ]
br i1 %56, label %57, label %65
57: ; preds = %55
%58 = load i8*, i8** %3
%59 = load i32, i32* %6
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i8, i8* %58, i64 %60
store i8 10, i8* %61
br label %62
62: ; preds = %57
%63 = load i32, i32* %6
%64 = add nsw i32 %63, -1
store i32 %64, i32* %6
br label %43
65: ; preds = %55
%66 = load i8*, i8** %3
%67 = call i32 @deleteRepeatChars(i8* %66, i8 signext 10)
br label %68
68: ; preds = %65, %28, %20
br label %69
69: ; preds = %68
%70 = load i32, i32* %5
%71 = add nsw i32 %70, 1
store i32 %71, i32* %5
br label %7
72: ; preds = %18
ret void
}

LLVM IR (-O2):
define void @deleteTrailingCharFromLines(i8* %0, i32 %1) {
%3 = sext i32 %1 to i64
br label %4
4: ; preds = %2, %32
%5 = phi i64 [ 0, %2 ], [ %33, %32 ]
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = load i8, i8* %6
switch i8 %7, label %32 [
i8 0, label %8
i8 10, label %9
]
8: ; preds = %4, %32
ret void
9: ; preds = %4
%10 = add nsw i64 %5, -1
%11 = icmp eq i64 %10, %3
%12 = zext i1 %11 to i64
%13 = getelementptr inbounds i8, i8* %0, i64 %12
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 0
br i1 %15, label %32, label %16
16: ; preds = %9
%17 = icmp ugt i64 %5, 1
br i1 %17, label %18, label %27
18: ; preds = %16
%19 = trunc i64 %10 to i32
br label %20
20: ; preds = %18, %29
%21 = phi i32 [ %30, %29 ], [ %19, %18 ]
%22 = zext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %0, i64 %22
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, %1
br i1 %26, label %29, label %27
27: ; preds = %20, %29, %16
%28 = tail call i32 @deleteRepeatChars(i8* %0, i8 signext 10)
br label %32
29: ; preds = %20
store i8 10, i8* %23
%30 = add nsw i32 %21, -1
%31 = icmp sgt i32 %21, 1
br i1 %31, label %20, label %27
32: ; preds = %4, %9, %27
%33 = add nuw nsw i64 %5, 1
%34 = icmp eq i64 %33, 1000
br i1 %34, label %8, label %4
}