#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 /*<<< orphan*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ LC_ALL;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ find_directory(char *);
int /*<<< orphan*/ setlocale(int /*<<< orphan*/, char *);
int main(int argc, char *argv[]) {
  setlocale(LC_ALL, "");
  int i = 1;
  while (i < argc) {
    if (!find_directory(argv[i]))
      exit(EXIT_FAILURE);
    i++;
  }
  if (argc == 1)
    find_directory(".");
  return EXIT_SUCCESS;
}


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)
mov    0x2e83(%rip),%rax
mov    (%rax),%edi
lea    0xeab(%rip),%rsi
call   1040 <setlocale@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11a4 <main+0x74>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <find_directory@plt>
cmp    $0x0,%eax
jne    1196 <main+0x66>
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1162 <main+0x32>
cmpl   $0x1,-0x8(%rbp)
jne    11ba <main+0x8a>
lea    0xe4b(%rip),%rdi
call   1030 <find_directory@plt>
mov    0x2e17(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %edi,%r14d
mov    0x2e8c(%rip),%rax
mov    (%rax),%edi
lea    0xeb4(%rip),%rsi
call   1040 <setlocale@plt>
cmp    $0x2,%r14d
jl     1176 <main+0x46>
mov    %r14d,%ebp
mov    $0x1,%ebx
mov    (%r15,%rbx,8),%rdi
call   1030 <find_directory@plt>
test   %eax,%eax
je     119c <main+0x6c>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1160 <main+0x30>
cmp    $0x1,%r14d
jne    1188 <main+0x58>
lea    0xe7d(%rip),%rdi
call   1030 <find_directory@plt>
mov    0x2e49(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2e3d(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@LC_ALL = global i32 0
@.str = [1 x i8] zeroinitializer
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c".\00"
@EXIT_SUCCESS = global i32 0
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 = load i32, i32* @LC_ALL
%8 = call i32 @setlocale(i32 %7, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %6
br label %9
9: ; preds = %24, %2
%10 = load i32, i32* %6
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %27
13: ; preds = %9
%14 = load i8**, i8*** %5
%15 = load i32, i32* %6
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8*, i8** %14, i64 %16
%18 = load i8*, i8** %17
%19 = call i32 @find_directory(i8* %18)
%20 = icmp ne i32 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %13
%22 = load i32, i32* @EXIT_FAILURE
%23 = call i32 @exit(i32 %22)
unreachable
24: ; preds = %13
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 1
store i32 %26, i32* %6
br label %9
27: ; preds = %9
%28 = load i32, i32* %4
%29 = icmp eq i32 %28, 1
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = call i32 @find_directory(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %32
32: ; preds = %30, %27
%33 = load i32, i32* @EXIT_SUCCESS
ret i32 %33
}

LLVM IR (-O2):
@LC_ALL = global i32 0
@.str = [1 x i8] zeroinitializer
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c".\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = load i32, i32* @LC_ALL
%4 = tail call i32 @setlocale(i32 %3, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %20
6: ; preds = %2
%7 = zext i32 %0 to i64
br label %10
8: ; preds = %10
%9 = icmp eq i64 %16, %7
br i1 %9, label %20, label %10
10: ; preds = %6, %8
%11 = phi i64 [ 1, %6 ], [ %16, %8 ]
%12 = getelementptr inbounds i8*, i8** %1, i64 %11
%13 = load i8*, i8** %12
%14 = tail call i32 @find_directory(i8* %13)
%15 = icmp eq i32 %14, 0
%16 = add nuw nsw i64 %11, 1
br i1 %15, label %17, label %8
17: ; preds = %10
%18 = load i32, i32* @EXIT_FAILURE
%19 = tail call i32 @exit(i32 %18)
unreachable
20: ; preds = %8, %2
%21 = icmp eq i32 %0, 1
br i1 %21, label %22, label %24
22: ; preds = %20
%23 = tail call i32 @find_directory(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %24
24: ; preds = %22, %20
%25 = load i32, i32* @EXIT_SUCCESS
ret i32 %25
}