#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 */
char *fgets(char *, int, int /*<<< orphan*/ *);
char *strchr(char *, char);
int strlen(char *);
int strspn(char *, char *);
char *get_a_line(char *where, int len, FILE *ffptr) {
  char *retrn, *c;
  int j;
  while ((retrn = fgets(where, (len - 1), ffptr)) != NULL) {
    where[(len - 1)] = 0;
    if ((c = strchr(where, '\n')) != NULL)
      *c = 0;
    if ((c = strchr(where, ';')) != NULL)
      *c = 0;
    if ((j = strspn(where, " \t")) == strlen(where))
      continue;
    if (strlen(where))
      return (retrn);
  }
  return (retrn);
}


x86 assembly (clang, -O0):
<get_a_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
sub    $0x1,%esi
mov    -0x20(%rbp),%rdx
call   1060 <fgets@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     1220 <get_a_line+0xe0>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rdi
mov    $0xa,%esi
call   1040 <strchr@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     11a8 <get_a_line+0x68>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
mov    $0x3b,%esi
call   1040 <strchr@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     11cb <get_a_line+0x8b>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
lea    0xe2a(%rip),%rsi
call   1050 <strspn@plt>
mov    %eax,-0x38(%rbp)
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%eax
cmp    %ecx,%eax
jne    11fc <get_a_line+0xbc>
jmp    1153 <get_a_line+0x13>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%eax
je     121b <get_a_line+0xdb>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1228 <get_a_line+0xe8>
jmp    1153 <get_a_line+0x13>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_a_line>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rdi,%rbx
movslq %esi,%r15
add    $0xffffffffffffffff,%r15
mov    %r15d,%esi
call   1060 <fgets@plt>
test   %rax,%rax
je     11ec <get_a_line+0xac>
mov    %rax,%r12
lea    0xe8d(%rip),%r13
jmp    1196 <get_a_line+0x56>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
mov    %rax,%r12
test   %rax,%rax
je     11ec <get_a_line+0xac>
movb   $0x0,(%rbx,%r15,1)
mov    %rbx,%rdi
mov    $0xa,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     11b0 <get_a_line+0x70>
movb   $0x0,(%rax)
mov    %rbx,%rdi
mov    $0x3b,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     11c5 <get_a_line+0x85>
movb   $0x0,(%rax)
mov    %rbx,%rdi
mov    %r13,%rsi
call   1050 <strspn@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    %eax,%ebp
je     1180 <get_a_line+0x40>
mov    %rbx,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
je     1180 <get_a_line+0x40>
jmp    11ef <get_a_line+0xaf>
xor    %r12d,%r12d
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c" \09\00"
define i8* @get_a_line(i8* %0, i32 %1, i32* nocapture %2) {
%4 = add nsw i32 %1, -1
%5 = tail call i8* @fgets(i8* %0, i32 %4, i32* %2)
%6 = icmp eq i8* %5, null
br i1 %6, label %29, label %7
7: ; preds = %3
%8 = sext i32 %4 to i64
%9 = getelementptr inbounds i8, i8* %0, i64 %8
br label %10
10: ; preds = %7, %23
%11 = phi i8* [ %5, %7 ], [ %24, %23 ]
store i8 0, i8* %9
%12 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 10)
%13 = icmp eq i8* %12, null
br i1 %13, label %15, label %14
14: ; preds = %10
store i8 0, i8* %12
br label %15
15: ; preds = %14, %10
%16 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 59)
%17 = icmp eq i8* %16, null
br i1 %17, label %19, label %18
18: ; preds = %15
store i8 0, i8* %16
br label %19
19: ; preds = %18, %15
%20 = tail call i32 @strspn(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%21 = tail call i32 @strlen(i8* %0)
%22 = icmp eq i32 %20, %21
br i1 %22, label %23, label %26
23: ; preds = %19, %26
%24 = tail call i8* @fgets(i8* %0, i32 %4, i32* %2)
%25 = icmp eq i8* %24, null
br i1 %25, label %29, label %10
26: ; preds = %19
%27 = tail call i32 @strlen(i8* %0)
%28 = icmp eq i32 %27, 0
br i1 %28, label %23, label %29
29: ; preds = %26, %23, %3
%30 = phi i8* [ null, %3 ], [ null, %23 ], [ %11, %26 ]
ret i8* %30
}