#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 atoi(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int open_lock_sleep_close(char *, int, int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ usage(char *, char *);
int main(int argc, char *argv[]) {
  int from, to, sleeptime;
  if (argc < 4) {
    usage(argv[0], "Not enough parameters specified");
  }
  if (argc < 5) {
    sleeptime = 10;
  } else {
    sleeptime = atoi(argv[4]);
  }
  printf("Working in dir: %s\n", argv[1]);
  from = atoi(argv[2]);
  to = atoi(argv[3]);
  printf("Locking from Byte: %d (sleeptime=%d)\n", from, sleeptime);
  printf("Locking to Byte: %d\n", to);
  return open_lock_sleep_close(argv[1], from, to, sleeptime);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    1173 <main+0x33>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe92(%rip),%rsi
call   1050 <usage@plt>
cmpl   $0x5,-0x8(%rbp)
jge    1189 <main+0x49>
movl   $0xa,-0x1c(%rbp)
jmp    1199 <main+0x59>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
call   1040 <open_lock_sleep_close@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
cmp    $0x3,%edi
jg     1166 <main+0x26>
mov    (%r15),%rdi
lea    0xea7(%rip),%rsi
call   1050 <usage@plt>
mov    $0xa,%r14d
jmp    117d <main+0x3d>
mov    $0xa,%r14d
cmp    $0x4,%edi
je     117d <main+0x3d>
mov    0x20(%r15),%rdi
call   1060 <atoi@plt>
mov    %eax,%r14d
mov    0x8(%r15),%rsi
lea    0xe98(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%r15),%rdi
call   1060 <atoi@plt>
mov    %eax,%ebp
mov    0x18(%r15),%rdi
call   1060 <atoi@plt>
mov    %eax,%ebx
lea    0xe88(%rip),%rdi
mov    %ebp,%esi
mov    %r14d,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe9b(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x8(%r15),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
mov    %r14d,%ecx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <open_lock_sleep_close@plt>

LLVM IR (-O0):
@.str = [32 x i8] c"Not enough parameters specified\00"
@.str.1 = [20 x i8] c"Working in dir: %s\0A\00"
@.str.2 = [38 x i8] c"Locking from Byte: %d (sleeptime=%d)\0A\00"
@.str.3 = [21 x i8] c"Locking to Byte: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 4
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 @usage(i8* %14, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %11, %2
%17 = load i32, i32* %4
%18 = icmp slt i32 %17, 5
br i1 %18, label %19, label %20
19: ; preds = %16
store i32 10, i32* %8
br label %25
20: ; preds = %16
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 4
%23 = load i8*, i8** %22
%24 = call i32 @atoi(i8* %23)
store i32 %24, i32* %8
br label %25
25: ; preds = %20, %19
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %28)
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 2
%32 = load i8*, i8** %31
%33 = call i32 @atoi(i8* %32)
store i32 %33, i32* %6
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 3
%36 = load i8*, i8** %35
%37 = call i32 @atoi(i8* %36)
store i32 %37, i32* %7
%38 = load i32, i32* %6
%39 = load i32, i32* %8
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i32 %38, i32 %39)
%41 = load i32, i32* %7
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %41)
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 1
%45 = load i8*, i8** %44
%46 = load i32, i32* %6
%47 = load i32, i32* %7
%48 = load i32, i32* %8
%49 = call i32 @open_lock_sleep_close(i8* %45, i32 %46, i32 %47, i32 %48)
ret i32 %49
}

LLVM IR (-O2):
@.str = [32 x i8] c"Not enough parameters specified\00"
@.str.1 = [20 x i8] c"Working in dir: %s\0A\00"
@.str.2 = [38 x i8] c"Locking from Byte: %d (sleeptime=%d)\0A\00"
@.str.3 = [21 x i8] c"Locking to Byte: %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 4
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 @usage(i8* %5, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
br label %13
7: ; preds = %2
%8 = icmp eq i32 %0, 4
br i1 %8, label %13, label %9
9: ; preds = %7
%10 = getelementptr inbounds i8*, i8** %1, i64 4
%11 = load i8*, i8** %10
%12 = tail call i32 @atoi(i8* %11)
br label %13
13: ; preds = %4, %7, %9
%14 = phi i32 [ %12, %9 ], [ 10, %7 ], [ 10, %4 ]
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = getelementptr inbounds i8*, i8** %1, i64 2
%19 = load i8*, i8** %18
%20 = tail call i32 @atoi(i8* %19)
%21 = getelementptr inbounds i8*, i8** %1, i64 3
%22 = load i8*, i8** %21
%23 = tail call i32 @atoi(i8* %22)
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i32 %20, i32 %14)
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %23)
%26 = load i8*, i8** %15
%27 = tail call i32 @open_lock_sleep_close(i8* %26, i32 %20, i32 %23, i32 %14)
ret i32 %27
}