#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*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ free(char *);
char *get_current_dir();
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
int internal_pwd(int argc, char **argv) {
  if (argc > 1) {
    fprintf(stderr, "Philsh : Option inconue : %s\n", argv[1]);
    return 2;
  }
  char *current_dir;
  current_dir = get_current_dir();
  assert(current_dir != NULL);
  printf("%s\n", current_dir);
  free(current_dir);
  return 0;
}


x86 assembly (clang, -O0):
<internal_pwd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1192 <internal_pwd+0x42>
mov    0x2e70(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe7f(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    11cf <internal_pwd+0x7f>
mov    $0x0,%al
call   1040 <get_current_dir@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x18(%rbp),%rsi
lea    0xe60(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<internal_pwd>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x2,%edi
jl     1178 <internal_pwd+0x28>
mov    0x2e81(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rsi),%rdx
lea    0xe94(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x2,%ebp
jmp    11a9 <internal_pwd+0x59>
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <get_current_dir@plt>
mov    %rax,%rbx
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1060 <assert@plt>
lea    0xe81(%rip),%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [30 x i8] c"Philsh : Option inconue : %s\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @internal_pwd(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp sgt i32 %7, 1
br i1 %8, label %9, label %15
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %13)
store i32 2, i32* %3
br label %25
15: ; preds = %2
%16 = call i8* (...) @get_current_dir()
store i8* %16, i8** %6
%17 = load i8*, i8** %6
%18 = icmp ne i8* %17, null
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = load i8*, i8** %6
%22 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %21)
%23 = load i8*, i8** %6
%24 = call i32 @free(i8* %23)
store i32 0, i32* %3
br label %25
25: ; preds = %15, %9
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [30 x i8] c"Philsh : Option inconue : %s\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @internal_pwd(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %7)
br label %16
9: ; preds = %2
%10 = tail call i8* (...) @get_current_dir()
%11 = icmp ne i8* %10, null
%12 = zext i1 %11 to i32
%13 = tail call i32 @assert(i32 %12)
%14 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%15 = tail call i32 @free(i8* %10)
br label %16
16: ; preds = %9, %4
%17 = phi i32 [ 2, %4 ], [ 0, %9 ]
ret i32 %17
}