#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
scalar_t__ isspace(char);
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
char *Read_Line(char *buff, int size, FILE *f_in) {
  char *p;
  do
    if (fgets(buff, size, f_in) == NULL)
      return NULL;
  while (strncmp(buff, "IGN", 3) == 0);
  for (p = buff + strlen(buff) - 1; isspace(*p); p--)
    ;
  p[1] = '\0';
  return buff;
}


x86 assembly (clang, -O0):
<Read_Line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
call   1060 <fgets@plt>
cmp    $0x0,%rax
jne    117a <Read_Line+0x3a>
movq   $0x0,-0x8(%rbp)
jmp    11ff <Read_Line+0xbf>
jmp    117f <Read_Line+0x3f>
mov    -0x10(%rbp),%rdi
lea    0xe76(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1153 <Read_Line+0x13>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%edi
call   1050 <isspace@plt>
cmp    $0x0,%rax
je     11ef <Read_Line+0xaf>
jmp    11de <Read_Line+0x9e>
mov    -0x28(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x28(%rbp)
jmp    11c3 <Read_Line+0x83>
mov    -0x28(%rbp),%rax
movb   $0x0,0x1(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Read_Line>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xeaa(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     11b8 <Read_Line+0x78>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1160 <Read_Line+0x20>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
lea    (%rax,%rbx,1),%rbp
add    $0x1,%rbp
nopl   0x0(%rax)
movsbl -0x2(%rbp),%edi
call   1050 <isspace@plt>
add    $0xffffffffffffffff,%rbp
test   %rax,%rax
jne    11a0 <Read_Line+0x60>
movb   $0x0,0x0(%rbp)
jmp    11ba <Read_Line+0x7a>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"IGN\00"
define i8* @Read_Line(i8* %0, i32 %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i8*
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32* %2, i32** %7
br label %9
9: ; preds = %17, %3
%10 = load i8*, i8** %5
%11 = load i32, i32* %6
%12 = load i32*, i32** %7
%13 = call i32* @fgets(i8* %10, i32 %11, i32* %12)
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %16
15: ; preds = %9
store i8* null, i8** %4
br label %41
16: ; preds = %9
br label %17
17: ; preds = %16
%18 = load i8*, i8** %5
%19 = call i64 @strncmp(i8* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%20 = icmp eq i64 %19, 0
br i1 %20, label %9, label %21
21: ; preds = %17
%22 = load i8*, i8** %5
%23 = load i8*, i8** %5
%24 = call i32 @strlen(i8* %23)
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %22, i64 %25
%27 = getelementptr inbounds i8, i8* %26, i64 -1
store i8* %27, i8** %8
br label %28
28: ; preds = %34, %21
%29 = load i8*, i8** %8
%30 = load i8, i8* %29
%31 = call i64 @isspace(i8 signext %30)
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %37
33: ; preds = %28
br label %34
34: ; preds = %33
%35 = load i8*, i8** %8
%36 = getelementptr inbounds i8, i8* %35, i32 -1
store i8* %36, i8** %8
br label %28
37: ; preds = %28
%38 = load i8*, i8** %8
%39 = getelementptr inbounds i8, i8* %38, i64 1
store i8 0, i8* %39
%40 = load i8*, i8** %5
store i8* %40, i8** %4
br label %41
41: ; preds = %37, %15
%42 = load i8*, i8** %4
ret i8* %42
}

LLVM IR (-O2):
@.str = [4 x i8] c"IGN\00"
define i8* @Read_Line(i8* %0, i32 %1, i32* nocapture %2) {
br label %4
4: ; preds = %7, %3
%5 = tail call i32* @fgets(i8* %0, i32 %1, i32* %2)
%6 = icmp eq i32* %5, null
br i1 %6, label %21, label %7
7: ; preds = %4
%8 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%9 = icmp eq i64 %8, 0
br i1 %9, label %4, label %10
10: ; preds = %7
%11 = tail call i32 @strlen(i8* %0)
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %0, i64 %12
br label %14
14: ; preds = %14, %10
%15 = phi i8* [ %13, %10 ], [ %16, %14 ]
%16 = getelementptr inbounds i8, i8* %15, i64 -1
%17 = load i8, i8* %16
%18 = tail call i64 @isspace(i8 signext %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %14
20: ; preds = %14
store i8 0, i8* %15
br label %21
21: ; preds = %4, %20
%22 = phi i8* [ %0, %20 ], [ null, %4 ]
ret i8* %22
}