#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 errno;
int /*<<< orphan*/ printf(char *, ...);
int unlink(char *);
int main(int argc, char **argv) {
  if (argc < 2) {
    printf("rm: missing operand\n");
    return -1;
  }
  int r = 0;
  for (int i = 1; i < argc; i++) {
    if ((r = unlink(argv[i])) < 0) {
      printf("rm error: %d\n", errno);
      return -errno;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    115a <main+0x3a>
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d5 <main+0xb5>
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11ce <main+0xae>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <unlink@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    11bb <main+0x9b>
mov    0x2e48(%rip),%rax
mov    (%rax),%esi
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
mov    0x2e2f(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    11d5 <main+0xb5>
jmp    11c0 <main+0xa0>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1168 <main+0x48>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
cmp    $0x2,%edi
jge    114d <main+0x1d>
lea    0xecd(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%ebx
jmp    1197 <main+0x67>
mov    %rsi,%r14
mov    %edi,%r15d
mov    $0x1,%ebx
nopl   0x0(%rax,%rax,1)
mov    (%r14,%rbx,8),%rdi
call   1030 <unlink@plt>
test   %eax,%eax
js     117a <main+0x4a>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1160 <main+0x30>
xor    %ebx,%ebx
jmp    1197 <main+0x67>
mov    0x2e5f(%rip),%r14
mov    (%r14),%esi
lea    0xe75(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <printf@plt>
sub    (%r14),%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [21 x i8] c"rm: missing operand\0A\00"
@.str.1 = [14 x i8] c"rm error: %d\0A\00"
@errno = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %35
12: ; preds = %2
store i32 0, i32* %6
store i32 1, i32* %7
br label %13
13: ; preds = %31, %12
%14 = load i32, i32* %7
%15 = load i32, i32* %4
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %34
17: ; preds = %13
%18 = load i8**, i8*** %5
%19 = load i32, i32* %7
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8*, i8** %18, i64 %20
%22 = load i8*, i8** %21
%23 = call i32 @unlink(i8* %22)
store i32 %23, i32* %6
%24 = icmp slt i32 %23, 0
br i1 %24, label %25, label %30
25: ; preds = %17
%26 = load i32, i32* @errno
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %26)
%28 = load i32, i32* @errno
%29 = sub nsw i32 0, %28
store i32 %29, i32* %3
br label %35
30: ; preds = %17
br label %31
31: ; preds = %30
%32 = load i32, i32* %7
%33 = add nsw i32 %32, 1
store i32 %33, i32* %7
br label %13
34: ; preds = %13
store i32 0, i32* %3
br label %35
35: ; preds = %34, %25, %10
%36 = load i32, i32* %3
ret i32 %36
}

LLVM IR (-O2):
@.str.1 = [14 x i8] c"rm error: %d\0A\00"
@errno = global i32 0
@str = [20 x i8] c"rm: missing operand\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %10
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
br label %22
8: ; preds = %10
%9 = icmp eq i64 %16, %5
br i1 %9, label %22, label %10
10: ; preds = %4, %8
%11 = phi i64 [ 1, %4 ], [ %16, %8 ]
%12 = getelementptr inbounds i8*, i8** %1, i64 %11
%13 = load i8*, i8** %12
%14 = tail call i32 @unlink(i8* %13)
%15 = icmp slt i32 %14, 0
%16 = add nuw nsw i64 %11, 1
br i1 %15, label %17, label %8
17: ; preds = %10
%18 = load i32, i32* @errno
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = load i32, i32* @errno
%21 = sub nsw i32 0, %20
br label %22
22: ; preds = %8, %17, %6
%23 = phi i32 [ -1, %6 ], [ %21, %17 ], [ 0, %8 ]
ret i32 %23
}