#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 */
scalar_t__ creat(char *, int);
short makescore();
short readscore();
int /*<<< orphan*/ showscore();
int /*<<< orphan*/ unlink(char *);
short writescore();
short score() {
  short ret;
  while (creat("/tmp/sok.lock", 0666) < 0)
    ;
  if ((ret = readscore()) == 0)
    if ((ret = makescore()) == 0)
      if ((ret = writescore()) == 0)
        showscore();
  unlink("/tmp/sok.lock");
  return ((ret == 0) ? 7 : ret);
}


x86 assembly (clang, -O0):
<score>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xe91(%rip),%rdi
mov    $0x1b6,%esi
call   1070 <creat@plt>
cmp    $0x0,%rax
jge    1188 <score+0x28>
jmp    1168 <score+0x8>
mov    $0x0,%al
call   1040 <readscore@plt>
mov    %ax,-0x2(%rbp)
cwtl
cmp    $0x0,%eax
jne    11d8 <score+0x78>
mov    $0x0,%al
call   1060 <makescore@plt>
mov    %ax,-0x2(%rbp)
cwtl
cmp    $0x0,%eax
jne    11d3 <score+0x73>
mov    $0x0,%al
call   1050 <writescore@plt>
mov    %ax,-0x2(%rbp)
cwtl
cmp    $0x0,%eax
jne    11ce <score+0x6e>
mov    $0x0,%al
call   1080 <showscore@plt>
jmp    11d3 <score+0x73>
jmp    11d8 <score+0x78>
lea    0xe21(%rip),%rdi
call   1030 <unlink@plt>
movswl -0x2(%rbp),%eax
cmp    $0x0,%eax
jne    11fe <score+0x9e>
mov    $0x7,%eax
mov    %eax,-0x8(%rbp)
jmp    1205 <score+0xa5>
movswl -0x2(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cwtl
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<score>:
push   %rbx
lea    0xe98(%rip),%rbx
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x1b6,%esi
call   1070 <creat@plt>
test   %rax,%rax
js     1170 <score+0x10>
xor    %eax,%eax
call   1040 <readscore@plt>
mov    %eax,%ebx
test   %ax,%ax
jne    11b7 <score+0x57>
xor    %eax,%eax
call   1060 <makescore@plt>
mov    %eax,%ebx
test   %ax,%ax
jne    11b7 <score+0x57>
xor    %eax,%eax
call   1050 <writescore@plt>
mov    %eax,%ebx
test   %ax,%ax
jne    11b7 <score+0x57>
xor    %eax,%eax
call   1080 <showscore@plt>
mov    $0x7,%bx
lea    0xe42(%rip),%rdi
call   1030 <unlink@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [14 x i8] c"/tmp/sok.lock\00"
define signext i16 @score() {
%1 = alloca i16
br label %2
2: ; preds = %5, %0
%3 = call i64 @creat(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 438)
%4 = icmp slt i64 %3, 0
br i1 %4, label %5, label %6
5: ; preds = %2
br label %2
6: ; preds = %2
%7 = call signext i16 (...) @readscore()
store i16 %7, i16* %1
%8 = sext i16 %7 to i32
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %22
10: ; preds = %6
%11 = call signext i16 (...) @makescore()
store i16 %11, i16* %1
%12 = sext i16 %11 to i32
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %21
14: ; preds = %10
%15 = call signext i16 (...) @writescore()
store i16 %15, i16* %1
%16 = sext i16 %15 to i32
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = call i32 (...) @showscore()
br label %20
20: ; preds = %18, %14
br label %21
21: ; preds = %20, %10
br label %22
22: ; preds = %21, %6
%23 = call i32 @unlink(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%24 = load i16, i16* %1
%25 = sext i16 %24 to i32
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %22
br label %31
28: ; preds = %22
%29 = load i16, i16* %1
%30 = sext i16 %29 to i32
br label %31
31: ; preds = %28, %27
%32 = phi i32 [ 7, %27 ], [ %30, %28 ]
%33 = trunc i32 %32 to i16
ret i16 %33
}

LLVM IR (-O2):
@.str = [14 x i8] c"/tmp/sok.lock\00"
define signext i16 @score() {
br label %1
1: ; preds = %1, %0
%2 = tail call i64 @creat(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 438)
%3 = icmp slt i64 %2, 0
br i1 %3, label %1, label %4
4: ; preds = %1
%5 = tail call signext i16 (...) @readscore()
%6 = icmp eq i16 %5, 0
br i1 %6, label %7, label %15
7: ; preds = %4
%8 = tail call signext i16 (...) @makescore()
%9 = icmp eq i16 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %7
%11 = tail call signext i16 (...) @writescore()
%12 = icmp eq i16 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = tail call i32 (...) @showscore()
br label %15
15: ; preds = %4, %7, %10, %13
%16 = phi i16 [ 7, %13 ], [ %5, %4 ], [ %8, %7 ], [ %11, %10 ]
%17 = tail call i32 @unlink(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
ret i16 %16
}