#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 do_lock();
int do_unlock();
int /*<<< orphan*/ show_usage(char *);
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  int i = 0;
  for (i = 0; i < argc; i++) {
    if (strcmp("-l", argv[i]) == 0) {
      return do_lock();
    }
    if (strcmp("-u", argv[i]) == 0) {
      return do_unlock();
    }
  }
  show_usage(argv[0]);
  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)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11e5 <main+0xa5>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe7d(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11a1 <main+0x61>
mov    $0x0,%al
call   1040 <do_lock@plt>
mov    %eax,-0x4(%rbp)
jmp    11f8 <main+0xb8>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe4f(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11d2 <main+0x92>
mov    $0x0,%al
call   1060 <do_unlock@plt>
mov    %eax,-0x4(%rbp)
jmp    11f8 <main+0xb8>
jmp    11d7 <main+0x97>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1164 <main+0x24>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <show_usage@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r13
test   %edi,%edi
jle    119d <main+0x5d>
mov    %edi,%r12d
xor    %ebx,%ebx
lea    0xea4(%rip),%r14
lea    0xea0(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x0(%r13,%rbx,8),%rsi
mov    %r14,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11b2 <main+0x72>
mov    0x0(%r13,%rbx,8),%rsi
mov    %r15,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11c2 <main+0x82>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1170 <main+0x30>
mov    0x0(%r13),%rdi
call   1050 <show_usage@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1040 <do_lock@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1060 <do_unlock@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"-l\00"
@.str.1 = [3 x i8] c"-u\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %6
br label %7
7: ; preds = %32, %2
%8 = load i32, i32* %6
%9 = load i32, i32* %4
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %35
11: ; preds = %7
%12 = load i8**, i8*** %5
%13 = load i32, i32* %6
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8*, i8** %12, i64 %14
%16 = load i8*, i8** %15
%17 = call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %11
%20 = call i32 (...) @do_lock()
store i32 %20, i32* %3
br label %40
21: ; preds = %11
%22 = load i8**, i8*** %5
%23 = load i32, i32* %6
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8*, i8** %22, i64 %24
%26 = load i8*, i8** %25
%27 = call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %26)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %21
%30 = call i32 (...) @do_unlock()
store i32 %30, i32* %3
br label %40
31: ; preds = %21
br label %32
32: ; preds = %31
%33 = load i32, i32* %6
%34 = add nsw i32 %33, 1
store i32 %34, i32* %6
br label %7
35: ; preds = %7
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 0
%38 = load i8*, i8** %37
%39 = call i32 @show_usage(i8* %38)
store i32 0, i32* %3
br label %40
40: ; preds = %35, %29, %19
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
@.str = [3 x i8] c"-l\00"
@.str.1 = [3 x i8] c"-u\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 0
br i1 %3, label %4, label %23
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %8
6: ; preds = %16
%7 = icmp eq i64 %20, %5
br i1 %7, label %23, label %8
8: ; preds = %4, %6
%9 = phi i64 [ 0, %4 ], [ %20, %6 ]
%10 = getelementptr inbounds i8*, i8** %1, i64 %9
%11 = load i8*, i8** %10
%12 = tail call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %8
%15 = tail call i32 (...) @do_lock()
br label %26
16: ; preds = %8
%17 = load i8*, i8** %10
%18 = tail call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = icmp eq i64 %18, 0
%20 = add nuw nsw i64 %9, 1
br i1 %19, label %21, label %6
21: ; preds = %16
%22 = tail call i32 (...) @do_unlock()
br label %26
23: ; preds = %6, %2
%24 = load i8*, i8** %1
%25 = tail call i32 @show_usage(i8* %24)
br label %26
26: ; preds = %23, %21, %14
%27 = phi i32 [ %15, %14 ], [ %22, %21 ], [ 0, %23 ]
ret i32 %27
}