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


x86 assembly (clang, -O0):
<outputscore>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
mov    $0x1b6,%esi
call   1050 <creat@plt>
cmp    $0x0,%rax
jge    1168 <outputscore+0x28>
jmp    1148 <outputscore+0x8>
mov    $0x0,%al
call   1040 <readscore@plt>
mov    %ax,-0x2(%rbp)
cwtl
cmp    $0x0,%eax
jne    1184 <outputscore+0x44>
mov    $0x0,%al
call   1060 <showscore@plt>
lea    0xe75(%rip),%rdi
call   1030 <unlink@plt>
movswl -0x2(%rbp),%eax
cmp    $0x0,%eax
jne    11aa <outputscore+0x6a>
mov    $0x7,%eax
mov    %eax,-0x8(%rbp)
jmp    11b1 <outputscore+0x71>
movswl -0x2(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cwtl
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<outputscore>:
push   %rbx
lea    0xeb8(%rip),%rbx
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x1b6,%esi
call   1050 <creat@plt>
test   %rax,%rax
js     1150 <outputscore+0x10>
xor    %eax,%eax
call   1040 <readscore@plt>
mov    %eax,%ebx
test   %ax,%ax
jne    117b <outputscore+0x3b>
xor    %eax,%eax
call   1060 <showscore@plt>
mov    $0x7,%bx
lea    0xe7e(%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 @outputscore() {
%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 %12
10: ; preds = %6
%11 = call i32 (...) @showscore()
br label %12
12: ; preds = %10, %6
%13 = call i32 @unlink(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%14 = load i16, i16* %1
%15 = sext i16 %14 to i32
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %12
br label %21
18: ; preds = %12
%19 = load i16, i16* %1
%20 = sext i16 %19 to i32
br label %21
21: ; preds = %18, %17
%22 = phi i32 [ 7, %17 ], [ %20, %18 ]
%23 = trunc i32 %22 to i16
ret i16 %23
}

LLVM IR (-O2):
@.str = [14 x i8] c"/tmp/sok.lock\00"
define signext i16 @outputscore() {
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 %9
7: ; preds = %4
%8 = tail call i32 (...) @showscore()
br label %9
9: ; preds = %7, %4
%10 = phi i16 [ 7, %7 ], [ %5, %4 ]
%11 = tail call i32 @unlink(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
ret i16 %10
}