#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 CLString {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ CLString_appendCharacter(struct CLString *, int);
int EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int getc(int /*<<< orphan*/ *);
void CLString_readFilePointer(struct CLString *self, FILE *thePointer) {
  int character = getc(thePointer);
  while (character != EOF) {
    CLString_appendCharacter(self, character);
    character = getc(thePointer);
  }
  fclose(thePointer);
}


x86 assembly (clang, -O0):
<CLString_readFilePointer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <getc@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e92(%rip),%rcx
cmp    (%rcx),%eax
je     117b <CLString_readFilePointer+0x4b>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <CLString_appendCharacter@plt>
mov    -0x10(%rbp),%rdi
call   1050 <getc@plt>
mov    %eax,-0x14(%rbp)
jmp    114c <CLString_readFilePointer+0x1c>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CLString_readFilePointer>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1050 <getc@plt>
mov    0x2e9e(%rip),%r15
cmp    (%r15),%eax
je     1167 <CLString_readFilePointer+0x37>
nop
mov    %r14,%rdi
mov    %eax,%esi
call   1040 <CLString_appendCharacter@plt>
mov    %rbx,%rdi
call   1050 <getc@plt>
cmp    (%r15),%eax
jne    1150 <CLString_readFilePointer+0x20>
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <fclose@plt>

LLVM IR (-O0):
%struct.CLString = type { i32 }
@EOF = global i32 0
define void @CLString_readFilePointer(%struct.CLString* %0, i32* %1) {
%3 = alloca %struct.CLString*
%4 = alloca i32*
%5 = alloca i32
store %struct.CLString* %0, %struct.CLString** %3
store i32* %1, i32** %4
%6 = load i32*, i32** %4
%7 = call i32 @getc(i32* %6)
store i32 %7, i32* %5
br label %8
8: ; preds = %12, %2
%9 = load i32, i32* %5
%10 = load i32, i32* @EOF
%11 = icmp ne i32 %9, %10
br i1 %11, label %12, label %18
12: ; preds = %8
%13 = load %struct.CLString*, %struct.CLString** %3
%14 = load i32, i32* %5
%15 = call i32 @CLString_appendCharacter(%struct.CLString* %13, i32 %14)
%16 = load i32*, i32** %4
%17 = call i32 @getc(i32* %16)
store i32 %17, i32* %5
br label %8
18: ; preds = %8
%19 = load i32*, i32** %4
%20 = call i32 @fclose(i32* %19)
ret void
}

LLVM IR (-O2):
%struct.CLString = type { i32 }
@EOF = global i32 0
define void @CLString_readFilePointer(%struct.CLString* %0, i32* nocapture %1) {
%3 = tail call i32 @getc(i32* %1)
%4 = load i32, i32* @EOF
%5 = icmp eq i32 %3, %4
br i1 %5, label %12, label %6
6: ; preds = %2, %6
%7 = phi i32 [ %9, %6 ], [ %3, %2 ]
%8 = tail call i32 @CLString_appendCharacter(%struct.CLString* %0, i32 %7)
%9 = tail call i32 @getc(i32* %1)
%10 = load i32, i32* @EOF
%11 = icmp eq i32 %9, %10
br i1 %11, label %12, label %6
12: ; preds = %6, %2
%13 = tail call i32 @fclose(i32* %1)
ret void
}