#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 PATH_MAX;
int /*<<< orphan*/ err(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
char *getcwd(char *, int);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  char cwd[PATH_MAX];
  char *p;
  if (argc > 1) {
    fprintf(stderr, "usage: pwd\n");
    exit(1);
  }
  if ((p = getcwd(cwd, PATH_MAX)) == NULL) {
    err(1, NULL);
    exit(1);
  }
  puts(p);
  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)
mov    0x2e83(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    11bb <main+0x6b>
mov    0x2e35(%rip),%rax
mov    (%rax),%edi
lea    0xe54(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x30(%rbp),%rdi
mov    0x2e2a(%rip),%rax
mov    (%rax),%esi
call   1040 <getcwd@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    11f3 <main+0xa3>
mov    $0x1,%edi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <err@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x28(%rbp),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,%eax
mov    0x2e93(%rip),%rcx
mov    (%rcx),%esi
mov    %rsp,%rdi
lea    0xf(%rsi),%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%rdi
mov    %rdi,%rsp
cmp    $0x2,%eax
jl     1194 <main+0x44>
mov    0x2e5c(%rip),%rax
mov    (%rax),%edi
lea    0xe7b(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
call   1040 <getcwd@plt>
test   %rax,%rax
jne    11b4 <main+0x64>
mov    $0x1,%edi
xor    %esi,%esi
call   1060 <err@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    %rax,%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@PATH_MAX = global i32 0
@stderr = global i32 0
@.str = [12 x i8] c"usage: pwd\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* @PATH_MAX
%10 = zext i32 %9 to i64
%11 = call i8* @llvm.stacksave()
store i8* %11, i8** %6
%12 = alloca i8, i64 %10
store i64 %10, i64* %7
%13 = load i32, i32* %4
%14 = icmp sgt i32 %13, 1
br i1 %14, label %15, label %19
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %2
%20 = load i32, i32* @PATH_MAX
%21 = call i8* @getcwd(i8* %12, i32 %20)
store i8* %21, i8** %8
%22 = icmp eq i8* %21, null
br i1 %22, label %23, label %26
23: ; preds = %19
%24 = call i32 @err(i32 1, i32* null)
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %19
%27 = load i8*, i8** %8
%28 = call i32 @puts(i8* %27)
%29 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@PATH_MAX = global i32 0
@stderr = global i32 0
@.str = [12 x i8] c"usage: pwd\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @PATH_MAX
%4 = zext i32 %3 to i64
%5 = alloca i8, i64 %4
%6 = icmp sgt i32 %0, 1
br i1 %6, label %7, label %11
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %2
%12 = call i8* @getcwd(i8* %5, i32 %3)
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = call i32 @err(i32 1, i32* null)
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %11
%18 = call i32 @puts(i8* %12)
%19 = call i32 @exit(i32 0)
unreachable
}