#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 */

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ close(int);
int open(char *, int /*<<< orphan*/);
int read(int, void *, int);
void fillState(char *fileName, void *buf, int size) {
  int ret, fd;
  assert(size > 0);
  fd = open(fileName, O_RDONLY);
  assert(fd >= 0);
  ret = read(fd, buf, size);
  assert((ret <= size) && (ret > 0));
  close(fd);
}


x86 assembly (clang, -O0):
<fillState>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x8(%rbp),%rdi
mov    0x2e79(%rip),%rax
mov    (%rax),%esi
call   1060 <open@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
setge  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x1c(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1040 <read@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%ecx
xor    %eax,%eax
cmp    -0x14(%rbp),%ecx
mov    %al,-0x1d(%rbp)
jg     11b7 <fillState+0x77>
cmpl   $0x0,-0x18(%rbp)
setg   %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x1c(%rbp),%edi
call   1030 <close@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fillState>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebx
mov    %rsi,%r14
mov    %rdi,%r15
xor    %edi,%edi
test   %edx,%edx
setg   %dil
call   1050 <assert@plt>
mov    0x2e85(%rip),%rax
mov    (%rax),%esi
mov    %r15,%rdi
call   1060 <open@plt>
mov    %eax,%ebp
mov    %eax,%edi
not    %edi
shr    $0x1f,%edi
call   1050 <assert@plt>
mov    %ebp,%edi
mov    %r14,%rsi
mov    %ebx,%edx
call   1040 <read@plt>
cmp    %ebx,%eax
setle  %cl
test   %eax,%eax
setg   %al
and    %cl,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    %ebp,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <close@plt>

LLVM IR (-O0):
@O_RDONLY = global i32 0
define void @fillState(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%9 = load i32, i32* %6
%10 = icmp sgt i32 %9, 0
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = load i8*, i8** %4
%14 = load i32, i32* @O_RDONLY
%15 = call i32 @open(i8* %13, i32 %14)
store i32 %15, i32* %8
%16 = load i32, i32* %8
%17 = icmp sge i32 %16, 0
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
%20 = load i32, i32* %8
%21 = load i8*, i8** %5
%22 = load i32, i32* %6
%23 = call i32 @read(i32 %20, i8* %21, i32 %22)
store i32 %23, i32* %7
%24 = load i32, i32* %7
%25 = load i32, i32* %6
%26 = icmp sle i32 %24, %25
br i1 %26, label %27, label %30
27: ; preds = %3
%28 = load i32, i32* %7
%29 = icmp sgt i32 %28, 0
br label %30
30: ; preds = %27, %3
%31 = phi i1 [ false, %3 ], [ %29, %27 ]
%32 = zext i1 %31 to i32
%33 = call i32 @assert(i32 %32)
%34 = load i32, i32* %8
%35 = call i32 @close(i32 %34)
ret void
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
define void @fillState(i8* nocapture %0, i8* nocapture %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = load i32, i32* @O_RDONLY
%8 = tail call i32 @open(i8* %0, i32 %7)
%9 = xor i32 %8, -1
%10 = lshr i32 %9, 31
%11 = tail call i32 @assert(i32 %10)
%12 = tail call i32 @read(i32 %8, i8* %1, i32 %2)
%13 = icmp sle i32 %12, %2
%14 = icmp sgt i32 %12, 0
%15 = and i1 %13, %14
%16 = zext i1 %15 to i32
%17 = tail call i32 @assert(i32 %16)
%18 = tail call i32 @close(i32 %8)
ret void
}