#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*/ EXIT_SUCCESS;
int /*<<< orphan*/ LC_ALL;
int /*<<< orphan*/ err(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
char *getcwd(int /*<<< orphan*/ *, int /*<<< orphan*/);
char *getcwd_logical();
int getopt(int, char **, char *);
scalar_t__ optind;
int /*<<< orphan*/ printf(char *, char const *);
int /*<<< orphan*/ setlocale(int /*<<< orphan*/, char *);
int /*<<< orphan*/ setprogname(char *);
int /*<<< orphan*/ usage();
int main(int argc, char *argv[]) {
  int ch, lFlag;
  const char *p;
  setprogname(argv[0]);
  (void)setlocale(LC_ALL, "");
  lFlag = 0;
  while ((ch = getopt(argc, argv, "LP")) != -1) {
    switch (ch) {
    case 'L':
      lFlag = 1;
      break;
    case 'P':
      lFlag = 0;
      break;
    case '?':
    default:
      usage();
    }
  }
  argc -= optind;
  argv += optind;
  if (argc != 0)
    usage();
  if (lFlag)
    p = getcwd_logical();
  else
    p = NULL;
  if (p == NULL)
    p = getcwd(NULL, 0);
  if (p == NULL)
    err(EXIT_FAILURE, NULL);
  (void)printf("%s\n", p);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10b0 <setprogname@plt>
mov    0x2e0f(%rip),%rax
mov    (%rax),%edi
lea    0xe44(%rip),%rsi
call   1070 <setlocale@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe24(%rip),%rdx
call   1090 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     124c <main+0xbc>
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x3f,%eax
je     123b <main+0xab>
jmp    1201 <main+0x71>
mov    -0x24(%rbp),%eax
sub    $0x4c,%eax
je     1223 <main+0x93>
jmp    1212 <main+0x82>
mov    -0x24(%rbp),%eax
sub    $0x50,%eax
je     122f <main+0x9f>
jmp    1240 <main+0xb0>
movl   $0x1,-0x18(%rbp)
jmp    1247 <main+0xb7>
movl   $0x0,-0x18(%rbp)
jmp    1247 <main+0xb7>
jmp    1240 <main+0xb0>
mov    $0x0,%al
call   1080 <usage@plt>
jmp    11ce <main+0x3e>
mov    0x2d95(%rip),%rax
mov    (%rax),%rcx
movslq -0x8(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    0x2d81(%rip),%rax
mov    (%rax),%rax
shl    $0x3,%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1287 <main+0xf7>
mov    $0x0,%al
call   1080 <usage@plt>
cmpl   $0x0,-0x18(%rbp)
je     12a1 <main+0x111>
mov    $0x0,%al
call   1040 <getcwd_logical@plt>
mov    %rax,-0x20(%rbp)
jmp    12a9 <main+0x119>
movq   $0x0,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    12c3 <main+0x133>
xor    %eax,%eax
mov    %eax,%edi
xor    %esi,%esi
call   1050 <getcwd@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    12e0 <main+0x150>
mov    0x2d03(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <err@plt>
mov    -0x20(%rbp),%rsi
lea    0xd18(%rip),%rdi
call   1030 <printf@plt>
mov    0x2cd9(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
mov    (%rsi),%rdi
call   10b0 <setprogname@plt>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
lea    0xe52(%rip),%rsi
call   1070 <setlocale@plt>
lea    0xe40(%rip),%r14
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1090 <getopt@plt>
cmp    $0x4c,%eax
je     11f5 <main+0x65>
cmp    $0x50,%eax
je     11c0 <main+0x30>
cmp    $0xffffffff,%eax
je     11fd <main+0x6d>
xor    %eax,%eax
call   1080 <usage@plt>
jmp    11d0 <main+0x40>
mov    $0x1,%r15d
jmp    11d0 <main+0x40>
mov    0x2de4(%rip),%rax
cmp    %ebp,(%rax)
je     120f <main+0x7f>
xor    %eax,%eax
call   1080 <usage@plt>
test   %r15d,%r15d
je     1223 <main+0x93>
xor    %eax,%eax
call   1040 <getcwd_logical@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1246 <main+0xb6>
xor    %edi,%edi
xor    %esi,%esi
call   1050 <getcwd@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1246 <main+0xb6>
mov    0x2d9d(%rip),%rax
mov    (%rax),%edi
xor    %ebx,%ebx
xor    %esi,%esi
call   1060 <err@plt>
lea    0xdb6(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    0x2d74(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@LC_ALL = global i32 0
@.str = [1 x i8] zeroinitializer
@.str.1 = [3 x i8] c"LP\00"
@optind = global i64 0
@EXIT_FAILURE = global i32 0
@.str.2 = [4 x i8] c"%s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 0
%11 = load i8*, i8** %10
%12 = call i32 @setprogname(i8* %11)
%13 = load i32, i32* @LC_ALL
%14 = call i32 @setlocale(i32 %13, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %7
br label %15
15: ; preds = %27, %2
%16 = load i32, i32* %4
%17 = load i8**, i8*** %5
%18 = call i32 @getopt(i32 %16, i8** %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32 %18, i32* %6
%19 = icmp ne i32 %18, -1
br i1 %19, label %20, label %28
20: ; preds = %15
%21 = load i32, i32* %6
switch i32 %21, label %25 [
i32 76, label %22
i32 80, label %23
i32 63, label %24
]
22: ; preds = %20
store i32 1, i32* %7
br label %27
23: ; preds = %20
store i32 0, i32* %7
br label %27
24: ; preds = %20
br label %25
25: ; preds = %20, %24
%26 = call i32 (...) @usage()
br label %27
27: ; preds = %25, %23, %22
br label %15
28: ; preds = %15
%29 = load i64, i64* @optind
%30 = load i32, i32* %4
%31 = sext i32 %30 to i64
%32 = sub nsw i64 %31, %29
%33 = trunc i64 %32 to i32
store i32 %33, i32* %4
%34 = load i64, i64* @optind
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 %34
store i8** %36, i8*** %5
%37 = load i32, i32* %4
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %28
%40 = call i32 (...) @usage()
br label %41
41: ; preds = %39, %28
%42 = load i32, i32* %7
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %46
44: ; preds = %41
%45 = call i8* (...) @getcwd_logical()
store i8* %45, i8** %8
br label %47
46: ; preds = %41
store i8* null, i8** %8
br label %47
47: ; preds = %46, %44
%48 = load i8*, i8** %8
%49 = icmp eq i8* %48, null
br i1 %49, label %50, label %52
50: ; preds = %47
%51 = call i8* @getcwd(i32* null, i32 0)
store i8* %51, i8** %8
br label %52
52: ; preds = %50, %47
%53 = load i8*, i8** %8
%54 = icmp eq i8* %53, null
br i1 %54, label %55, label %58
55: ; preds = %52
%56 = load i32, i32* @EXIT_FAILURE
%57 = call i32 @err(i32 %56, i32* null)
br label %58
58: ; preds = %55, %52
%59 = load i8*, i8** %8
%60 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %59)
%61 = load i32, i32* @EXIT_SUCCESS
%62 = call i32 @exit(i32 %61)
unreachable
}

LLVM IR (-O2):
@LC_ALL = global i32 0
@.str = [1 x i8] zeroinitializer
@.str.1 = [3 x i8] c"LP\00"
@optind = global i64 0
@EXIT_FAILURE = global i32 0
@.str.2 = [4 x i8] c"%s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = load i8*, i8** %1
%4 = tail call i32 @setprogname(i8* %3)
%5 = load i32, i32* @LC_ALL
%6 = tail call i32 @setlocale(i32 %5, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %12, %2
%8 = phi i32 [ 0, %2 ], [ %13, %12 ]
br label %9
9: ; preds = %7, %14
%10 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
switch i32 %10, label %14 [
i32 -1, label %16
i32 76, label %12
i32 80, label %11
]
11: ; preds = %9
br label %12
12: ; preds = %9, %11
%13 = phi i32 [ 0, %11 ], [ 1, %9 ]
br label %7
14: ; preds = %9
%15 = tail call i32 (...) @usage()
br label %9
16: ; preds = %9
%17 = load i64, i64* @optind
%18 = trunc i64 %17 to i32
%19 = icmp eq i32 %18, %0
br i1 %19, label %22, label %20
20: ; preds = %16
%21 = tail call i32 (...) @usage()
br label %22
22: ; preds = %20, %16
%23 = icmp eq i32 %8, 0
br i1 %23, label %27, label %24
24: ; preds = %22
%25 = tail call i8* (...) @getcwd_logical()
%26 = icmp eq i8* %25, null
br i1 %26, label %27, label %33
27: ; preds = %22, %24
%28 = tail call i8* @getcwd(i32* null, i32 0)
%29 = icmp eq i8* %28, null
br i1 %29, label %30, label %33
30: ; preds = %27
%31 = load i32, i32* @EXIT_FAILURE
%32 = tail call i32 @err(i32 %31, i32* null)
br label %33
33: ; preds = %24, %30, %27
%34 = phi i8* [ null, %30 ], [ %28, %27 ], [ %25, %24 ]
%35 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %34)
%36 = load i32, i32* @EXIT_SUCCESS
%37 = tail call i32 @exit(i32 %36)
unreachable
}