#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 */
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int emptydir(int /*<<< orphan*/ *);
int /*<<< orphan*/ error(char *, char *, char *);
int /*<<< orphan*/ *opendir(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ usage(char *);
int main(int argc, char **argv) {
  DIR *dp;
  int arg;
  char *prog_name;
  prog_name = argv[0];
  if (argc < 2) {
    usage(prog_name);
    return 1;
  }
  for (arg = 1; arg < argc; arg++) {
    dp = opendir(argv[arg]);
    if (dp == NULL)
      error("%s: Error when opening `%s'", prog_name, argv[arg]);
    else {
      int result = emptydir(dp);
      closedir(dp);
      if (result)
        printf("`%s' is empty.\n", argv[arg]);
      else
        printf("`%s' is not empty.\n", argv[arg]);
    }
  }
  return 0;
}


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)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11a0 <main+0x40>
mov    -0x28(%rbp),%rdi
call   1070 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    1267 <main+0x107>
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1260 <main+0x100>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <opendir@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11f4 <main+0x94>
mov    -0x28(%rbp),%rsi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe16(%rip),%rdi
call   1080 <error@plt>
jmp    124d <main+0xed>
mov    -0x18(%rbp),%rdi
call   1060 <emptydir@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <closedir@plt>
cmpl   $0x0,-0x2c(%rbp)
je     1230 <main+0xd0>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xdf6(%rip),%rdi
call   1040 <printf@plt>
jmp    1248 <main+0xe8>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xde9(%rip),%rdi
call   1040 <printf@plt>
jmp    124d <main+0xed>
jmp    1252 <main+0xf2>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a7 <main+0x47>
movl   $0x0,-0x4(%rbp)
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
mov    (%rsi),%r14
cmp    $0x2,%edi
jge    1182 <main+0x22>
mov    %r14,%rdi
call   1070 <usage@plt>
mov    $0x1,%eax
jmp    1200 <main+0xa0>
mov    %rsi,%rbx
mov    %edi,%r15d
mov    $0x1,%r13d
jmp    11ac <main+0x4c>
mov    (%rbx,%r13,8),%rdx
lea    0xe65(%rip),%rdi
mov    %r14,%rsi
call   1080 <error@plt>
add    $0x1,%r13
cmp    %r13,%r15
je     11fe <main+0x9e>
mov    (%rbx,%r13,8),%rdi
call   1030 <opendir@plt>
test   %rax,%rax
je     1190 <main+0x30>
mov    %rax,%rbp
mov    %rax,%rdi
call   1060 <emptydir@plt>
mov    %eax,%r12d
mov    %rbp,%rdi
call   1050 <closedir@plt>
mov    (%rbx,%r13,8),%rsi
test   %r12d,%r12d
je     11f0 <main+0x90>
lea    0xe3c(%rip),%rdi
jmp    11f7 <main+0x97>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0xe35(%rip),%rdi
call   1040 <printf@plt>
jmp    11a3 <main+0x43>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"%s: Error when opening `%s'\00"
@.str.1 = [16 x i8] c"`%s' is empty.\0A\00"
@.str.2 = [20 x i8] c"`%s' is not empty.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 0
%12 = load i8*, i8** %11
store i8* %12, i8** %8
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 2
br i1 %14, label %15, label %18
15: ; preds = %2
%16 = load i8*, i8** %8
%17 = call i32 @usage(i8* %16)
store i32 1, i32* %3
br label %67
18: ; preds = %2
store i32 1, i32* %7
br label %19
19: ; preds = %63, %18
%20 = load i32, i32* %7
%21 = load i32, i32* %4
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %66
23: ; preds = %19
%24 = load i8**, i8*** %5
%25 = load i32, i32* %7
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8*, i8** %24, i64 %26
%28 = load i8*, i8** %27
%29 = call i32* @opendir(i8* %28)
store i32* %29, i32** %6
%30 = load i32*, i32** %6
%31 = icmp eq i32* %30, null
br i1 %31, label %32, label %40
32: ; preds = %23
%33 = load i8*, i8** %8
%34 = load i8**, i8*** %5
%35 = load i32, i32* %7
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8*, i8** %34, i64 %36
%38 = load i8*, i8** %37
%39 = call i32 @error(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %33, i8* %38)
br label %62
40: ; preds = %23
%41 = load i32*, i32** %6
%42 = call i32 @emptydir(i32* %41)
store i32 %42, i32* %9
%43 = load i32*, i32** %6
%44 = call i32 @closedir(i32* %43)
%45 = load i32, i32* %9
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %54
47: ; preds = %40
%48 = load i8**, i8*** %5
%49 = load i32, i32* %7
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8*, i8** %48, i64 %50
%52 = load i8*, i8** %51
%53 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %52)
br label %61
54: ; preds = %40
%55 = load i8**, i8*** %5
%56 = load i32, i32* %7
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8*, i8** %55, i64 %57
%59 = load i8*, i8** %58
%60 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %59)
br label %61
61: ; preds = %54, %47
br label %62
62: ; preds = %61, %32
br label %63
63: ; preds = %62
%64 = load i32, i32* %7
%65 = add nsw i32 %64, 1
store i32 %65, i32* %7
br label %19
66: ; preds = %19
store i32 0, i32* %3
br label %67
67: ; preds = %66, %15
%68 = load i32, i32* %3
ret i32 %68
}

LLVM IR (-O2):
@.str = [28 x i8] c"%s: Error when opening `%s'\00"
@.str.1 = [16 x i8] c"`%s' is empty.\0A\00"
@.str.2 = [20 x i8] c"`%s' is not empty.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = load i8*, i8** %1
%4 = icmp slt i32 %0, 2
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = zext i32 %0 to i64
br label %9
7: ; preds = %2
%8 = tail call i32 @usage(i8* %3)
br label %30
9: ; preds = %5, %27
%10 = phi i64 [ 1, %5 ], [ %28, %27 ]
%11 = getelementptr inbounds i8*, i8** %1, i64 %10
%12 = load i8*, i8** %11
%13 = tail call i32* @opendir(i8* %12)
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %18
15: ; preds = %9
%16 = load i8*, i8** %11
%17 = tail call i32 @error(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %3, i8* %16)
br label %27
18: ; preds = %9
%19 = tail call i32 @emptydir(i32* %13)
%20 = tail call i32 @closedir(i32* %13)
%21 = icmp eq i32 %19, 0
%22 = load i8*, i8** %11
br i1 %21, label %25, label %23
23: ; preds = %18
%24 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %22)
br label %27
25: ; preds = %18
%26 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %22)
br label %27
27: ; preds = %23, %25, %15
%28 = add nuw nsw i64 %10, 1
%29 = icmp eq i64 %28, %6
br i1 %29, label %30, label %9
30: ; preds = %27, %7
%31 = phi i32 [ 1, %7 ], [ 0, %27 ]
ret i32 %31
}