#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*/ sprintf(char *, char *, char *, char *, ...);
int strncmp(char *, char *, int);
bool parhash(char *hash, char att[][8 + 1], int nat) {
  int i;
  switch (nat) {
  case 2:
    if (strncmp(att[0], att[1], 8) > 0)
      sprintf(hash,
              "%-"
              "8s"
              " %-"
              "8s",
              att[1], att[0]);
    else
      sprintf(hash,
              "%-"
              "8s"
              " %-"
              "8s",
              att[0], att[1]);
    return false;
  case 3:
    if (strncmp(att[0], att[2], 8) > 0)
      sprintf(hash,
              "%-"
              "8s"
              " %-"
              "8s"
              " %-"
              "8s",
              att[2], att[1], att[0]);
    else
      sprintf(hash,
              "%-"
              "8s"
              " %-"
              "8s"
              " %-"
              "8s",
              att[0], att[1], att[2]);
    return false;
  case 4:
    if (!(i = strncmp(att[1], att[2], 8)))
      i = strncmp(att[0], att[3], 8);
    if (i > 0)
      sprintf(hash,
              "%-"
              "8s"
              " %-"
              "8s"
              " %-"
              "8s"
              " %-"
              "8s",
              att[3], att[2], att[1], att[0]);
    else
      sprintf(hash,
              "%-"
              "8s"
              " %-"
              "8s"
              " %-"
              "8s"
              " %-"
              "8s",
              att[0], att[1], att[2], att[3]);
    return false;
  default:
    return true;
  }
}


