#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 dummy;
};

/* Variables and functions */
int /*<<< orphan*/ STDERR_FILENO;
int /*<<< orphan*/ lstat(char *, struct stat *);
int strlen(char *);
scalar_t__ unlink(char *);
int /*<<< orphan*/ write(int /*<<< orphan*/, char *, int);
int main(int argc, char **argv) {
  int i;
  struct stat sbuf;
  int fd, er;
  for (i = 1; i < argc; i++) {
    if (argv[i][0] != '-') {
      if (!lstat(argv[i], &sbuf)) {
        if (unlink(argv[i])) {
          write(STDERR_FILENO, "rm: could not remove ", 21);
          write(STDERR_FILENO, argv[i], strlen(argv[i]));
          write(STDERR_FILENO, "\n", 1);
        }
      }
    }
  }
}


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    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1246 <main+0x106>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
je     1233 <main+0xf3>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x18(%rbp),%rsi
call   1060 <lstat@plt>
cmp    $0x0,%eax
jne    122e <main+0xee>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <unlink@plt>
cmp    $0x0,%rax
je     1229 <main+0xe9>
mov    0x2e1f(%rip),%rax
mov    (%rax),%edi
lea    0xe36(%rip),%rsi
mov    $0x15,%edx
call   1040 <write@plt>
mov    0x2e05(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <strlen@plt>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    0x2dca(%rip),%rax
mov    (%rax),%edi
lea    0xdf7(%rip),%rsi
mov    $0x1,%edx
call   1040 <write@plt>
jmp    122e <main+0xee>
jmp    1233 <main+0xf3>
jmp    1238 <main+0xf8>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115d <main+0x1d>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jl     11ec <main+0xac>
mov    %rsi,%rbx
mov    %edi,%r15d
mov    $0x1,%r12d
mov    %rsp,%rbp
jmp    1179 <main+0x39>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%r12
cmp    %r12,%r15
je     11ec <main+0xac>
mov    (%rbx,%r12,8),%rdi
cmpb   $0x2d,(%rdi)
je     1170 <main+0x30>
mov    %rbp,%rsi
call   1060 <lstat@plt>
test   %eax,%eax
jne    1170 <main+0x30>
mov    (%rbx,%r12,8),%rdi
call   1030 <unlink@plt>
test   %rax,%rax
je     1170 <main+0x30>
mov    0x2e3d(%rip),%r14
mov    (%r14),%edi
lea    0xe53(%rip),%rsi
mov    $0x15,%edx
call   1040 <write@plt>
mov    (%r14),%r13d
mov    (%rbx,%r12,8),%rbp
mov    %rbp,%rdi
call   1050 <strlen@plt>
mov    %r13d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    (%r14),%edi
mov    %rsp,%rbp
lea    0xe36(%rip),%rsi
mov    $0x1,%edx
call   1040 <write@plt>
jmp    1170 <main+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@STDERR_FILENO = global i32 0
@.str = [22 x i8] c"rm: could not remove \00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.stat
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
br label %10
10: ; preds = %61, %2
%11 = load i32, i32* %6
%12 = load i32, i32* %4
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %64
14: ; preds = %10
%15 = load i8**, i8*** %5
%16 = load i32, i32* %6
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8*, i8** %15, i64 %17
%19 = load i8*, i8** %18
%20 = getelementptr inbounds i8, i8* %19, i64 0
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 45
br i1 %23, label %24, label %60
24: ; preds = %14
%25 = load i8**, i8*** %5
%26 = load i32, i32* %6
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8*, i8** %25, i64 %27
%29 = load i8*, i8** %28
%30 = call i32 @lstat(i8* %29, %struct.stat* %7)
%31 = icmp ne i32 %30, 0
br i1 %31, label %59, label %32
32: ; preds = %24
%33 = load i8**, i8*** %5
%34 = load i32, i32* %6
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8*, i8** %33, i64 %35
%37 = load i8*, i8** %36
%38 = call i64 @unlink(i8* %37)
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %58
40: ; preds = %32
%41 = load i32, i32* @STDERR_FILENO
%42 = call i32 @write(i32 %41, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 21)
%43 = load i32, i32* @STDERR_FILENO
%44 = load i8**, i8*** %5
%45 = load i32, i32* %6
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8*, i8** %44, i64 %46
%48 = load i8*, i8** %47
%49 = load i8**, i8*** %5
%50 = load i32, i32* %6
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8*, i8** %49, i64 %51
%53 = load i8*, i8** %52
%54 = call i32 @strlen(i8* %53)
%55 = call i32 @write(i32 %43, i8* %48, i32 %54)
%56 = load i32, i32* @STDERR_FILENO
%57 = call i32 @write(i32 %56, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
br label %58
58: ; preds = %40, %32
br label %59
59: ; preds = %58, %24
br label %60
60: ; preds = %59, %14
br label %61
61: ; preds = %60
%62 = load i32, i32* %6
%63 = add nsw i32 %62, 1
store i32 %63, i32* %6
br label %10
64: ; preds = %10
%65 = load i32, i32* %3
ret i32 %65
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@STDERR_FILENO = global i32 0
@.str = [22 x i8] c"rm: could not remove \00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %3 to i8*
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %33
6: ; preds = %2
%7 = zext i32 %0 to i64
br label %8
8: ; preds = %6, %30
%9 = phi i64 [ 1, %6 ], [ %31, %30 ]
%10 = getelementptr inbounds i8*, i8** %1, i64 %9
%11 = load i8*, i8** %10
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 45
br i1 %13, label %30, label %14
14: ; preds = %8
%15 = call i32 @lstat(i8* %11, %struct.stat* %3)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %30
17: ; preds = %14
%18 = load i8*, i8** %10
%19 = tail call i64 @unlink(i8* %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %30, label %21
21: ; preds = %17
%22 = load i32, i32* @STDERR_FILENO
%23 = tail call i32 @write(i32 %22, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 21)
%24 = load i32, i32* @STDERR_FILENO
%25 = load i8*, i8** %10
%26 = tail call i32 @strlen(i8* %25)
%27 = tail call i32 @write(i32 %24, i8* %25, i32 %26)
%28 = load i32, i32* @STDERR_FILENO
%29 = tail call i32 @write(i32 %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
br label %30
30: ; preds = %8, %17, %21, %14
%31 = add nuw nsw i64 %9, 1
%32 = icmp eq i64 %31, %7
br i1 %32, label %33, label %8
33: ; preds = %30, %2
ret i32 0
}