#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;
};
struct dirent {
  int d_ino;
  int /*<<< orphan*/ d_name;
};
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ *opendir(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int);
struct dirent *readdir(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(int /*<<< orphan*/, char *);
int main(int argc, char *argv[]) {
  char name_buf[1024];
  DIR *dir;
  struct dirent *dentry;
  struct stat file_info;
  int status = 0;
  if (argc <= 1) {
    fprintf(stderr, "%s: missing argument: dir\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  dir = opendir(argv[1]);
  if (!dir)
    do {
      perror("opendir");
      exit(EXIT_FAILURE);
    } while (0);
  for (;;) {
    dentry = readdir(dir);
    if (!dentry)
      break;
    if (strcmp(dentry->d_name, ".") && strcmp(dentry->d_name, ".."))
      printf("%d\n", dentry->d_ino);
  }
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x42c(%rbp)
cmpl   $0x1,-0x8(%rbp)
jg     11c7 <main+0x57>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe4c(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2e18(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <opendir@plt>
mov    %rax,-0x418(%rbp)
cmpq   $0x0,-0x418(%rbp)
jne    1208 <main+0x98>
jmp    11ee <main+0x7e>
lea    0xe26(%rip),%rdi
call   1080 <perror@plt>
mov    0x2dd7(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
jmp    120d <main+0x9d>
mov    -0x418(%rbp),%rdi
call   1070 <readdir@plt>
mov    %rax,-0x420(%rbp)
cmpq   $0x0,-0x420(%rbp)
jne    1233 <main+0xc3>
jmp    128d <main+0x11d>
mov    -0x420(%rbp),%rax
mov    0x4(%rax),%edi
lea    0xde0(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     1288 <main+0x118>
mov    -0x420(%rbp),%rax
mov    0x4(%rax),%edi
lea    0xdbf(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     1288 <main+0x118>
mov    -0x420(%rbp),%rax
mov    (%rax),%esi
lea    0xda3(%rip),%rdi
call   1040 <printf@plt>
jmp    120d <main+0x9d>
mov    0x2d3c(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
cmp    $0x1,%edi
jg     1198 <main+0x28>
mov    0x2e5b(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xe6f(%rip),%rsi
call   1060 <fprintf@plt>
jmp    11b2 <main+0x42>
mov    0x8(%rsi),%rdi
call   1030 <opendir@plt>
test   %rax,%rax
jne    11c0 <main+0x50>
lea    0xe6e(%rip),%rdi
call   1080 <perror@plt>
mov    0x2e1f(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    %rax,%r13
mov    %rax,%rdi
call   1070 <readdir@plt>
test   %rax,%rax
jne    11de <main+0x6e>
mov    0x2df9(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    %rax,%rbx
lea    0xe3c(%rip),%r14
lea    0xe34(%rip),%r15
lea    0xe30(%rip),%r12
jmp    1210 <main+0xa0>
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
call   1070 <readdir@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11d0 <main+0x60>
mov    0x4(%rbx),%edi
mov    %r14,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1200 <main+0x90>
mov    0x4(%rbx),%edi
mov    %r15,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1200 <main+0x90>
mov    (%rbx),%esi
mov    %r12,%rdi
call   1040 <printf@plt>
jmp    1200 <main+0x90>

LLVM IR (-O0):
%struct.dirent = type { i32, i32 }
%struct.stat = type { i32 }
@stderr = global i32 0
@.str = [27 x i8] c"%s: missing argument: dir\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [8 x i8] c"opendir\00"
@.str.2 = [2 x i8] c".\00"
@.str.3 = [3 x i8] c"..\00"
@.str.4 = [4 x i8] c"%d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1024 x i8]
%7 = alloca i32*
%8 = alloca %struct.dirent*
%9 = alloca %struct.stat
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %10
%11 = load i32, i32* %4
%12 = icmp sle i32 %11, 1
br i1 %12, label %13, label %21
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = load i32, i32* @EXIT_FAILURE
%20 = call i32 @exit(i32 %19)
unreachable
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32* @opendir(i8* %24)
store i32* %25, i32** %7
%26 = load i32*, i32** %7
%27 = icmp ne i32* %26, null
br i1 %27, label %34, label %28
28: ; preds = %21
br label %29
29: ; preds = %28
%30 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%31 = load i32, i32* @EXIT_FAILURE
%32 = call i32 @exit(i32 %31)
unreachable
33: ; No predecessors!
br label %34
34: ; preds = %33, %21
br label %35
35: ; preds = %58, %34
%36 = load i32*, i32** %7
%37 = call %struct.dirent* @readdir(i32* %36)
store %struct.dirent* %37, %struct.dirent** %8
%38 = load %struct.dirent*, %struct.dirent** %8
%39 = icmp ne %struct.dirent* %38, null
br i1 %39, label %41, label %40
40: ; preds = %35
br label %59
41: ; preds = %35
%42 = load %struct.dirent*, %struct.dirent** %8
%43 = getelementptr inbounds %struct.dirent, %struct.dirent* %42, i32 0, i32 1
%44 = load i32, i32* %43
%45 = call i64 @strcmp(i32 %44, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%46 = icmp ne i64 %45, 0
br i1 %46, label %47, label %58
47: ; preds = %41
%48 = load %struct.dirent*, %struct.dirent** %8
%49 = getelementptr inbounds %struct.dirent, %struct.dirent* %48, i32 0, i32 1
%50 = load i32, i32* %49
%51 = call i64 @strcmp(i32 %50, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%52 = icmp ne i64 %51, 0
br i1 %52, label %53, label %58
53: ; preds = %47
%54 = load %struct.dirent*, %struct.dirent** %8
%55 = getelementptr inbounds %struct.dirent, %struct.dirent* %54, i32 0, i32 0
%56 = load i32, i32* %55
%57 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %56)
br label %58
58: ; preds = %53, %47, %41
br label %35
59: ; preds = %40
%60 = load i32, i32* @EXIT_SUCCESS
%61 = call i32 @exit(i32 %60)
unreachable
}

LLVM IR (-O2):
%struct.dirent = type { i32, i32 }
@stderr = global i32 0
@.str = [27 x i8] c"%s: missing argument: dir\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [8 x i8] c"opendir\00"
@.str.2 = [2 x i8] c".\00"
@.str.3 = [3 x i8] c"..\00"
@.str.4 = [4 x i8] c"%d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %10
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = load i32, i32* @EXIT_FAILURE
%9 = tail call i32 @exit(i32 %8)
unreachable
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32* @opendir(i8* %12)
%14 = icmp eq i32* %13, null
br i1 %14, label %18, label %15
15: ; preds = %10
%16 = tail call %struct.dirent* @readdir(i32* %13)
%17 = icmp eq %struct.dirent* %16, null
br i1 %17, label %39, label %22
18: ; preds = %10
%19 = tail call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%20 = load i32, i32* @EXIT_FAILURE
%21 = tail call i32 @exit(i32 %20)
unreachable
22: ; preds = %15, %36
%23 = phi %struct.dirent* [ %37, %36 ], [ %16, %15 ]
%24 = getelementptr inbounds %struct.dirent, %struct.dirent* %23, i64 0, i32 1
%25 = load i32, i32* %24
%26 = tail call i64 @strcmp(i32 %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %36, label %28
28: ; preds = %22
%29 = load i32, i32* %24
%30 = tail call i64 @strcmp(i32 %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %36, label %32
32: ; preds = %28
%33 = getelementptr inbounds %struct.dirent, %struct.dirent* %23, i64 0, i32 0
%34 = load i32, i32* %33
%35 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %34)
br label %36
36: ; preds = %32, %28, %22
%37 = tail call %struct.dirent* @readdir(i32* %13)
%38 = icmp eq %struct.dirent* %37, null
br i1 %38, label %39, label %22
39: ; preds = %36, %15
%40 = load i32, i32* @EXIT_SUCCESS
%41 = tail call i32 @exit(i32 %40)
unreachable
}