#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 */
scalar_t__ DOcmdcheck();
int DOcommand(char *, char *);
int DOpwd() {
  int s;
  if (DOcmdcheck())
    return (0);
  s = DOcommand("PWD", "");
  if (s == 500 || s == 502)
    s = DOcommand("XPWD", "");
  return (s);
}


x86 assembly (clang, -O0):
<DOpwd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1040 <DOcmdcheck@plt>
cmp    $0x0,%rax
je     1145 <DOpwd+0x25>
movl   $0x0,-0x4(%rbp)
jmp    1191 <DOpwd+0x71>
lea    0xeb5(%rip),%rdi
lea    0xeb1(%rip),%rsi
call   1030 <DOcommand@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x1f4,-0x8(%rbp)
je     1175 <DOpwd+0x55>
cmpl   $0x1f6,-0x8(%rbp)
jne    118b <DOpwd+0x6b>
lea    0xe84(%rip),%rdi
lea    0xe81(%rip),%rsi
call   1030 <DOcommand@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DOpwd>:
push   %rbx
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <DOcmdcheck@plt>
test   %rax,%rax
jne    1162 <DOpwd+0x42>
lea    0xecb(%rip),%rdi
lea    0xec7(%rip),%rsi
call   1030 <DOcommand@plt>
mov    %eax,%ebx
and    $0xfffffffd,%eax
cmp    $0x1f4,%eax
jne    1162 <DOpwd+0x42>
lea    0xeab(%rip),%rdi
lea    0xea8(%rip),%rsi
pop    %rbx
jmp    1030 <DOcommand@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"PWD\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [5 x i8] c"XPWD\00"
define i32 @DOpwd() {
%1 = alloca i32
%2 = alloca i32
%3 = call i64 (...) @DOcmdcheck()
%4 = icmp ne i64 %3, 0
br i1 %4, label %5, label %6
5: ; preds = %0
store i32 0, i32* %1
br label %17
6: ; preds = %0
%7 = call i32 @DOcommand(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
store i32 %7, i32* %2
%8 = load i32, i32* %2
%9 = icmp eq i32 %8, 500
br i1 %9, label %13, label %10
10: ; preds = %6
%11 = load i32, i32* %2
%12 = icmp eq i32 %11, 502
br i1 %12, label %13, label %15
13: ; preds = %10, %6
%14 = call i32 @DOcommand(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
store i32 %14, i32* %2
br label %15
15: ; preds = %13, %10
%16 = load i32, i32* %2
store i32 %16, i32* %1
br label %17
17: ; preds = %15, %5
%18 = load i32, i32* %1
ret i32 %18
}

LLVM IR (-O2):
@.str = [4 x i8] c"PWD\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [5 x i8] c"XPWD\00"
define i32 @DOpwd() {
%1 = tail call i64 (...) @DOcmdcheck()
%2 = icmp eq i64 %1, 0
br i1 %2, label %3, label %9
3: ; preds = %0
%4 = tail call i32 @DOcommand(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%5 = and i32 %4, -3
%6 = icmp eq i32 %5, 500
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = tail call i32 @DOcommand(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
br label %9
9: ; preds = %7, %3, %0
%10 = phi i32 [ 0, %0 ], [ %8, %7 ], [ %4, %3 ]
ret i32 %10
}