#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 */
struct file_buffer {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ buffer_destroy(struct file_buffer *);
char *buffer_gets(struct file_buffer *);
int /*<<< orphan*/ printf(char *, char *);
struct file_buffer *read_open_buffer(char *);
int main(int argc, char *argv[]) {
  struct file_buffer *buffer;
  char *line;
  char c;
  buffer = read_open_buffer(argv[1]);
  while ((line = buffer_gets(buffer))) {
    printf("LINE->%s<-", line);
  }
  buffer_destroy(buffer);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <read_open_buffer@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <buffer_gets@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     1193 <main+0x53>
mov    -0x20(%rbp),%rsi
lea    0xe77(%rip),%rdi
call   1030 <printf@plt>
jmp    1167 <main+0x27>
mov    -0x18(%rbp),%rdi
call   1060 <buffer_destroy@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    0x8(%rsi),%rdi
call   1040 <read_open_buffer@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <buffer_gets@plt>
test   %rax,%rax
je     1188 <main+0x48>
lea    0xe9c(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1050 <buffer_gets@plt>
test   %rax,%rax
jne    1170 <main+0x30>
mov    %rbx,%rdi
call   1060 <buffer_destroy@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.file_buffer = type { i32 }
@.str = [11 x i8] c"LINE->%s<-\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.file_buffer*
%7 = alloca i8*
%8 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = call %struct.file_buffer* @read_open_buffer(i8* %11)
store %struct.file_buffer* %12, %struct.file_buffer** %6
br label %13
13: ; preds = %17, %2
%14 = load %struct.file_buffer*, %struct.file_buffer** %6
%15 = call i8* @buffer_gets(%struct.file_buffer* %14)
store i8* %15, i8** %7
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %20
17: ; preds = %13
%18 = load i8*, i8** %7
%19 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %18)
br label %13
20: ; preds = %13
%21 = load %struct.file_buffer*, %struct.file_buffer** %6
%22 = call i32 @buffer_destroy(%struct.file_buffer* %21)
ret i32 0
}

LLVM IR (-O2):
%struct.file_buffer = type { i32 }
@.str = [11 x i8] c"LINE->%s<-\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call %struct.file_buffer* @read_open_buffer(i8* %4)
%6 = tail call i8* @buffer_gets(%struct.file_buffer* %5)
%7 = icmp eq i8* %6, null
br i1 %7, label %13, label %8
8: ; preds = %2, %8
%9 = phi i8* [ %11, %8 ], [ %6, %2 ]
%10 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = tail call i8* @buffer_gets(%struct.file_buffer* %5)
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %8
13: ; preds = %8, %2
%14 = tail call i32 @buffer_destroy(%struct.file_buffer* %5)
ret i32 0
}