#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;
scalar_t__ close(int);
int /*<<< orphan*/ exit(int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
size_t read(int, char *, int);
int /*<<< orphan*/ umask(int /*<<< orphan*/);
int main() {
  int fd;
  size_t size;
  char string[14];
  (void)umask(0);
  if ((fd = open("myfile", O_RDONLY)) < 0) {
    printf("Can\'t open file\n");
    exit(-1);
  }
  size = read(fd, string, 14);
  if (size != 14) {
    printf("Can\'t write all string\n");
    exit(-1);
  }
  printf("%s", string);
  if (close(fd) < 0) {
    printf("Can\'t close file\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xor    %edi,%edi
call   1060 <umask@plt>
mov    0x2e6b(%rip),%rax
mov    (%rax),%esi
lea    0xe7a(%rip),%rdi
call   1070 <open@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jge    11af <main+0x4f>
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
mov    -0x8(%rbp),%edi
lea    -0x1e(%rbp),%rsi
mov    $0xe,%edx
call   1050 <read@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0xe,-0x10(%rbp)
je     11e7 <main+0x87>
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
lea    -0x1e(%rbp),%rsi
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
call   1040 <close@plt>
cmp    $0x0,%rax
jge    1219 <main+0xb9>
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
xor    %edi,%edi
call   1070 <umask@plt>
mov    0x2e65(%rip),%rax
mov    (%rax),%esi
lea    0xe74(%rip),%rdi
call   1080 <open@plt>
test   %eax,%eax
js     11e1 <main+0x71>
mov    %eax,%ebx
lea    0x2(%rsp),%rsi
mov    %eax,%edi
mov    $0xe,%edx
call   1060 <read@plt>
cmp    $0xe,%rax
jne    11ea <main+0x7a>
lea    0xe52(%rip),%rdi
lea    0x2(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%edi
call   1050 <close@plt>
test   %rax,%rax
jns    11d9 <main+0x69>
lea    0xe36(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe4a(%rip),%rdi
jmp    11f1 <main+0x81>
lea    0xe2a(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"myfile\00"
@O_RDONLY = global i32 0
@.str.1 = [17 x i8] c"Can't open file\0A\00"
@.str.2 = [24 x i8] c"Can't write all string\0A\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [18 x i8] c"Can't close file\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i64
%4 = alloca [14 x i8]
store i32 0, i32* %1
%5 = call i32 @umask(i32 0)
%6 = load i32, i32* @O_RDONLY
%7 = call i32 @open(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %6)
store i32 %7, i32* %2
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @exit(i32 -1)
unreachable
12: ; preds = %0
%13 = load i32, i32* %2
%14 = getelementptr inbounds [14 x i8], [14 x i8]* %4, i64 0, i64 0
%15 = call i64 @read(i32 %13, i8* %14, i32 14)
store i64 %15, i64* %3
%16 = load i64, i64* %3
%17 = icmp ne i64 %16, 14
br i1 %17, label %18, label %21
18: ; preds = %12
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%20 = call i32 @exit(i32 -1)
unreachable
21: ; preds = %12
%22 = getelementptr inbounds [14 x i8], [14 x i8]* %4, i64 0, i64 0
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %22)
%24 = load i32, i32* %2
%25 = call i64 @close(i32 %24)
%26 = icmp slt i64 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %21
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
br label %29
29: ; preds = %27, %21
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"myfile\00"
@O_RDONLY = global i32 0
@.str.3 = [3 x i8] c"%s\00"
@str = [17 x i8] c"Can't close file\00"
@str.5 = [23 x i8] c"Can't write all string\00"
@str.6 = [16 x i8] c"Can't open file\00"
define i32 @main() {
%1 = alloca [14 x i8]
%2 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @umask(i32 0)
%4 = load i32, i32* @O_RDONLY
%5 = tail call i32 @open(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %0
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.6, i64 0, i64 0))
%9 = tail call i32 @exit(i32 -1)
unreachable
10: ; preds = %0
%11 = call i64 @read(i32 %5, i8* %2, i32 14)
%12 = icmp eq i64 %11, 14
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.5, i64 0, i64 0))
%15 = tail call i32 @exit(i32 -1)
unreachable
16: ; preds = %10
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %2)
%18 = call i64 @close(i32 %5)
%19 = icmp slt i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
br label %22
22: ; preds = %20, %16
ret i32 0
}