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


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)
movl   $0x1,-0x14(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe65(%rip),%rdx
call   1080 <getopt@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
je     120b <main+0x9b>
mov    -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x3f,%eax
je     11fa <main+0x8a>
jmp    11c0 <main+0x50>
mov    -0x24(%rbp),%eax
sub    $0x4c,%eax
je     11e2 <main+0x72>
jmp    11d1 <main+0x61>
mov    -0x24(%rbp),%eax
sub    $0x50,%eax
je     11ee <main+0x7e>
jmp    11ff <main+0x8f>
movl   $0x0,-0x14(%rbp)
jmp    1206 <main+0x96>
movl   $0x1,-0x14(%rbp)
jmp    1206 <main+0x96>
jmp    11ff <main+0x8f>
mov    $0x0,%al
call   1070 <usage@plt>
jmp    118d <main+0x1d>
mov    0x2dd6(%rip),%rax
mov    (%rax),%rcx
movslq -0x8(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    0x2dc2(%rip),%rax
mov    (%rax),%rax
shl    $0x3,%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1246 <main+0xd6>
mov    $0x0,%al
call   1070 <usage@plt>
cmpl   $0x0,-0x14(%rbp)
jne    1265 <main+0xf5>
mov    $0x0,%al
call   1040 <getcwd_logical@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    127e <main+0x10e>
xor    %eax,%eax
mov    %eax,%edi
xor    %esi,%esi
call   1050 <getcwd@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     1293 <main+0x123>
mov    -0x20(%rbp),%rsi
lea    0xd7a(%rip),%rdi
call   1030 <printf@plt>
jmp    12a4 <main+0x134>
mov    $0x1,%edi
lea    0xd68(%rip),%rsi
call   1060 <err@plt>
xor    %edi,%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
mov    $0x1,%r15d
lea    0xe77(%rip),%r14
jmp    11a0 <main+0x30>
mov    $0x1,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1080 <getopt@plt>
cmp    $0x4c,%eax
je     11c5 <main+0x55>
cmp    $0x50,%eax
je     118b <main+0x1b>
cmp    $0xffffffff,%eax
je     11ca <main+0x5a>
xor    %eax,%eax
call   1070 <usage@plt>
jmp    11a0 <main+0x30>
xor    %r15d,%r15d
jmp    11a0 <main+0x30>
mov    0x2e17(%rip),%rax
cmp    %ebp,(%rax)
je     11dc <main+0x6c>
xor    %eax,%eax
call   1070 <usage@plt>
test   %r15d,%r15d
jne    11ed <main+0x7d>
xor    %eax,%eax
call   1040 <getcwd_logical@plt>
test   %rax,%rax
jne    1213 <main+0xa3>
xor    %edi,%edi
xor    %esi,%esi
call   1050 <getcwd@plt>
test   %rax,%rax
jne    1213 <main+0xa3>
lea    0xe05(%rip),%rsi
mov    $0x1,%edi
call   1060 <err@plt>
xor    %edi,%edi
call   1090 <exit@plt>
lea    0xde9(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"LP\00"
@optind = global i64 0
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [2 x i8] c".\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 i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
br label %9
9: ; preds = %21, %2
%10 = load i32, i32* %4
%11 = load i8**, i8*** %5
%12 = call i32 @getopt(i32 %10, i8** %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 %12, i32* %7
%13 = icmp ne i32 %12, -1
br i1 %13, label %14, label %22
14: ; preds = %9
%15 = load i32, i32* %7
switch i32 %15, label %19 [
i32 76, label %16
i32 80, label %17
i32 63, label %18
]
16: ; preds = %14
store i32 0, i32* %6
br label %21
17: ; preds = %14
store i32 1, i32* %6
br label %21
18: ; preds = %14
br label %19
19: ; preds = %14, %18
%20 = call i32 (...) @usage()
br label %21
21: ; preds = %19, %17, %16
br label %9
22: ; preds = %9
%23 = load i64, i64* @optind
%24 = load i32, i32* %4
%25 = sext i32 %24 to i64
%26 = sub nsw i64 %25, %23
%27 = trunc i64 %26 to i32
store i32 %27, i32* %4
%28 = load i64, i64* @optind
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 %28
store i8** %30, i8*** %5
%31 = load i32, i32* %4
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %22
%34 = call i32 (...) @usage()
br label %35
35: ; preds = %33, %22
%36 = load i32, i32* %6
%37 = icmp ne i32 %36, 0
br i1 %37, label %41, label %38
38: ; preds = %35
%39 = call i8* (...) @getcwd_logical()
store i8* %39, i8** %8
%40 = icmp ne i8* %39, null
br i1 %40, label %44, label %41
41: ; preds = %38, %35
%42 = call i8* @getcwd(i32* null, i32 0)
store i8* %42, i8** %8
%43 = icmp ne i8* %42, null
br i1 %43, label %44, label %47
44: ; preds = %41, %38
%45 = load i8*, i8** %8
%46 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %45)
br label %49
47: ; preds = %41
%48 = call i32 @err(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %49
49: ; preds = %47, %44
%50 = call i32 @exit(i32 0)
unreachable
}

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