#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__ chdir(char *);
scalar_t__ chroot(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ unlink(char *);
int main(int argc, char *argv[]) {
  int i;
  if (chdir("/var/lib/update-notifier/user.d") < 0) {
    perror("chdir");
    exit(1);
  }
  if (chroot("/var/lib/update-notifier/user.d") < 0) {
    perror("chroot");
    exit(1);
  }
  for (i = 1; i < argc; i++) {
    unlink(argv[i]);
  }
  exit(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)
lea    0xe93(%rip),%rdi
call   1050 <chdir@plt>
cmp    $0x0,%rax
jge    1192 <main+0x42>
lea    0xe9d(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
lea    0xe67(%rip),%rdi
call   1040 <chroot@plt>
cmp    $0x0,%rax
jge    11be <main+0x6e>
lea    0xe77(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11f0 <main+0xa0>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <unlink@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11c5 <main+0x75>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %edi,%ebp
lea    0xea0(%rip),%rdi
call   1050 <chdir@plt>
test   %rax,%rax
jns    1173 <main+0x23>
lea    0xeaf(%rip),%rdi
jmp    118b <main+0x3b>
lea    0xe86(%rip),%rdi
call   1040 <chroot@plt>
test   %rax,%rax
jns    119a <main+0x4a>
lea    0xe9b(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
cmp    $0x2,%ebp
jl     11c2 <main+0x72>
mov    %ebp,%ebp
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    (%r14,%rbx,8),%rdi
call   1030 <unlink@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    11b0 <main+0x60>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [32 x i8] c"/var/lib/update-notifier/user.d\00"
@.str.1 = [6 x i8] c"chdir\00"
@.str.2 = [7 x i8] c"chroot\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i64 @chdir(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%8 = icmp slt i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @exit(i32 1)
unreachable
12: ; preds = %2
%13 = call i64 @chroot(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %12
store i32 1, i32* %6
br label %19
19: ; preds = %30, %18
%20 = load i32, i32* %6
%21 = load i32, i32* %4
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %33
23: ; preds = %19
%24 = load i8**, i8*** %5
%25 = load i32, i32* %6
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8*, i8** %24, i64 %26
%28 = load i8*, i8** %27
%29 = call i32 @unlink(i8* %28)
br label %30
30: ; preds = %23
%31 = load i32, i32* %6
%32 = add nsw i32 %31, 1
store i32 %32, i32* %6
br label %19
33: ; preds = %19
%34 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [32 x i8] c"/var/lib/update-notifier/user.d\00"
@.str.1 = [6 x i8] c"chdir\00"
@.str.2 = [7 x i8] c"chroot\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i64 @chdir(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%4 = icmp slt i64 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %2
%9 = tail call i64 @chroot(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%10 = icmp slt i64 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %8
%12 = icmp sgt i32 %0, 1
br i1 %12, label %13, label %25
13: ; preds = %11
%14 = zext i32 %0 to i64
br label %18
15: ; preds = %8
%16 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%17 = tail call i32 @exit(i32 1)
unreachable
18: ; preds = %13, %18
%19 = phi i64 [ 1, %13 ], [ %23, %18 ]
%20 = getelementptr inbounds i8*, i8** %1, i64 %19
%21 = load i8*, i8** %20
%22 = tail call i32 @unlink(i8* %21)
%23 = add nuw nsw i64 %19, 1
%24 = icmp eq i64 %23, %14
br i1 %24, label %25, label %18
25: ; preds = %18, %11
%26 = tail call i32 @exit(i32 0)
unreachable
}