#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 */
struct stat {
  int /*<<< orphan*/ st_mode;
};

/* Variables and functions */
scalar_t__ S_ISDIR(int /*<<< orphan*/);
int /*<<< orphan*/ pyi_remove_temp_path(char *);
scalar_t__ stat(char *, struct stat *);
int /*<<< orphan*/ strcat(char *, char const *);
scalar_t__ strcmp(char const *, char *);
int /*<<< orphan*/ unlink(char *);
void remove_one(char *pnm, int pos, const char *fnm) {
  struct stat sbuf;
  if (strcmp(fnm, ".") == 0 || strcmp(fnm, "..") == 0)
    return;
  pnm[pos] = '\0';
  strcat(pnm, fnm);
  if (stat(pnm, &sbuf) == 0) {
    if (S_ISDIR(sbuf.st_mode))
      pyi_remove_temp_path(pnm);
    else
      unlink(pnm);
  }
}


x86 assembly (clang, -O0):
<remove_one>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe83(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     11a7 <remove_one+0x47>
mov    -0x18(%rbp),%rdi
lea    0xe68(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    11ac <remove_one+0x4c>
jmp    120a <remove_one+0xaa>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1080 <strcat@plt>
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1070 <stat@plt>
cmp    $0x0,%rax
jne    120a <remove_one+0xaa>
mov    -0x20(%rbp),%edi
call   1050 <S_ISDIR@plt>
cmp    $0x0,%rax
je     11fc <remove_one+0x9c>
mov    -0x8(%rbp),%rdi
call   1040 <pyi_remove_temp_path@plt>
jmp    1205 <remove_one+0xa5>
mov    -0x8(%rbp),%rdi
call   1030 <unlink@plt>
jmp    120a <remove_one+0xaa>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remove_one>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%rbx
mov    %esi,%ebp
mov    %rdi,%r14
lea    0xe8a(%rip),%rsi
mov    %rdx,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11da <remove_one+0x7a>
lea    0xe75(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11da <remove_one+0x7a>
movslq %ebp,%rax
movb   $0x0,(%r14,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1080 <strcat@plt>
lea    0x8(%rsp),%rsi
mov    %r14,%rdi
call   1070 <stat@plt>
test   %rax,%rax
jne    11da <remove_one+0x7a>
mov    0x8(%rsp),%edi
call   1050 <S_ISDIR@plt>
mov    %r14,%rdi
test   %rax,%rax
je     11d5 <remove_one+0x75>
call   1040 <pyi_remove_temp_path@plt>
jmp    11da <remove_one+0x7a>
call   1030 <unlink@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [2 x i8] c".\00"
@.str.1 = [3 x i8] c"..\00"
define void @remove_one(i8* %0, i32 %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca %struct.stat
store i8* %0, i8** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%8 = load i8*, i8** %6
%9 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %3
%12 = load i8*, i8** %6
%13 = call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %11, %3
br label %39
16: ; preds = %11
%17 = load i8*, i8** %4
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
store i8 0, i8* %20
%21 = load i8*, i8** %4
%22 = load i8*, i8** %6
%23 = call i32 @strcat(i8* %21, i8* %22)
%24 = load i8*, i8** %4
%25 = call i64 @stat(i8* %24, %struct.stat* %7)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %39
27: ; preds = %16
%28 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%29 = load i32, i32* %28
%30 = call i64 @S_ISDIR(i32 %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %27
%33 = load i8*, i8** %4
%34 = call i32 @pyi_remove_temp_path(i8* %33)
br label %38
35: ; preds = %27
%36 = load i8*, i8** %4
%37 = call i32 @unlink(i8* %36)
br label %38
38: ; preds = %35, %32
br label %39
39: ; preds = %15, %38, %16
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [2 x i8] c".\00"
@.str.1 = [3 x i8] c"..\00"
define void @remove_one(i8* %0, i32 %1, i8* %2) {
%4 = alloca %struct.stat
%5 = bitcast %struct.stat* %4 to i8*
%6 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %26, label %8
8: ; preds = %3
%9 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %26, label %11
11: ; preds = %8
%12 = sext i32 %1 to i64
%13 = getelementptr inbounds i8, i8* %0, i64 %12
store i8 0, i8* %13
%14 = tail call i32 @strcat(i8* %0, i8* %2)
%15 = call i64 @stat(i8* %0, %struct.stat* %4)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %26
17: ; preds = %11
%18 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 0
%19 = load i32, i32* %18
%20 = call i64 @S_ISDIR(i32 %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %17
%23 = call i32 @pyi_remove_temp_path(i8* %0)
br label %26
24: ; preds = %17
%25 = call i32 @unlink(i8* %0)
br label %26
26: ; preds = %11, %24, %22, %3, %8
ret void
}