#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*/ EXIT_FAILURE;
int /*<<< orphan*/ attemptLock(char *);
int /*<<< orphan*/ err(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ errx(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ execvp(char *, char **);
int main(int argc, char *argv[]) {
  if (argc < 3)
    errx(EXIT_FAILURE,
         "Not enough arguments.\nUsage: %s LOCKFILENAME COMMAND...\n", argv[0]);
  attemptLock(argv[1]);
  argv += 2;
  execvp(argv[0], argv);
  err(EXIT_FAILURE, "Cannot execute %s", argv[0]);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    117c <main+0x3c>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe89(%rip),%rsi
call   1030 <errx@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <attemptLock@plt>
mov    -0x10(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <execvp@plt>
mov    0x2e34(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe7d(%rip),%rsi
call   1040 <err@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
cmp    $0x2,%edi
jg     1161 <main+0x21>
mov    0x2e90(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xea4(%rip),%rsi
call   1030 <errx@plt>
mov    0x8(%rbx),%rdi
call   1050 <attemptLock@plt>
lea    0x10(%rbx),%rsi
mov    0x10(%rbx),%rdi
call   1060 <execvp@plt>
mov    0x2e62(%rip),%rax
mov    (%rax),%edi
mov    0x10(%rbx),%rdx
lea    0xeae(%rip),%rsi
call   1040 <err@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
@.str = [57 x i8] c"Not enough arguments.\0AUsage: %s LOCKFILENAME COMMAND...\0A\00"
@.str.1 = [18 x i8] c"Cannot execute %s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 3
br i1 %7, label %8, label %14
8: ; preds = %2
%9 = load i32, i32* @EXIT_FAILURE
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 0
%12 = load i8*, i8** %11
%13 = call i32 @errx(i32 %9, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0), i8* %12)
br label %14
14: ; preds = %8, %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @attemptLock(i8* %17)
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 2
store i8** %20, i8*** %5
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 0
%23 = load i8*, i8** %22
%24 = load i8**, i8*** %5
%25 = call i32 @execvp(i8* %23, i8** %24)
%26 = load i32, i32* @EXIT_FAILURE
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 0
%29 = load i8*, i8** %28
%30 = call i32 @err(i32 %26, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %29)
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@.str = [57 x i8] c"Not enough arguments.\0AUsage: %s LOCKFILENAME COMMAND...\0A\00"
@.str.1 = [18 x i8] c"Cannot execute %s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = load i32, i32* @EXIT_FAILURE
%6 = load i8*, i8** %1
%7 = tail call i32 @errx(i32 %5, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %8
8: ; preds = %4, %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @attemptLock(i8* %10)
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = tail call i32 @execvp(i8* %13, i8** %12)
%15 = load i32, i32* @EXIT_FAILURE
%16 = load i8*, i8** %12
%17 = tail call i32 @err(i32 %15, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %16)
ret i32 0
}