#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*/ uint64_t;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ strtoull(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int sys_read_string(char *, char *, char *, int);
int sys_read_uint64(char *dir_name, char *file_name, uint64_t *u) {
  char buf[32];
  int r;
  if ((r = sys_read_string(dir_name, file_name, buf, sizeof(buf))) < 0)
    return r;
  *u = strtoull(buf, 0, 0);
  return 0;
}


x86 assembly (clang, -O0):
<sys_read_uint64>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x40(%rbp),%rdx
mov    $0x20,%ecx
call   1040 <sys_read_string@plt>
mov    %eax,-0x44(%rbp)
cmp    $0x0,%eax
jge    1161 <sys_read_uint64+0x41>
mov    -0x44(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    117d <sys_read_uint64+0x5d>
lea    -0x40(%rbp),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   1030 <strtoull@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sys_read_uint64>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
mov    %rdx,%rbx
mov    %rsp,%rdx
mov    $0x20,%ecx
call   1040 <sys_read_string@plt>
test   %eax,%eax
js     114c <sys_read_uint64+0x2c>
mov    %rsp,%rdi
xor    %ebp,%ebp
xor    %esi,%esi
xor    %edx,%edx
call   1030 <strtoull@plt>
mov    %eax,(%rbx)
jmp    114e <sys_read_uint64+0x2e>
mov    %eax,%ebp
mov    %ebp,%eax
add    $0x28,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @sys_read_uint64(i8* %0, i8* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca [32 x i8]
%9 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32* %2, i32** %7
%10 = load i8*, i8** %5
%11 = load i8*, i8** %6
%12 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%13 = call i32 @sys_read_string(i8* %10, i8* %11, i8* %12, i32 32)
store i32 %13, i32* %9
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %3
%16 = load i32, i32* %9
store i32 %16, i32* %4
br label %21
17: ; preds = %3
%18 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%19 = call i32 @strtoull(i8* %18, i32 0, i32 0)
%20 = load i32*, i32** %7
store i32 %19, i32* %20
store i32 0, i32* %4
br label %21
21: ; preds = %17, %15
%22 = load i32, i32* %4
ret i32 %22
}

LLVM IR (-O2):
define i32 @sys_read_uint64(i8* %0, i8* %1, i32* nocapture writeonly %2) {
%4 = alloca [32 x i8]
%5 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%6 = call i32 @sys_read_string(i8* %0, i8* %1, i8* %5, i32 32)
%7 = icmp slt i32 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %3
%9 = call i32 @strtoull(i8* %5, i32 0, i32 0)
store i32 %9, i32* %2
br label %10
10: ; preds = %3, %8
%11 = phi i32 [ 0, %8 ], [ %6, %3 ]
ret i32 %11
}