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

/* Variables and functions */
long atol(char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/ *);
int mylock(char const *, long, long);
int /*<<< orphan*/ printf(char *, long, long, long);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ usage(char *, char *);
int main(int argc, char *argv[]) {
  const char *FILENAME = "/tmp/myfile-1337";
  if (argc == 1) {
    char text[1337];
    int i;
    for (i = 0; i < 1337; i++) {
      text[i] = (char)((i % 90) + 32);
    }
    FILE *file = fopen(FILENAME, "w");
    fwrite(text, 1, 1337, file);
    fclose(file);
    exit(0);
  }
  if (argc < 3) {
    usage(argv[0], "wrong number of arguments");
  }
  long x = atol(argv[1]);
  long y = atol(argv[2]);
  long len = y - x;
  printf("x=%ld y=%ld len=%ld\n", x, y, len);
  int fd = mylock(FILENAME, x, y);
  sleep(10);
  close(fd);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x590,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe40(%rip),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    1264 <main+0xc4>
movl   $0x0,-0x564(%rbp)
cmpl   $0x539,-0x564(%rbp)
jge    121d <main+0x7d>
mov    -0x564(%rbp),%eax
mov    $0x5a,%ecx
cltd
idiv   %ecx
add    $0x20,%edx
mov    %dl,%cl
movslq -0x564(%rbp),%rax
mov    %cl,-0x560(%rbp,%rax,1)
mov    -0x564(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x564(%rbp)
jmp    11d8 <main+0x38>
mov    -0x18(%rbp),%rdi
lea    0xde9(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x570(%rbp)
lea    -0x560(%rbp),%rdi
mov    -0x570(%rbp),%rcx
mov    $0x1,%esi
mov    $0x539,%edx
call   10b0 <fwrite@plt>
mov    -0x570(%rbp),%rdi
call   1040 <fclose@plt>
xor    %edi,%edi
call   10a0 <exit@plt>
cmpl   $0x3,-0x8(%rbp)
jge    1281 <main+0xe1>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xd97(%rip),%rsi
call   1070 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <atol@plt>
mov    %rax,-0x578(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1080 <atol@plt>
mov    %rax,-0x580(%rbp)
mov    -0x580(%rbp),%rax
sub    -0x578(%rbp),%rax
mov    %rax,-0x588(%rbp)
mov    -0x578(%rbp),%rsi
mov    -0x580(%rbp),%rdx
mov    -0x588(%rbp),%rcx
lea    0xd53(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x578(%rbp),%rsi
mov    -0x580(%rbp),%rdx
call   1030 <mylock@plt>
mov    %eax,-0x58c(%rbp)
mov    $0xa,%edi
call   10c0 <sleep@plt>
mov    -0x58c(%rbp),%edi
call   1060 <close@plt>
xor    %edi,%edi
call   10a0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x548,%rsp
cmp    $0x1,%edi
jne    12a8 <main+0x108>
movdqa 0xe45(%rip),%xmm5
movdqa 0xe4d(%rip),%xmm4
mov    $0x10,%eax
movdqa 0xe50(%rip),%xmm2
movdqa 0xe58(%rip),%xmm3
movdqa 0xe5f(%rip),%xmm8
movdqa 0xe66(%rip),%xmm9
movdqa 0xe6e(%rip),%xmm6
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movdqa %xmm4,%xmm7
pmulhuw %xmm2,%xmm7
psrlw  $0x4,%xmm7
pmullw %xmm3,%xmm7
movdqa %xmm4,%xmm1
psubw  %xmm7,%xmm1
movdqa %xmm5,%xmm7
pmulhuw %xmm2,%xmm7
psrlw  $0x4,%xmm7
pmullw %xmm3,%xmm7
movdqa %xmm5,%xmm0
psubw  %xmm7,%xmm0
packuswb %xmm0,%xmm1
paddb  %xmm8,%xmm1
movdqa %xmm1,-0x10(%rsp,%rax,1)
cmp    $0x530,%rax
je     131b <main+0x17b>
movdqa %xmm5,%xmm0
paddw  %xmm9,%xmm0
movdqa %xmm4,%xmm1
paddw  %xmm9,%xmm1
movdqa %xmm1,%xmm7
pmulhuw %xmm2,%xmm7
psrlw  $0x4,%xmm7
pmullw %xmm3,%xmm7
psubw  %xmm7,%xmm1
movdqa %xmm0,%xmm7
pmulhuw %xmm2,%xmm7
psrlw  $0x4,%xmm7
pmullw %xmm3,%xmm7
psubw  %xmm7,%xmm0
packuswb %xmm0,%xmm1
paddb  %xmm8,%xmm1
movdqa %xmm1,(%rsp,%rax,1)
paddw  %xmm6,%xmm4
paddw  %xmm6,%xmm5
add    $0x20,%rax
jmp    1200 <main+0x60>
mov    %rsi,%rbx
cmp    $0x2,%edi
jg     12bf <main+0x11f>
mov    (%rbx),%rdi
lea    0xdc9(%rip),%rsi
call   1070 <usage@plt>
mov    0x8(%rbx),%rdi
call   1080 <atol@plt>
mov    %rax,%r14
mov    0x10(%rbx),%rdi
call   1080 <atol@plt>
mov    %rax,%rbx
mov    %rax,%rcx
sub    %r14,%rcx
lea    0xdb9(%rip),%rdi
mov    %r14,%rsi
mov    %rax,%rdx
call   1050 <printf@plt>
lea    0xd7a(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1030 <mylock@plt>
mov    %eax,%ebx
mov    $0xa,%edi
call   10c0 <sleep@plt>
mov    %ebx,%edi
call   1060 <close@plt>
xor    %edi,%edi
call   10a0 <exit@plt>
movabs $0x6b6a696867666564,%rax
69 6a 6b
mov    %rax,0x530(%rsp)
movb   $0x6c,0x538(%rsp)
6c
lea    0xd34(%rip),%rdi
lea    0xd3e(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%rbx
mov    %rsp,%rdi
mov    $0x1,%esi
mov    $0x539,%edx
mov    %rax,%rcx
call   10b0 <fwrite@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %edi,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"/tmp/myfile-1337\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [26 x i8] c"wrong number of arguments\00"
@.str.3 = [21 x i8] c"x=%ld y=%ld len=%ld\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca [1337 x i8]
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i64
%11 = alloca i64
%12 = alloca i64
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8** %6
%14 = load i32, i32* %4
%15 = icmp eq i32 %14, 1
br i1 %15, label %16, label %40
16: ; preds = %2
store i32 0, i32* %8
br label %17
17: ; preds = %28, %16
%18 = load i32, i32* %8
%19 = icmp slt i32 %18, 1337
br i1 %19, label %20, label %31
20: ; preds = %17
%21 = load i32, i32* %8
%22 = srem i32 %21, 90
%23 = add nsw i32 %22, 32
%24 = trunc i32 %23 to i8
%25 = load i32, i32* %8
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [1337 x i8], [1337 x i8]* %7, i64 0, i64 %26
store i8 %24, i8* %27
br label %28
28: ; preds = %20
%29 = load i32, i32* %8
%30 = add nsw i32 %29, 1
store i32 %30, i32* %8
br label %17
31: ; preds = %17
%32 = load i8*, i8** %6
%33 = call i32* @fopen(i8* %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %33, i32** %9
%34 = getelementptr inbounds [1337 x i8], [1337 x i8]* %7, i64 0, i64 0
%35 = load i32*, i32** %9
%36 = call i32 @fwrite(i8* %34, i32 1, i32 1337, i32* %35)
%37 = load i32*, i32** %9
%38 = call i32 @fclose(i32* %37)
%39 = call i32 @exit(i32 0)
unreachable
40: ; preds = %2
%41 = load i32, i32* %4
%42 = icmp slt i32 %41, 3
br i1 %42, label %43, label %48
43: ; preds = %40
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 0
%46 = load i8*, i8** %45
%47 = call i32 @usage(i8* %46, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %48
48: ; preds = %43, %40
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 1
%51 = load i8*, i8** %50
%52 = call i64 @atol(i8* %51)
store i64 %52, i64* %10
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 2
%55 = load i8*, i8** %54
%56 = call i64 @atol(i8* %55)
store i64 %56, i64* %11
%57 = load i64, i64* %11
%58 = load i64, i64* %10
%59 = sub nsw i64 %57, %58
store i64 %59, i64* %12
%60 = load i64, i64* %10
%61 = load i64, i64* %11
%62 = load i64, i64* %12
%63 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i64 %60, i64 %61, i64 %62)
%64 = load i8*, i8** %6
%65 = load i64, i64* %10
%66 = load i64, i64* %11
%67 = call i32 @mylock(i8* %64, i64 %65, i64 %66)
store i32 %67, i32* %13
%68 = call i32 @sleep(i32 10)
%69 = load i32, i32* %13
%70 = call i32 @close(i32 %69)
%71 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [17 x i8] c"/tmp/myfile-1337\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [26 x i8] c"wrong number of arguments\00"
@.str.3 = [21 x i8] c"x=%ld y=%ld len=%ld\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1337 x i8]
%4 = icmp eq i32 %0, 1
br i1 %4, label %5, label %40
5: ; preds = %2
%6 = getelementptr inbounds [1337 x i8], [1337 x i8]* %3, i64 0, i64 0
br label %7
7: ; preds = %17, %5
%8 = phi i64 [ 0, %5 ], [ %24, %17 ]
%9 = phi <16 x i16> [ <i16 0, i16 1, i16 2, i16 3, i16 4, i16 5, i16 6, i16 7, i16 8, i16 9, i16 10, i16 11, i16 12, i16 13, i16 14, i16 15>, %5 ], [ %25, %17 ]
%10 = urem <16 x i16> %9, <i16 90, i16 90, i16 90, i16 90, i16 90, i16 90, i16 90, i16 90, i16 90, i16 90, i16 90, i16 90, i16 90, i16 90, i16 90, i16 90>
%11 = trunc <16 x i16> %10 to <16 x i8>
%12 = add nuw nsw <16 x i8> %11, <i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32>
%13 = getelementptr inbounds [1337 x i8], [1337 x i8]* %3, i64 0, i64 %8
%14 = bitcast i8* %13 to <16 x i8>*
store <16 x i8> %12, <16 x i8>* %14
%15 = or i64 %8, 16
%16 = icmp eq i64 %15, 1328
br i1 %16, label %26, label %17
17: ; preds = %7
%18 = add <16 x i16> %9, <i16 16, i16 16, i16 16, i16 16, i16 16, i16 16, i16 16, i16 16, i16 16, i16 16, i16 16, i16 16, i16 16, i16 16, i16 16, i16 16>
%19 = urem <16 x i16> %18, <i16 90, i16 90, i16 90, i16 90, i16 90, i16 90, i16 90, i16 90, i16 90, i16 90, i16 90, i16 90, i16 90, i16 90, i16 90, i16 90>
%20 = trunc <16 x i16> %19 to <16 x i8>
%21 = add nuw nsw <16 x i8> %20, <i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32>
%22 = getelementptr inbounds [1337 x i8], [1337 x i8]* %3, i64 0, i64 %15
%23 = bitcast i8* %22 to <16 x i8>*
store <16 x i8> %21, <16 x i8>* %23
%24 = add nuw nsw i64 %8, 32
%25 = add <16 x i16> %9, <i16 32, i16 32, i16 32, i16 32, i16 32, i16 32, i16 32, i16 32, i16 32, i16 32, i16 32, i16 32, i16 32, i16 32, i16 32, i16 32>
br label %7
26: ; preds = %7
%27 = getelementptr inbounds [1337 x i8], [1337 x i8]* %3, i64 0, i64 1328
store i8 100, i8* %27
%28 = getelementptr inbounds [1337 x i8], [1337 x i8]* %3, i64 0, i64 1329
store i8 101, i8* %28
%29 = getelementptr inbounds [1337 x i8], [1337 x i8]* %3, i64 0, i64 1330
store i8 102, i8* %29
%30 = getelementptr inbounds [1337 x i8], [1337 x i8]* %3, i64 0, i64 1331
store i8 103, i8* %30
%31 = getelementptr inbounds [1337 x i8], [1337 x i8]* %3, i64 0, i64 1332
store i8 104, i8* %31
%32 = getelementptr inbounds [1337 x i8], [1337 x i8]* %3, i64 0, i64 1333
store i8 105, i8* %32
%33 = getelementptr inbounds [1337 x i8], [1337 x i8]* %3, i64 0, i64 1334
store i8 106, i8* %33
%34 = getelementptr inbounds [1337 x i8], [1337 x i8]* %3, i64 0, i64 1335
store i8 107, i8* %34
%35 = getelementptr inbounds [1337 x i8], [1337 x i8]* %3, i64 0, i64 1336
store i8 108, i8* %35
%36 = tail call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%37 = call i32 @fwrite(i8* %6, i32 1, i32 1337, i32* %36)
%38 = tail call i32 @fclose(i32* %36)
%39 = tail call i32 @exit(i32 0)
unreachable
40: ; preds = %2
%41 = icmp slt i32 %0, 3
br i1 %41, label %42, label %45
42: ; preds = %40
%43 = load i8*, i8** %1
%44 = tail call i32 @usage(i8* %43, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %45
45: ; preds = %42, %40
%46 = getelementptr inbounds i8*, i8** %1, i64 1
%47 = load i8*, i8** %46
%48 = tail call i64 @atol(i8* %47)
%49 = getelementptr inbounds i8*, i8** %1, i64 2
%50 = load i8*, i8** %49
%51 = tail call i64 @atol(i8* %50)
%52 = sub nsw i64 %51, %48
%53 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i64 %48, i64 %51, i64 %52)
%54 = tail call i32 @mylock(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 %48, i64 %51)
%55 = tail call i32 @sleep(i32 10)
%56 = tail call i32 @close(i32 %54)
%57 = tail call i32 @exit(i32 0)
unreachable
}