#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 getline(char **, size_t *, int /*<<< orphan*/ *);
int /*<<< orphan*/ is_empty(char *, int);
int read_line(char **line, size_t *size, FILE *fp) {
  int ret = 0;
  while (1) {
    ret = getline(line, size, fp);
    if (ret == -1) {
      ret = 0;
      break;
    }
    if (!is_empty(*line, ret)) {
      continue;
    } else {
      break;
    }
  }
  return ret;
}


x86 assembly (clang, -O0):
<read_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <getline@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    1165 <read_line+0x45>
movl   $0x0,-0x1c(%rbp)
jmp    1187 <read_line+0x67>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x1c(%rbp),%esi
call   1030 <is_empty@plt>
cmp    $0x0,%eax
jne    1182 <read_line+0x62>
jmp    113b <read_line+0x1b>
jmp    1187 <read_line+0x67>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_line>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1040 <getline@plt>
cmp    $0xffffffff,%eax
je     1155 <read_line+0x35>
mov    %eax,%ebp
mov    (%rbx),%rdi
mov    %eax,%esi
call   1030 <is_empty@plt>
test   %eax,%eax
je     1130 <read_line+0x10>
jmp    1157 <read_line+0x37>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @read_line(i8** %0, i64* %1, i32* %2) {
%4 = alloca i8**
%5 = alloca i64*
%6 = alloca i32*
%7 = alloca i32
store i8** %0, i8*** %4
store i64* %1, i64** %5
store i32* %2, i32** %6
store i32 0, i32* %7
br label %8
8: ; preds = %3, %22
%9 = load i8**, i8*** %4
%10 = load i64*, i64** %5
%11 = load i32*, i32** %6
%12 = call i32 @getline(i8** %9, i64* %10, i32* %11)
store i32 %12, i32* %7
%13 = load i32, i32* %7
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %16
15: ; preds = %8
store i32 0, i32* %7
br label %24
16: ; preds = %8
%17 = load i8**, i8*** %4
%18 = load i8*, i8** %17
%19 = load i32, i32* %7
%20 = call i32 @is_empty(i8* %18, i32 %19)
%21 = icmp ne i32 %20, 0
br i1 %21, label %23, label %22
22: ; preds = %16
br label %8
23: ; preds = %16
br label %24
24: ; preds = %23, %15
%25 = load i32, i32* %7
ret i32 %25
}

LLVM IR (-O2):
define i32 @read_line(i8** %0, i64* %1, i32* %2) {
br label %4
4: ; preds = %7, %3
%5 = tail call i32 @getline(i8** %0, i64* %1, i32* %2)
%6 = icmp eq i32 %5, -1
br i1 %6, label %11, label %7
7: ; preds = %4
%8 = load i8*, i8** %0
%9 = tail call i32 @is_empty(i8* %8, i32 %5)
%10 = icmp eq i32 %9, 0
br i1 %10, label %4, label %11
11: ; preds = %4, %7
%12 = phi i32 [ %5, %7 ], [ 0, %4 ]
ret i32 %12
}