#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 getopt(int, char **, char *);
char *optarg;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ test_locking(char const *);
int main(int argc, char **argv) {
  int flag;
  const char *lockfile = NULL;
  while (1) {
    flag = getopt(argc, argv, "f:");
    if (flag == -1)
      break;
    switch (flag) {
    case 'f':
      lockfile = optarg;
      break;
    default:
      printf("Unknown option: -%c\n", flag);
      break;
    }
  }
  if (lockfile) {
    test_locking(lockfile);
  } else {
    printf("ERROR: NO LOCK FILE GIVEN. usage: -f <lock file>\n");
  }
  return 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)
movq   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xea4(%rip),%rdx
call   1050 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    1173 <main+0x43>
jmp    11ad <main+0x7d>
mov    -0x14(%rbp),%eax
sub    $0x66,%eax
jne    1197 <main+0x67>
jmp    1184 <main+0x54>
mov    0x2e6d(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    11a8 <main+0x78>
mov    -0x14(%rbp),%esi
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    114e <main+0x1e>
cmpq   $0x0,-0x20(%rbp)
je     11c6 <main+0x96>
mov    -0x20(%rbp),%rdi
call   1040 <test_locking@plt>
jmp    11d4 <main+0xa4>
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xea9(%rip),%r15
mov    0x2e9a(%rip),%r13
lea    0xe9e(%rip),%r12
xor    %r14d,%r14d
jmp    117c <main+0x3c>
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1060 <getopt@plt>
cmp    $0xffffffff,%eax
je     1199 <main+0x59>
cmp    $0x66,%eax
jne    1170 <main+0x30>
mov    0x0(%r13),%r14
jmp    117c <main+0x3c>
test   %r14,%r14
je     11a8 <main+0x68>
mov    %r14,%rdi
call   1050 <test_locking@plt>
jmp    11b4 <main+0x74>
lea    0xe69(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"f:\00"
@optarg = global i8* null
@.str.1 = [21 x i8] c"Unknown option: -%c\0A\00"
@.str.2 = [50 x i8] c"ERROR: NO LOCK FILE GIVEN. usage: -f <lock file>\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %7
br label %8
8: ; preds = %2, %22
%9 = load i32, i32* %4
%10 = load i8**, i8*** %5
%11 = call i32 @getopt(i32 %9, i8** %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 %11, i32* %6
%12 = load i32, i32* %6
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %15
14: ; preds = %8
br label %23
15: ; preds = %8
%16 = load i32, i32* %6
switch i32 %16, label %19 [
i32 102, label %17
]
17: ; preds = %15
%18 = load i8*, i8** @optarg
store i8* %18, i8** %7
br label %22
19: ; preds = %15
%20 = load i32, i32* %6
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %20)
br label %22
22: ; preds = %19, %17
br label %8
23: ; preds = %14
%24 = load i8*, i8** %7
%25 = icmp ne i8* %24, null
br i1 %25, label %26, label %29
26: ; preds = %23
%27 = load i8*, i8** %7
%28 = call i32 @test_locking(i8* %27)
br label %31
29: ; preds = %23
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0))
br label %31
31: ; preds = %29, %26
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"f:\00"
@optarg = global i8* null
@.str.1 = [21 x i8] c"Unknown option: -%c\0A\00"
@str = [49 x i8] c"ERROR: NO LOCK FILE GIVEN. usage: -f <lock file>\00"
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %7, %2
%4 = phi i8* [ %8, %7 ], [ null, %2 ]
br label %5
5: ; preds = %3, %9
%6 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
switch i32 %6, label %9 [
i32 -1, label %11
i32 102, label %7
]
7: ; preds = %5
%8 = load i8*, i8** @optarg
br label %3
9: ; preds = %5
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %6)
br label %5
11: ; preds = %5
%12 = icmp eq i8* %4, null
br i1 %12, label %15, label %13
13: ; preds = %11
%14 = tail call i32 @test_locking(i8* %4)
br label %17
15: ; preds = %11
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str, i64 0, i64 0))
br label %17
17: ; preds = %15, %13
ret i32 0
}