#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*/ *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int get_line(FILE *fl, char *buf) {
  char temp[256];
  int lines = 0;
  int sl;
  do {
    if (!fgets(temp, 256, fl))
      return (0);
    lines++;
  } while (*temp == '*' || *temp == '\n' || *temp == '\r');
  sl = strlen(temp);
  while (sl > 0 && (temp[sl - 1] == '\n' || temp[sl - 1] == '\r'))
    temp[--sl] = '\0';
  strcpy(buf, temp);
  return (lines);
}


x86 assembly (clang, -O0):
<get_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x124(%rbp)
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x100,%esi
call   1050 <fgets@plt>
cmp    $0x0,%eax
jne    1177 <get_line+0x47>
movl   $0x0,-0x4(%rbp)
jmp    1297 <get_line+0x167>
mov    -0x124(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x124(%rbp)
movsbl -0x120(%rbp),%ecx
mov    $0x1,%al
cmp    $0x2a,%ecx
mov    %al,-0x129(%rbp)
je     11c9 <get_line+0x99>
movsbl -0x120(%rbp),%ecx
mov    $0x1,%al
cmp    $0xa,%ecx
mov    %al,-0x129(%rbp)
je     11c9 <get_line+0x99>
movsbl -0x120(%rbp),%eax
cmp    $0xd,%eax
sete   %al
mov    %al,-0x129(%rbp)
mov    -0x129(%rbp),%al
test   $0x1,%al
jne    114d <get_line+0x1d>
lea    -0x120(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x128(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x128(%rbp)
mov    %al,-0x12a(%rbp)
jle    124d <get_line+0x11d>
mov    -0x128(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x120(%rbp,%rax,1),%ecx
ff
mov    $0x1,%al
cmp    $0xa,%ecx
mov    %al,-0x12b(%rbp)
je     1241 <get_line+0x111>
mov    -0x128(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x120(%rbp,%rax,1),%eax
ff
cmp    $0xd,%eax
sete   %al
mov    %al,-0x12b(%rbp)
mov    -0x12b(%rbp),%al
mov    %al,-0x12a(%rbp)
mov    -0x12a(%rbp),%al
test   $0x1,%al
jne    1260 <get_line+0x130>
jmp    127e <get_line+0x14e>
mov    -0x128(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x128(%rbp)
cltq
movb   $0x0,-0x120(%rbp,%rax,1)
jmp    11e9 <get_line+0xb9>
mov    -0x18(%rbp),%rdi
lea    -0x120(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x124(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_line>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x100,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsp,%rdi
mov    $0x100,%esi
mov    %rbx,%rdx
call   1050 <fgets@plt>
test   %eax,%eax
je     1197 <get_line+0x67>
mov    $0x1,%ebp
movabs $0x40000002400,%r12
mov    %rsp,%r15
nopl   0x0(%rax,%rax,1)
movzbl (%rsp),%eax
cmp    $0x2a,%rax
ja     11ab <get_line+0x7b>
bt     %rax,%r12
jae    11ab <get_line+0x7b>
mov    %r15,%rdi
mov    $0x100,%esi
mov    %rbx,%rdx
call   1050 <fgets@plt>
add    $0x1,%ebp
test   %eax,%eax
jne    1170 <get_line+0x40>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x100,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rsp,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    11df <get_line+0xaf>
mov    %eax,%eax
add    $0x1,%rax
jmp    11ce <get_line+0x9e>
nop
movb   $0x0,(%rsp,%rcx,1)
add    $0xffffffffffffffff,%rax
cmp    $0x1,%rax
jbe    11df <get_line+0xaf>
lea    -0x2(%rax),%ecx
movzbl (%rsp,%rcx,1),%edx
cmp    $0xd,%dl
je     11c0 <get_line+0x90>
cmp    $0xa,%dl
je     11c0 <get_line+0x90>
mov    %rsp,%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
jmp    1199 <get_line+0x69>

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

LLVM IR (-O2):
define i32 @get_line(i32* nocapture %0, i8* %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = call i32 @fgets(i8* %4, i32 256, i32* %0)
%6 = icmp eq i32 %5, 0
br i1 %6, label %29, label %7
7: ; preds = %2, %11
%8 = phi i32 [ %9, %11 ], [ 0, %2 ]
%9 = add nuw nsw i32 %8, 1
%10 = load i8, i8* %4
switch i8 %10, label %14 [
i8 42, label %11
i8 13, label %11
i8 10, label %11
]
11: ; preds = %7, %7, %7
%12 = call i32 @fgets(i8* %4, i32 256, i32* %0)
%13 = icmp eq i32 %12, 0
br i1 %13, label %29, label %7
14: ; preds = %7
%15 = call i32 @strlen(i8* %4)
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %27
17: ; preds = %14
%18 = zext i32 %15 to i64
br label %19
19: ; preds = %17, %25
%20 = phi i64 [ %18, %17 ], [ %21, %25 ]
%21 = add nsw i64 %20, -1
%22 = and i64 %21, 4294967295
%23 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %22
%24 = load i8, i8* %23
switch i8 %24, label %27 [
i8 10, label %25
i8 13, label %25
]
25: ; preds = %19, %19
store i8 0, i8* %23
%26 = icmp ugt i64 %20, 1
br i1 %26, label %19, label %27
27: ; preds = %25, %19, %14
%28 = call i32 @strcpy(i8* %1, i8* %4)
br label %29
29: ; preds = %11, %2, %27
%30 = phi i32 [ %9, %27 ], [ 0, %2 ], [ 0, %11 ]
ret i32 %30
}