x86 assembly (clang, -O0):
<parhash>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x2,%eax
je     1169 <parhash+0x49>
jmp    1147 <parhash+0x27>
mov    -0x24(%rbp),%eax
sub    $0x3,%eax
je     11d5 <parhash+0xb5>
jmp    1158 <parhash+0x38>
mov    -0x24(%rbp),%eax
sub    $0x4,%eax
je     1251 <parhash+0x131>
jmp    1307 <parhash+0x1e7>
mov    -0x18(%rbp),%rdi
mov    -0x18(%rbp),%rsi
add    $0x9,%rsi
mov    $0x8,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jle    11ab <parhash+0x8b>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
add    $0x9,%rdx
mov    -0x18(%rbp),%rcx
lea    0xe6b(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    11c9 <parhash+0xa9>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x18(%rbp),%rcx
add    $0x9,%rcx
lea    0xe48(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    130e <parhash+0x1ee>
mov    -0x18(%rbp),%rdi
mov    -0x18(%rbp),%rsi
add    $0x12,%rsi
mov    $0x8,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jle    121f <parhash+0xff>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
add    $0x12,%rdx
mov    -0x18(%rbp),%rcx
add    $0x9,%rcx
mov    -0x18(%rbp),%r8
lea    0xdf2(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    1245 <parhash+0x125>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x18(%rbp),%rcx
add    $0x9,%rcx
mov    -0x18(%rbp),%r8
add    $0x12,%r8
lea    0xdc7(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    130e <parhash+0x1ee>
mov    -0x18(%rbp),%rdi
add    $0x9,%rdi
mov    -0x18(%rbp),%rsi
add    $0x12,%rsi
mov    $0x8,%edx
call   1030 <strncmp@plt>
mov    %eax,-0x20(%rbp)
cmp    $0x0,%eax
jne    1290 <parhash+0x170>
mov    -0x18(%rbp),%rdi
mov    -0x18(%rbp),%rsi
add    $0x1b,%rsi
mov    $0x8,%edx
call   1030 <strncmp@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jle    12cd <parhash+0x1ad>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
add    $0x1b,%rdx
mov    -0x18(%rbp),%rcx
add    $0x12,%rcx
mov    -0x18(%rbp),%r8
add    $0x9,%r8
mov    -0x18(%rbp),%r9
lea    0xd3f(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    12fb <parhash+0x1db>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x18(%rbp),%rcx
add    $0x9,%rcx
mov    -0x18(%rbp),%r8
add    $0x12,%r8
mov    -0x18(%rbp),%r9
add    $0x1b,%r9
lea    0xd0c(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    130e <parhash+0x1ee>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parhash>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
cmp    $0x4,%edx
je     1172 <parhash+0x52>
cmp    $0x3,%edx
je     11ad <parhash+0x8d>
mov    $0x1,%ebp
cmp    $0x2,%edx
jne    1230 <parhash+0x110>
lea    0x9(%rbx),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x8,%edx
call   1030 <strncmp@plt>
lea    0xea9(%rip),%rsi
xor    %ebp,%ebp
mov    %r14,%rdi
test   %eax,%eax
jle    11dd <parhash+0xbd>
mov    %r15,%rdx
mov    %rbx,%rcx
jmp    11e3 <parhash+0xc3>
lea    0x9(%rbx),%r15
lea    0x12(%rbx),%r12
mov    %r15,%rdi
mov    %r12,%rsi
mov    $0x8,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     11fb <parhash+0xdb>
test   %eax,%eax
jle    1210 <parhash+0xf0>
lea    0x1b(%rbx),%rdx
lea    0xe63(%rip),%rsi
xor    %ebp,%ebp
mov    %r14,%rdi
mov    %r12,%rcx
mov    %r15,%r8
mov    %rbx,%r9
jmp    1229 <parhash+0x109>
lea    0x12(%rbx),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x8,%edx
call   1030 <strncmp@plt>
lea    0x9(%rbx),%rcx
lea    0xe39(%rip),%rsi
xor    %ebp,%ebp
mov    %r14,%rdi
test   %eax,%eax
jle    11ec <parhash+0xcc>
mov    %r15,%rdx
mov    %rbx,%r8
jmp    11f2 <parhash+0xd2>
mov    %rbx,%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   1040 <sprintf@plt>
jmp    1230 <parhash+0x110>
mov    %rbx,%rdx
mov    %r15,%r8
xor    %eax,%eax
call   1040 <sprintf@plt>
jmp    1230 <parhash+0x110>
lea    0x1b(%rbx),%rsi
mov    %rbx,%rdi
mov    $0x8,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
jg     1192 <parhash+0x72>
lea    0x1b(%rbx),%r9
lea    0xde5(%rip),%rsi
xor    %ebp,%ebp
mov    %r14,%rdi
mov    %rbx,%rdx
mov    %r15,%rcx
mov    %r12,%r8
xor    %eax,%eax
call   1040 <sprintf@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"%-8s %-8s\00"
@.str.1 = [15 x i8] c"%-8s %-8s %-8s\00"
@.str.2 = [20 x i8] c"%-8s %-8s %-8s %-8s\00"
define i32 @parhash(i8* %0, [9 x i8]* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca [9 x i8]*
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %5
store [9 x i8]* %1, [9 x i8]** %6
store i32 %2, i32* %7
%9 = load i32, i32* %7
switch i32 %9, label %123 [
i32 2, label %10
i32 3, label %38
i32 4, label %72
]
10: ; preds = %3
%11 = load [9 x i8]*, [9 x i8]** %6
%12 = getelementptr inbounds [9 x i8], [9 x i8]* %11, i64 0
%13 = getelementptr inbounds [9 x i8], [9 x i8]* %12, i64 0, i64 0
%14 = load [9 x i8]*, [9 x i8]** %6
%15 = getelementptr inbounds [9 x i8], [9 x i8]* %14, i64 1
%16 = getelementptr inbounds [9 x i8], [9 x i8]* %15, i64 0, i64 0
%17 = call i32 @strncmp(i8* %13, i8* %16, i32 8)
%18 = icmp sgt i32 %17, 0
br i1 %18, label %19, label %28
19: ; preds = %10
%20 = load i8*, i8** %5
%21 = load [9 x i8]*, [9 x i8]** %6
%22 = getelementptr inbounds [9 x i8], [9 x i8]* %21, i64 1
%23 = getelementptr inbounds [9 x i8], [9 x i8]* %22, i64 0, i64 0
%24 = load [9 x i8]*, [9 x i8]** %6
%25 = getelementptr inbounds [9 x i8], [9 x i8]* %24, i64 0
%26 = getelementptr inbounds [9 x i8], [9 x i8]* %25, i64 0, i64 0
%27 = call i32 (i8*, i8*, i8*, i8*, ...) @sprintf(i8* %20, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %23, i8* %26)
br label %37
28: ; preds = %10
%29 = load i8*, i8** %5
%30 = load [9 x i8]*, [9 x i8]** %6
%31 = getelementptr inbounds [9 x i8], [9 x i8]* %30, i64 0
%32 = getelementptr inbounds [9 x i8], [9 x i8]* %31, i64 0, i64 0
%33 = load [9 x i8]*, [9 x i8]** %6
%34 = getelementptr inbounds [9 x i8], [9 x i8]* %33, i64 1
%35 = getelementptr inbounds [9 x i8], [9 x i8]* %34, i64 0, i64 0
%36 = call i32 (i8*, i8*, i8*, i8*, ...) @sprintf(i8* %29, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %32, i8* %35)
br label %37
37: ; preds = %28, %19
store i32 0, i32* %4
br label %124
38: ; preds = %3
%39 = load [9 x i8]*, [9 x i8]** %6
%40 = getelementptr inbounds [9 x i8], [9 x i8]* %39, i64 0
%41 = getelementptr inbounds [9 x i8], [9 x i8]* %40, i64 0, i64 0
%42 = load [9 x i8]*, [9 x i8]** %6
%43 = getelementptr inbounds [9 x i8], [9 x i8]* %42, i64 2
%44 = getelementptr inbounds [9 x i8], [9 x i8]* %43, i64 0, i64 0
%45 = call i32 @strncmp(i8* %41, i8* %44, i32 8)
%46 = icmp sgt i32 %45, 0
br i1 %46, label %47, label %59
47: ; preds = %38
%48 = load i8*, i8** %5
%49 = load [9 x i8]*, [9 x i8]** %6
%50 = getelementptr inbounds [9 x i8], [9 x i8]* %49, i64 2
%51 = getelementptr inbounds [9 x i8], [9 x i8]* %50, i64 0, i64 0
%52 = load [9 x i8]*, [9 x i8]** %6
%53 = getelementptr inbounds [9 x i8], [9 x i8]* %52, i64 1
%54 = getelementptr inbounds [9 x i8], [9 x i8]* %53, i64 0, i64 0
%55 = load [9 x i8]*, [9 x i8]** %6
%56 = getelementptr inbounds [9 x i8], [9 x i8]* %55, i64 0
%57 = getelementptr inbounds [9 x i8], [9 x i8]* %56, i64 0, i64 0
%58 = call i32 (i8*, i8*, i8*, i8*, ...) @sprintf(i8* %48, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %51, i8* %54, i8* %57)
br label %71
59: ; preds = %38
%60 = load i8*, i8** %5
%61 = load [9 x i8]*, [9 x i8]** %6
%62 = getelementptr inbounds [9 x i8], [9 x i8]* %61, i64 0
%63 = getelementptr inbounds [9 x i8], [9 x i8]* %62, i64 0, i64 0
%64 = load [9 x i8]*, [9 x i8]** %6
%65 = getelementptr inbounds [9 x i8], [9 x i8]* %64, i64 1
%66 = getelementptr inbounds [9 x i8], [9 x i8]* %65, i64 0, i64 0
%67 = load [9 x i8]*, [9 x i8]** %6
%68 = getelementptr inbounds [9 x i8], [9 x i8]* %67, i64 2
%69 = getelementptr inbounds [9 x i8], [9 x i8]* %68, i64 0, i64 0
%70 = call i32 (i8*, i8*, i8*, i8*, ...) @sprintf(i8* %60, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %63, i8* %66, i8* %69)
br label %71
71: ; preds = %59, %47
store i32 0, i32* %4
br label %124
72: ; preds = %3
%73 = load [9 x i8]*, [9 x i8]** %6
%74 = getelementptr inbounds [9 x i8], [9 x i8]* %73, i64 1
%75 = getelementptr inbounds [9 x i8], [9 x i8]* %74, i64 0, i64 0
%76 = load [9 x i8]*, [9 x i8]** %6
%77 = getelementptr inbounds [9 x i8], [9 x i8]* %76, i64 2
%78 = getelementptr inbounds [9 x i8], [9 x i8]* %77, i64 0, i64 0
%79 = call i32 @strncmp(i8* %75, i8* %78, i32 8)
store i32 %79, i32* %8
%80 = icmp ne i32 %79, 0
br i1 %80, label %89, label %81
81: ; preds = %72
%82 = load [9 x i8]*, [9 x i8]** %6
%83 = getelementptr inbounds [9 x i8], [9 x i8]* %82, i64 0
%84 = getelementptr inbounds [9 x i8], [9 x i8]* %83, i64 0, i64 0
%85 = load [9 x i8]*, [9 x i8]** %6
%86 = getelementptr inbounds [9 x i8], [9 x i8]* %85, i64 3
%87 = getelementptr inbounds [9 x i8], [9 x i8]* %86, i64 0, i64 0
%88 = call i32 @strncmp(i8* %84, i8* %87, i32 8)
store i32 %88, i32* %8
br label %89
89: ; preds = %81, %72
%90 = load i32, i32* %8
%91 = icmp sgt i32 %90, 0
br i1 %91, label %92, label %107
92: ; preds = %89
%93 = load i8*, i8** %5
%94 = load [9 x i8]*, [9 x i8]** %6
%95 = getelementptr inbounds [9 x i8], [9 x i8]* %94, i64 3
%96 = getelementptr inbounds [9 x i8], [9 x i8]* %95, i64 0, i64 0
%97 = load [9 x i8]*, [9 x i8]** %6
%98 = getelementptr inbounds [9 x i8], [9 x i8]* %97, i64 2
%99 = getelementptr inbounds [9 x i8], [9 x i8]* %98, i64 0, i64 0
%100 = load [9 x i8]*, [9 x i8]** %6
%101 = getelementptr inbounds [9 x i8], [9 x i8]* %100, i64 1
%102 = getelementptr inbounds [9 x i8], [9 x i8]* %101, i64 0, i64 0
%103 = load [9 x i8]*, [9 x i8]** %6
%104 = getelementptr inbounds [9 x i8], [9 x i8]* %103, i64 0
%105 = getelementptr inbounds [9 x i8], [9 x i8]* %104, i64 0, i64 0
%106 = call i32 (i8*, i8*, i8*, i8*, ...) @sprintf(i8* %93, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %96, i8* %99, i8* %102, i8* %105)
br label %122
107: ; preds = %89
%108 = load i8*, i8** %5
%109 = load [9 x i8]*, [9 x i8]** %6
%110 = getelementptr inbounds [9 x i8], [9 x i8]* %109, i64 0
%111 = getelementptr inbounds [9 x i8], [9 x i8]* %110, i64 0, i64 0
%112 = load [9 x i8]*, [9 x i8]** %6
%113 = getelementptr inbounds [9 x i8], [9 x i8]* %112, i64 1
%114 = getelementptr inbounds [9 x i8], [9 x i8]* %113, i64 0, i64 0
%115 = load [9 x i8]*, [9 x i8]** %6
%116 = getelementptr inbounds [9 x i8], [9 x i8]* %115, i64 2
%117 = getelementptr inbounds [9 x i8], [9 x i8]* %116, i64 0, i64 0
%118 = load [9 x i8]*, [9 x i8]** %6
%119 = getelementptr inbounds [9 x i8], [9 x i8]* %118, i64 3
%120 = getelementptr inbounds [9 x i8], [9 x i8]* %119, i64 0, i64 0
%121 = call i32 (i8*, i8*, i8*, i8*, ...) @sprintf(i8* %108, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %111, i8* %114, i8* %117, i8* %120)
br label %122
122: ; preds = %107, %92
store i32 0, i32* %4
br label %124
123: ; preds = %3
store i32 1, i32* %4
br label %124
124: ; preds = %123, %122, %71, %37
%125 = load i32, i32* %4
ret i32 %125
}

LLVM IR (-O2):
@.str = [10 x i8] c"%-8s %-8s\00"
@.str.1 = [15 x i8] c"%-8s %-8s %-8s\00"
@.str.2 = [20 x i8] c"%-8s %-8s %-8s %-8s\00"
define i32 @parhash(i8* nocapture writeonly %0, [9 x i8]* %1, i32 %2) {
switch i32 %2, label %43 [
i32 2, label %4
i32 3, label %13
i32 4, label %23
]
4: ; preds = %3
%5 = getelementptr inbounds [9 x i8], [9 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [9 x i8], [9 x i8]* %1, i64 1, i64 0
%7 = tail call i32 @strncmp(i8* %5, i8* %6, i32 8)
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %4
%10 = tail call i32 (i8*, i8*, i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %6, i8* %5)
br label %43
11: ; preds = %4
%12 = tail call i32 (i8*, i8*, i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %5, i8* %6)
br label %43
13: ; preds = %3
%14 = getelementptr inbounds [9 x i8], [9 x i8]* %1, i64 0, i64 0
%15 = getelementptr inbounds [9 x i8], [9 x i8]* %1, i64 2, i64 0
%16 = tail call i32 @strncmp(i8* %14, i8* %15, i32 8)
%17 = icmp sgt i32 %16, 0
%18 = getelementptr inbounds [9 x i8], [9 x i8]* %1, i64 1, i64 0
br i1 %17, label %19, label %21
19: ; preds = %13
%20 = tail call i32 (i8*, i8*, i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %15, i8* %18, i8* %14)
br label %43
21: ; preds = %13
%22 = tail call i32 (i8*, i8*, i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %14, i8* %18, i8* %15)
br label %43
23: ; preds = %3
%24 = getelementptr inbounds [9 x i8], [9 x i8]* %1, i64 1, i64 0
%25 = getelementptr inbounds [9 x i8], [9 x i8]* %1, i64 2, i64 0
%26 = tail call i32 @strncmp(i8* %24, i8* %25, i32 8)
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %32
28: ; preds = %23
%29 = getelementptr inbounds [9 x i8], [9 x i8]* %1, i64 0, i64 0
%30 = getelementptr inbounds [9 x i8], [9 x i8]* %1, i64 3, i64 0
%31 = tail call i32 @strncmp(i8* %29, i8* %30, i32 8)
br label %32
32: ; preds = %28, %23
%33 = phi i32 [ %26, %23 ], [ %31, %28 ]
%34 = icmp sgt i32 %33, 0
br i1 %34, label %35, label %39
35: ; preds = %32
%36 = getelementptr inbounds [9 x i8], [9 x i8]* %1, i64 3, i64 0
%37 = getelementptr inbounds [9 x i8], [9 x i8]* %1, i64 0, i64 0
%38 = tail call i32 (i8*, i8*, i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %36, i8* %25, i8* %24, i8* %37)
br label %43
39: ; preds = %32
%40 = getelementptr inbounds [9 x i8], [9 x i8]* %1, i64 0, i64 0
%41 = getelementptr inbounds [9 x i8], [9 x i8]* %1, i64 3, i64 0
%42 = tail call i32 (i8*, i8*, i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %40, i8* %24, i8* %25, i8* %41)
br label %43
43: ; preds = %3, %35, %39, %19, %21, %9, %11
%44 = phi i32 [ 0, %11 ], [ 0, %9 ], [ 0, %21 ], [ 0, %19 ], [ 0, %39 ], [ 0, %35 ], [ 1, %3 ]
ret i32 %44
}