#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 strcmp(char *, char *);
int /*<<< orphan*/ to_dirchars(char *, char *);
int /*<<< orphan*/ to_lower(char *, char *);
int strcmp_dirorder(char *s1, char *s2, int folding) {
  char a1[1000];
  char a2[1000];
  to_dirchars(s1, a1);
  to_dirchars(s2, a2);
  if (folding) {
    char b1[1000];
    char b2[1000];
    to_lower(a1, b1);
    to_lower(a2, b2);
    return strcmp(b1, b2);
  } else {
    return strcmp(a1, a2);
  }
}


x86 assembly (clang, -O0):
<strcmp_dirorder>:
push   %rbp
mov    %rsp,%rbp
sub    $0xfe0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x410(%rbp),%rsi
call   1050 <to_dirchars@plt>
mov    -0x18(%rbp),%rdi
lea    -0x800(%rbp),%rsi
call   1050 <to_dirchars@plt>
cmpl   $0x0,-0x1c(%rbp)
je     11b1 <strcmp_dirorder+0x81>
lea    -0x410(%rbp),%rdi
lea    -0xbf0(%rbp),%rsi
call   1030 <to_lower@plt>
lea    -0x800(%rbp),%rdi
lea    -0xfe0(%rbp),%rsi
call   1030 <to_lower@plt>
lea    -0xbf0(%rbp),%rdi
lea    -0xfe0(%rbp),%rsi
call   1040 <strcmp@plt>
mov    %eax,-0x4(%rbp)
jmp    11c7 <strcmp_dirorder+0x97>
lea    -0x410(%rbp),%rdi
lea    -0x800(%rbp),%rsi
call   1040 <strcmp@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xfe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strcmp_dirorder>:
push   %rbp
push   %rbx
sub    $0xfb8,%rsp
mov    %edx,%ebp
mov    %rsi,%rbx
lea    0x3f0(%rsp),%rsi
call   1050 <to_dirchars@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1050 <to_dirchars@plt>
lea    0x3f0(%rsp),%rdi
test   %ebp,%ebp
je     118d <strcmp_dirorder+0x5d>
lea    0xbd0(%rsp),%rbx
mov    %rbx,%rsi
call   1030 <to_lower@plt>
mov    %rsp,%rdi
lea    0x7e0(%rsp),%rbp
mov    %rbp,%rsi
call   1030 <to_lower@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
jmp    1190 <strcmp_dirorder+0x60>
mov    %rsp,%rsi
call   1040 <strcmp@plt>
add    $0xfb8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @strcmp_dirorder(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca [1000 x i8]
%9 = alloca [1000 x i8]
%10 = alloca [1000 x i8]
%11 = alloca [1000 x i8]
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%12 = load i8*, i8** %5
%13 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%14 = call i32 @to_dirchars(i8* %12, i8* %13)
%15 = load i8*, i8** %6
%16 = getelementptr inbounds [1000 x i8], [1000 x i8]* %9, i64 0, i64 0
%17 = call i32 @to_dirchars(i8* %15, i8* %16)
%18 = load i32, i32* %7
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %30
20: ; preds = %3
%21 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%22 = getelementptr inbounds [1000 x i8], [1000 x i8]* %10, i64 0, i64 0
%23 = call i32 @to_lower(i8* %21, i8* %22)
%24 = getelementptr inbounds [1000 x i8], [1000 x i8]* %9, i64 0, i64 0
%25 = getelementptr inbounds [1000 x i8], [1000 x i8]* %11, i64 0, i64 0
%26 = call i32 @to_lower(i8* %24, i8* %25)
%27 = getelementptr inbounds [1000 x i8], [1000 x i8]* %10, i64 0, i64 0
%28 = getelementptr inbounds [1000 x i8], [1000 x i8]* %11, i64 0, i64 0
%29 = call i32 @strcmp(i8* %27, i8* %28)
store i32 %29, i32* %4
br label %34
30: ; preds = %3
%31 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%32 = getelementptr inbounds [1000 x i8], [1000 x i8]* %9, i64 0, i64 0
%33 = call i32 @strcmp(i8* %31, i8* %32)
store i32 %33, i32* %4
br label %34
34: ; preds = %30, %20
%35 = load i32, i32* %4
ret i32 %35
}

LLVM IR (-O2):
define i32 @strcmp_dirorder(i8* %0, i8* %1, i32 %2) {
%4 = alloca [1000 x i8]
%5 = alloca [1000 x i8]
%6 = alloca [1000 x i8]
%7 = alloca [1000 x i8]
%8 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%9 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%10 = call i32 @to_dirchars(i8* %0, i8* %8)
%11 = call i32 @to_dirchars(i8* %1, i8* %9)
%12 = icmp eq i32 %2, 0
br i1 %12, label %19, label %13
13: ; preds = %3
%14 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%15 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%16 = call i32 @to_lower(i8* %8, i8* %14)
%17 = call i32 @to_lower(i8* %9, i8* %15)
%18 = call i32 @strcmp(i8* %14, i8* %15)
br label %21
19: ; preds = %3
%20 = call i32 @strcmp(i8* %8, i8* %9)
br label %21
21: ; preds = %19, %13
%22 = phi i32 [ %18, %13 ], [ %20, %19 ]
ret i32 %22
}