#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*/ close(int);
int /*<<< orphan*/ exit(char);
int open(char *, int, int /*<<< orphan*/);
int read(int, void *, int);
int main() {
  char *fname = "/dev/shm/dasosdatafile";
  int fd;
  char x, y, z;
  if ((fd = open(fname, 00, 0)) == -1) {
    exit(-1);
  }
  if ((read(fd, (void *)&x, 1)) != 1) {
    exit(-2);
  }
  y = 0;
  z = 1;
  if (x >= 10)
    y = 2;
  else if (x >= 0)
    y = 1;
  if (y == 0)
    z = 0;
  if (y == 1 && z == 0) {
    z = 4;
  }
  close(fd);
  exit(y + z);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   1050 <open@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
jne    117d <main+0x3d>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
mov    -0x14(%rbp),%edi
lea    -0x15(%rbp),%rsi
mov    $0x1,%edx
call   1040 <read@plt>
cmp    $0x1,%eax
je     11a1 <main+0x61>
mov    $0xfffffffe,%edi
call   1060 <exit@plt>
movb   $0x0,-0x16(%rbp)
movb   $0x1,-0x17(%rbp)
movsbl -0x15(%rbp),%eax
cmp    $0xa,%eax
jl     11bf <main+0x7f>
movb   $0x2,-0x16(%rbp)
jmp    11d5 <main+0x95>
movsbl -0x15(%rbp),%eax
cmp    $0x0,%eax
jl     11d0 <main+0x90>
movb   $0x1,-0x16(%rbp)
jmp    11d5 <main+0x95>
movsbl -0x16(%rbp),%eax
cmp    $0x0,%eax
jne    11e6 <main+0xa6>
movb   $0x0,-0x17(%rbp)
movsbl -0x16(%rbp),%eax
cmp    $0x1,%eax
jne    1204 <main+0xc4>
movsbl -0x17(%rbp),%eax
cmp    $0x0,%eax
jne    1204 <main+0xc4>
movb   $0x4,-0x17(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <close@plt>
movsbl -0x16(%rbp),%eax
movsbl -0x17(%rbp),%ecx
add    %ecx,%eax
movsbl %al,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xeb6(%rip),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1050 <open@plt>
cmp    $0xffffffff,%eax
jne    1162 <main+0x22>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
mov    %eax,%ebx
lea    0x7(%rsp),%rsi
mov    %eax,%edi
mov    $0x1,%edx
call   1040 <read@plt>
cmp    $0x1,%eax
jne    1190 <main+0x50>
mov    0x7(%rsp),%al
mov    $0x2,%bpl
cmp    $0x9,%al
jg     118c <main+0x4c>
mov    $0x1,%bpl
test   %al,%al
js     119a <main+0x5a>
mov    $0x1,%al
jmp    119e <main+0x5e>
mov    $0xfffffffe,%edi
call   1060 <exit@plt>
xor    %ebp,%ebp
xor    %eax,%eax
add    %al,%bpl
mov    %ebx,%edi
call   1030 <close@plt>
movzbl %bpl,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"/dev/shm/dasosdatafile\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8
%5 = alloca i8
%6 = alloca i8
store i32 0, i32* %1
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8** %2
%7 = load i8*, i8** %2
%8 = call i32 @open(i8* %7, i32 0, i32 0)
store i32 %8, i32* %3
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = call i32 @exit(i8 signext -1)
unreachable
12: ; preds = %0
%13 = load i32, i32* %3
%14 = call i32 @read(i32 %13, i8* %4, i32 1)
%15 = icmp ne i32 %14, 1
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = call i32 @exit(i8 signext -2)
unreachable
18: ; preds = %12
store i8 0, i8* %5
store i8 1, i8* %6
%19 = load i8, i8* %4
%20 = sext i8 %19 to i32
%21 = icmp sge i32 %20, 10
br i1 %21, label %22, label %23
22: ; preds = %18
store i8 2, i8* %5
br label %29
23: ; preds = %18
%24 = load i8, i8* %4
%25 = sext i8 %24 to i32
%26 = icmp sge i32 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %23
store i8 1, i8* %5
br label %28
28: ; preds = %27, %23
br label %29
29: ; preds = %28, %22
%30 = load i8, i8* %5
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %29
store i8 0, i8* %6
br label %34
34: ; preds = %33, %29
%35 = load i8, i8* %5
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 1
br i1 %37, label %38, label %43
38: ; preds = %34
%39 = load i8, i8* %6
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %43
42: ; preds = %38
store i8 4, i8* %6
br label %43
43: ; preds = %42, %38, %34
%44 = load i32, i32* %3
%45 = call i32 @close(i32 %44)
%46 = load i8, i8* %5
%47 = sext i8 %46 to i32
%48 = load i8, i8* %6
%49 = sext i8 %48 to i32
%50 = add nsw i32 %47, %49
%51 = trunc i32 %50 to i8
%52 = call i32 @exit(i8 signext %51)
unreachable
}

LLVM IR (-O2):
@.str = [23 x i8] c"/dev/shm/dasosdatafile\00"
define i32 @main() {
%1 = alloca i8
%2 = tail call i32 @open(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 0, i32 0)
%3 = icmp eq i32 %2, -1
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = tail call i32 @exit(i8 signext -1)
unreachable
6: ; preds = %0
%7 = call i32 @read(i32 %2, i8* %1, i32 1)
%8 = icmp eq i32 %7, 1
br i1 %8, label %11, label %9
9: ; preds = %6
%10 = tail call i32 @exit(i8 signext -2)
unreachable
11: ; preds = %6
%12 = load i8, i8* %1
%13 = icmp sgt i8 %12, 9
br i1 %13, label %16, label %14
14: ; preds = %11
%15 = icmp sgt i8 %12, -1
br i1 %15, label %16, label %18
16: ; preds = %11, %14
%17 = phi i8 [ 2, %11 ], [ 1, %14 ]
br label %18
18: ; preds = %14, %16
%19 = phi i8 [ %17, %16 ], [ 0, %14 ]
%20 = phi i8 [ 1, %16 ], [ 0, %14 ]
%21 = tail call i32 @close(i32 %2)
%22 = add nuw nsw i8 %20, %19
%23 = tail call i32 @exit(i8 signext %22)
unreachable
}