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

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ clearLastError();
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int readValueFromFile(char *, char *, int);
int readIntValueFromFile(char *fileName) {
  clearLastError();
  char buff[255];
  memset(buff, 0, sizeof(buff));
  int ret = readValueFromFile(fileName, buff, sizeof(buff) - 1);
  if (ret == 0) {
    return atoi(buff);
  }
  return ret;
}


x86 assembly (clang, -O0):
<readIntValueFromFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x0,%al
call   1040 <clearLastError@plt>
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0xff,%edx
call   1030 <memset@plt>
mov    -0x10(%rbp),%rdi
lea    -0x110(%rbp),%rsi
mov    $0xfe,%edx
call   1050 <readValueFromFile@plt>
mov    %eax,-0x114(%rbp)
cmpl   $0x0,-0x114(%rbp)
jne    11a5 <readIntValueFromFile+0x65>
lea    -0x110(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x4(%rbp)
jmp    11ae <readIntValueFromFile+0x6e>
mov    -0x114(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readIntValueFromFile>:
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %rdi,%rbx
xor    %eax,%eax
call   1040 <clearLastError@plt>
mov    %rsp,%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0xff,%edx
call   1030 <memset@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0xfe,%edx
call   1050 <readValueFromFile@plt>
test   %eax,%eax
jne    1182 <readIntValueFromFile+0x42>
mov    %rsp,%rdi
call   1060 <atoi@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @readIntValueFromFile(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [255 x i8]
%5 = alloca i32
store i8* %0, i8** %3
%6 = call i32 (...) @clearLastError()
%7 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 0
%8 = call i32 @memset(i8* %7, i32 0, i32 255)
%9 = load i8*, i8** %3
%10 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 0
%11 = call i32 @readValueFromFile(i8* %9, i8* %10, i32 254)
store i32 %11, i32* %5
%12 = load i32, i32* %5
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %1
%15 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 0
%16 = call i32 @atoi(i8* %15)
store i32 %16, i32* %2
br label %19
17: ; preds = %1
%18 = load i32, i32* %5
store i32 %18, i32* %2
br label %19
19: ; preds = %17, %14
%20 = load i32, i32* %2
ret i32 %20
}

LLVM IR (-O2):
define i32 @readIntValueFromFile(i8* %0) {
%2 = alloca [255 x i8]
%3 = tail call i32 (...) @clearLastError()
%4 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 0
%5 = call i32 @memset(i8* %4, i32 0, i32 255)
%6 = call i32 @readValueFromFile(i8* %0, i8* %4, i32 254)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = call i32 @atoi(i8* %4)
br label %10
10: ; preds = %1, %8
%11 = phi i32 [ %9, %8 ], [ %6, %1 ]
ret i32 %11
}