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

/* Variables and functions */
struct phash *new_phash(unsigned char *, struct phash *);
int /*<<< orphan*/ read_hash(int /*<<< orphan*/ *, unsigned char *);
struct phash *read_file(FILE *fl, size_t *count) {
  struct phash *data = NULL;
  unsigned char hash[(768 / 8)];
  for (;;) {
    if (!read_hash(fl, hash))
      break;
    data = new_phash(hash, data);
    if (count) {
      (*count)++;
    }
  }
  return data;
}


x86 assembly (clang, -O0):
<read_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x80(%rbp),%rsi
call   1040 <read_hash@plt>
cmp    $0x0,%eax
jne    1156 <read_file+0x36>
jmp    1185 <read_file+0x65>
lea    -0x80(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <new_phash@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1180 <read_file+0x60>
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
jmp    113b <read_file+0x1b>
mov    -0x18(%rbp),%rax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_file>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %rsi,%r15
mov    %rdi,%r14
mov    %rsp,%rsi
call   1040 <read_hash@plt>
xor    %ebx,%ebx
test   %eax,%eax
je     1178 <read_file+0x58>
mov    %rsp,%r12
jmp    115f <read_file+0x3f>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
mov    %r12,%rsi
call   1040 <read_hash@plt>
test   %eax,%eax
je     1178 <read_file+0x58>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <new_phash@plt>
mov    %rax,%rbx
test   %r15,%r15
je     1150 <read_file+0x30>
addq   $0x1,(%r15)
jmp    1150 <read_file+0x30>
mov    %rbx,%rax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.phash = type { i32 }
define %struct.phash* @read_file(i32* %0, i64* %1) {
%3 = alloca i32*
%4 = alloca i64*
%5 = alloca %struct.phash*
%6 = alloca [96 x i8]
store i32* %0, i32** %3
store i64* %1, i64** %4
store %struct.phash* null, %struct.phash** %5
br label %7
7: ; preds = %23, %2
%8 = load i32*, i32** %3
%9 = getelementptr inbounds [96 x i8], [96 x i8]* %6, i64 0, i64 0
%10 = call i32 @read_hash(i32* %8, i8* %9)
%11 = icmp ne i32 %10, 0
br i1 %11, label %13, label %12
12: ; preds = %7
br label %24
13: ; preds = %7
%14 = getelementptr inbounds [96 x i8], [96 x i8]* %6, i64 0, i64 0
%15 = load %struct.phash*, %struct.phash** %5
%16 = call %struct.phash* @new_phash(i8* %14, %struct.phash* %15)
store %struct.phash* %16, %struct.phash** %5
%17 = load i64*, i64** %4
%18 = icmp ne i64* %17, null
br i1 %18, label %19, label %23
19: ; preds = %13
%20 = load i64*, i64** %4
%21 = load i64, i64* %20
%22 = add i64 %21, 1
store i64 %22, i64* %20
br label %23
23: ; preds = %19, %13
br label %7
24: ; preds = %12
%25 = load %struct.phash*, %struct.phash** %5
ret %struct.phash* %25
}

LLVM IR (-O2):
%struct.phash = type { i32 }
define %struct.phash* @read_file(i32* %0, i64* %1) {
%3 = alloca [96 x i8]
%4 = getelementptr inbounds [96 x i8], [96 x i8]* %3, i64 0, i64 0
%5 = call i32 @read_hash(i32* %0, i8* %4)
%6 = icmp eq i32 %5, 0
br i1 %6, label %18, label %7
7: ; preds = %2
%8 = icmp eq i64* %1, null
br label %9
9: ; preds = %7, %15
%10 = phi %struct.phash* [ null, %7 ], [ %11, %15 ]
%11 = call %struct.phash* @new_phash(i8* %4, %struct.phash* %10)
br i1 %8, label %15, label %12
12: ; preds = %9
%13 = load i64, i64* %1
%14 = add i64 %13, 1
store i64 %14, i64* %1
br label %15
15: ; preds = %12, %9
%16 = call i32 @read_hash(i32* %0, i8* %4)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %9
18: ; preds = %15, %2
%19 = phi %struct.phash* [ null, %2 ], [ %11, %15 ]
ret %struct.phash* %19
}