#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*/ sscanf(char *, char *, char *, char *, char *);
int strcmp(char *, char *);
int strcoll(char *, char *);
int strcollcmp(char *a, char *b) {
  char a1[512], a2[512], a3[512];
  char b1[512], b2[512], b3[512];
  int order;
  a1[0] = a2[0] = a3[0] = '\0';
  sscanf(a, "%[^\t]\t%[^\t]\t%[^\t]", a1, a2, a3);
  b1[0] = b2[0] = b3[0] = '\0';
  sscanf(b, "%[^\t]\t%[^\t]\t%[^\t]", b1, b2, b3);
  order = strcoll(a1, b1);
  if (order == 0) {
    order = strcoll(a2, b2);
    if (order == 0) {
      order = strcoll(a3, b3);
      if (order == 0)
        order = strcmp(a, b);
    }
  }

  ;
  return order;
}


x86 assembly (clang, -O0):
<strcollcmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x0,-0x610(%rbp)
movb   $0x0,-0x410(%rbp)
movb   $0x0,-0x210(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x210(%rbp),%rdx
lea    -0x410(%rbp),%rcx
lea    -0x610(%rbp),%r8
lea    0xe88(%rip),%rsi
call   1040 <sscanf@plt>
movb   $0x0,-0xc10(%rbp)
movb   $0x0,-0xa10(%rbp)
movb   $0x0,-0x810(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x810(%rbp),%rdx
lea    -0xa10(%rbp),%rcx
lea    -0xc10(%rbp),%r8
lea    0xe4e(%rip),%rsi
call   1040 <sscanf@plt>
lea    -0x210(%rbp),%rdi
lea    -0x810(%rbp),%rsi
call   1050 <strcoll@plt>
mov    %eax,-0xc14(%rbp)
cmpl   $0x0,-0xc14(%rbp)
jne    1246 <strcollcmp+0x116>
lea    -0x410(%rbp),%rdi
lea    -0xa10(%rbp),%rsi
call   1050 <strcoll@plt>
mov    %eax,-0xc14(%rbp)
cmpl   $0x0,-0xc14(%rbp)
jne    1241 <strcollcmp+0x111>
lea    -0x610(%rbp),%rdi
lea    -0xc10(%rbp),%rsi
call   1050 <strcoll@plt>
mov    %eax,-0xc14(%rbp)
cmpl   $0x0,-0xc14(%rbp)
jne    123c <strcollcmp+0x10c>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcmp@plt>
mov    %eax,-0xc14(%rbp)
jmp    1241 <strcollcmp+0x111>
jmp    1246 <strcollcmp+0x116>
mov    -0xc14(%rbp),%eax
add    $0xc20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strcollcmp>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc00,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
movb   $0x0,0x400(%rsp)
movb   $0x0,0x600(%rsp)
movb   $0x0,0xa00(%rsp)
lea    0xe9b(%rip),%r13
lea    0xa00(%rsp),%r12
lea    0x600(%rsp),%rcx
lea    0x400(%rsp),%r8
mov    %r13,%rsi
mov    %r12,%rdx
call   1040 <sscanf@plt>
movb   $0x0,(%rsp)
movb   $0x0,0x200(%rsp)
movb   $0x0,0x800(%rsp)
lea    0x800(%rsp),%rbx
lea    0x200(%rsp),%rcx
mov    %rsp,%r8
mov    %r14,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1040 <sscanf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1050 <strcoll@plt>
test   %eax,%eax
jne    1204 <strcollcmp+0xd4>
lea    0x600(%rsp),%rdi
lea    0x200(%rsp),%rsi
call   1050 <strcoll@plt>
test   %eax,%eax
jne    1204 <strcollcmp+0xd4>
lea    0x400(%rsp),%rdi
mov    %rsp,%rsi
call   1050 <strcoll@plt>
test   %eax,%eax
jne    1204 <strcollcmp+0xd4>
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <strcmp@plt>
add    $0xc00,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [18 x i8] c"%[^\09]\09%[^\09]\09%[^\09]\00"
define i32 @strcollcmp(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [512 x i8]
%6 = alloca [512 x i8]
%7 = alloca [512 x i8]
%8 = alloca [512 x i8]
%9 = alloca [512 x i8]
%10 = alloca [512 x i8]
%11 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%12 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
store i8 0, i8* %12
%13 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
store i8 0, i8* %13
%14 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
store i8 0, i8* %14
%15 = load i8*, i8** %3
%16 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%17 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%18 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%19 = call i32 @sscanf(i8* %15, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %16, i8* %17, i8* %18)
%20 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
store i8 0, i8* %20
%21 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
store i8 0, i8* %21
%22 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
store i8 0, i8* %22
%23 = load i8*, i8** %4
%24 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%25 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%26 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%27 = call i32 @sscanf(i8* %23, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %24, i8* %25, i8* %26)
%28 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%29 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%30 = call i32 @strcoll(i8* %28, i8* %29)
store i32 %30, i32* %11
%31 = load i32, i32* %11
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %51
33: ; preds = %2
%34 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%35 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%36 = call i32 @strcoll(i8* %34, i8* %35)
store i32 %36, i32* %11
%37 = load i32, i32* %11
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %50
39: ; preds = %33
%40 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%41 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%42 = call i32 @strcoll(i8* %40, i8* %41)
store i32 %42, i32* %11
%43 = load i32, i32* %11
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %49
45: ; preds = %39
%46 = load i8*, i8** %3
%47 = load i8*, i8** %4
%48 = call i32 @strcmp(i8* %46, i8* %47)
store i32 %48, i32* %11
br label %49
49: ; preds = %45, %39
br label %50
50: ; preds = %49, %33
br label %51
51: ; preds = %50, %2
%52 = load i32, i32* %11
ret i32 %52
}

LLVM IR (-O2):
@.str = [18 x i8] c"%[^\09]\09%[^\09]\09%[^\09]\00"
define i32 @strcollcmp(i8* nocapture %0, i8* nocapture %1) {
%3 = alloca [512 x i8]
%4 = alloca [512 x i8]
%5 = alloca [512 x i8]
%6 = alloca [512 x i8]
%7 = alloca [512 x i8]
%8 = alloca [512 x i8]
%9 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%10 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%11 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%12 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%13 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%14 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
store i8 0, i8* %11
store i8 0, i8* %10
store i8 0, i8* %9
%15 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %9, i8* %10, i8* %11)
store i8 0, i8* %14
store i8 0, i8* %13
store i8 0, i8* %12
%16 = call i32 @sscanf(i8* %1, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %12, i8* %13, i8* %14)
%17 = call i32 @strcoll(i8* %9, i8* %12)
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %27
19: ; preds = %2
%20 = call i32 @strcoll(i8* %10, i8* %13)
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %19
%23 = call i32 @strcoll(i8* %11, i8* %14)
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(1) %1)
br label %27
27: ; preds = %19, %25, %22, %2
%28 = phi i32 [ %26, %25 ], [ %23, %22 ], [ %20, %19 ], [ %17, %2 ]
ret i32 %28
}