#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*/ strcpy(char *, char *);
void terminal_discard_first_line(char *string, unsigned int row_length) {
  unsigned int i;
  for (i = 0; string[i] && string[i] != '\n' && i < row_length - 1; i++)
    ;
  strcpy(string, string + i + 1);
}


x86 assembly (clang, -O0):
<terminal_discard_first_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x11(%rbp)
je     1169 <terminal_discard_first_line+0x59>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x11(%rbp)
je     1169 <terminal_discard_first_line+0x59>
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
setb   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1179 <terminal_discard_first_line+0x69>
jmp    118c <terminal_discard_first_line+0x7c>
jmp    117e <terminal_discard_first_line+0x6e>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <terminal_discard_first_line+0x16>
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%eax
add    %rax,%rsi
add    $0x1,%rsi
call   1030 <strcpy@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<terminal_discard_first_line>:
add    $0xffffffff,%esi
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nop
movzbl (%rdi,%rax,1),%ecx
test   %cl,%cl
je     1138 <terminal_discard_first_line+0x28>
cmp    $0xa,%cl
je     1138 <terminal_discard_first_line+0x28>
cmp    %rax,%rsi
je     113a <terminal_discard_first_line+0x2a>
add    $0x1,%rax
jmp    1120 <terminal_discard_first_line+0x10>
mov    %eax,%esi
mov    %esi,%eax
lea    (%rdi,%rax,1),%rsi
add    $0x1,%rsi
jmp    1030 <strcpy@plt>

LLVM IR (-O0):
define void @terminal_discard_first_line(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %30, %2
%7 = load i8*, i8** %3
%8 = load i32, i32* %5
%9 = zext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %7, i64 %9
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %27
14: ; preds = %6
%15 = load i8*, i8** %3
%16 = load i32, i32* %5
%17 = zext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 10
br i1 %21, label %22, label %27
22: ; preds = %14
%23 = load i32, i32* %5
%24 = load i32, i32* %4
%25 = sub i32 %24, 1
%26 = icmp ult i32 %23, %25
br label %27
27: ; preds = %22, %14, %6
%28 = phi i1 [ false, %14 ], [ false, %6 ], [ %26, %22 ]
br i1 %28, label %29, label %33
29: ; preds = %27
br label %30
30: ; preds = %29
%31 = load i32, i32* %5
%32 = add i32 %31, 1
store i32 %32, i32* %5
br label %6
33: ; preds = %27
%34 = load i8*, i8** %3
%35 = load i8*, i8** %3
%36 = load i32, i32* %5
%37 = zext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
%39 = getelementptr inbounds i8, i8* %38, i64 1
%40 = call i32 @strcpy(i8* %34, i8* %39)
ret void
}

LLVM IR (-O2):
define void @terminal_discard_first_line(i8* %0, i32 %1) {
%3 = add i32 %1, -1
%4 = zext i32 %3 to i64
br label %5
5: ; preds = %11, %2
%6 = phi i64 [ %12, %11 ], [ 0, %2 ]
%7 = getelementptr inbounds i8, i8* %0, i64 %6
%8 = load i8, i8* %7
switch i8 %8, label %9 [
i8 0, label %13
i8 10, label %13
]
9: ; preds = %5
%10 = icmp eq i64 %6, %4
br i1 %10, label %15, label %11
11: ; preds = %9
%12 = add nuw nsw i64 %6, 1
br label %5
13: ; preds = %5, %5
%14 = trunc i64 %6 to i32
br label %15
15: ; preds = %9, %13
%16 = phi i32 [ %14, %13 ], [ %3, %9 ]
%17 = zext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %0, i64 %17
%19 = getelementptr inbounds i8, i8* %18, i64 1
%20 = tail call i32 @strcpy(i8* %0, i8* %19)
ret void
}