#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 BUFSIZ;
int /*<<< orphan*/ bzero(char *, int);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
scalar_t__ isspace(int);
scalar_t__ strdup(char *);
char *get_next_line(FILE *file) {
  char buf[BUFSIZ];
  char *index;
  bzero((char *)buf, BUFSIZ);
  while (fgets(buf, BUFSIZ, file)) {
    index = buf;
    while (isspace((int)*index))
      ++index;
    return ((char *)strdup(index));
  }
  return (NULL);
}


x86 assembly (clang, -O0):
<get_next_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    0x2e8d(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x38(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x20(%rbp)
mov    0x2e61(%rip),%rax
mov    (%rax),%esi
call   1050 <bzero@plt>
mov    -0x38(%rbp),%rdi
mov    0x2e4f(%rip),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rdx
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     11ee <get_next_line+0xae>
mov    -0x38(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isspace@plt>
cmp    $0x0,%rax
je     11d5 <get_next_line+0x95>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    11ae <get_next_line+0x6e>
mov    -0x28(%rbp),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x8(%rbp)
movl   $0x1,-0x2c(%rbp)
jmp    11fd <get_next_line+0xbd>
movq   $0x0,-0x8(%rbp)
movl   $0x1,-0x2c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x8(%rbp),%rax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_next_line>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    0x2e8c(%rip),%rax
mov    (%rax),%r15d
mov    %rsp,%rbx
mov    %r15,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rbx,%rdi
mov    %r15d,%esi
call   1050 <bzero@plt>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %r14,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     11ac <get_next_line+0x6c>
add    $0xffffffffffffffff,%rbx
nopl   (%rax)
movsbl 0x1(%rbx),%edi
add    $0x1,%rbx
call   1030 <isspace@plt>
test   %rax,%rax
jne    1190 <get_next_line+0x50>
mov    %rbx,%rdi
call   1060 <strdup@plt>
jmp    11ae <get_next_line+0x6e>
xor    %eax,%eax
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@BUFSIZ = global i32 0
define i8* @get_next_line(i32* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i32
store i32* %0, i32** %3
%8 = load i32, i32* @BUFSIZ
%9 = zext i32 %8 to i64
%10 = call i8* @llvm.stacksave()
store i8* %10, i8** %4
%11 = alloca i8, i64 %9
store i64 %9, i64* %5
%12 = load i32, i32* @BUFSIZ
%13 = call i32 @bzero(i8* %11, i32 %12)
br label %14
14: ; preds = %1
%15 = load i32, i32* @BUFSIZ
%16 = load i32*, i32** %3
%17 = call i64 @fgets(i8* %11, i32 %15, i32* %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %33
19: ; preds = %14
store i8* %11, i8** %6
br label %20
20: ; preds = %26, %19
%21 = load i8*, i8** %6
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = call i64 @isspace(i32 %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %20
%27 = load i8*, i8** %6
%28 = getelementptr inbounds i8, i8* %27, i32 1
store i8* %28, i8** %6
br label %20
29: ; preds = %20
%30 = load i8*, i8** %6
%31 = call i64 @strdup(i8* %30)
%32 = inttoptr i64 %31 to i8*
store i8* %32, i8** %2
store i32 1, i32* %7
br label %34
33: ; preds = %14
store i8* null, i8** %2
store i32 1, i32* %7
br label %34
34: ; preds = %33, %29
%35 = load i8*, i8** %4
%36 = load i8*, i8** %2
ret i8* %36
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
define i8* @get_next_line(i32* nocapture %0) {
%2 = load i32, i32* @BUFSIZ
%3 = zext i32 %2 to i64
%4 = alloca i8, i64 %3
%5 = call i32 @bzero(i8* %4, i32 %2)
%6 = call i64 @fgets(i8* %4, i32 %2, i32* %0)
%7 = icmp eq i64 %6, 0
br i1 %7, label %18, label %8
8: ; preds = %1, %8
%9 = phi i8* [ %14, %8 ], [ %4, %1 ]
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = call i64 @isspace(i32 %11)
%13 = icmp eq i64 %12, 0
%14 = getelementptr inbounds i8, i8* %9, i64 1
br i1 %13, label %15, label %8
15: ; preds = %8
%16 = call i64 @strdup(i8* %9)
%17 = inttoptr i64 %16 to i8*
br label %18
18: ; preds = %1, %15
%19 = phi i8* [ %17, %15 ], [ null, %1 ]
ret i8* %19
}