#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 detect();
int /*<<< orphan*/ printf(char *);
void get_libname(void) {
  if (detect() == 2) {
    printf("loongson3a\n");
  } else if (detect() == 3) {
    printf("loongson3b\n");
  } else if (detect() == 4) {
    printf("i6400\n");
  } else if (detect() == 5) {
    printf("p6600\n");
  } else if (detect() == 6) {
    printf("i6500\n");
  } else {
    printf("mips64\n");
  }
}


x86 assembly (clang, -O0):
<get_libname>:
push   %rbp
mov    %rsp,%rbp
mov    $0x0,%al
call   1040 <detect@plt>
cmp    $0x2,%eax
jne    1145 <get_libname+0x25>
lea    0xec5(%rip),%rdi
call   1030 <printf@plt>
jmp    11e9 <get_libname+0xc9>
mov    $0x0,%al
call   1040 <detect@plt>
cmp    $0x3,%eax
jne    1166 <get_libname+0x46>
lea    0xeb0(%rip),%rdi
call   1030 <printf@plt>
jmp    11e4 <get_libname+0xc4>
mov    $0x0,%al
call   1040 <detect@plt>
cmp    $0x4,%eax
jne    1187 <get_libname+0x67>
lea    0xe9b(%rip),%rdi
call   1030 <printf@plt>
jmp    11df <get_libname+0xbf>
mov    $0x0,%al
call   1040 <detect@plt>
cmp    $0x5,%eax
jne    11a8 <get_libname+0x88>
lea    0xe81(%rip),%rdi
call   1030 <printf@plt>
jmp    11da <get_libname+0xba>
mov    $0x0,%al
call   1040 <detect@plt>
cmp    $0x6,%eax
jne    11c9 <get_libname+0xa9>
lea    0xe67(%rip),%rdi
call   1030 <printf@plt>
jmp    11d5 <get_libname+0xb5>
lea    0xe5d(%rip),%rdi
call   1030 <printf@plt>
jmp    11da <get_libname+0xba>
jmp    11df <get_libname+0xbf>
jmp    11e4 <get_libname+0xc4>
jmp    11e9 <get_libname+0xc9>
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_libname>:
push   %rax
xor    %eax,%eax
call   1040 <detect@plt>
cmp    $0x2,%eax
jne    113a <get_libname+0x1a>
lea    0xef0(%rip),%rdi
pop    %rax
jmp    1030 <puts@plt>
xor    %eax,%eax
call   1040 <detect@plt>
cmp    $0x3,%eax
jne    1153 <get_libname+0x33>
lea    0xecc(%rip),%rdi
pop    %rax
jmp    1030 <puts@plt>
xor    %eax,%eax
call   1040 <detect@plt>
cmp    $0x4,%eax
jne    116c <get_libname+0x4c>
lea    0xead(%rip),%rdi
pop    %rax
jmp    1030 <puts@plt>
xor    %eax,%eax
call   1040 <detect@plt>
cmp    $0x5,%eax
jne    1185 <get_libname+0x65>
lea    0xe8e(%rip),%rdi
pop    %rax
jmp    1030 <puts@plt>
xor    %eax,%eax
call   1040 <detect@plt>
cmp    $0x6,%eax
lea    0xe71(%rip),%rax
lea    0xe63(%rip),%rdi
cmove  %rax,%rdi
pop    %rax
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"loongson3a\0A\00"
@.str.1 = [12 x i8] c"loongson3b\0A\00"
@.str.2 = [7 x i8] c"i6400\0A\00"
@.str.3 = [7 x i8] c"p6600\0A\00"
@.str.4 = [7 x i8] c"i6500\0A\00"
@.str.5 = [8 x i8] c"mips64\0A\00"
define void @get_libname() {
%1 = call i32 (...) @detect()
%2 = icmp eq i32 %1, 2
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %31
5: ; preds = %0
%6 = call i32 (...) @detect()
%7 = icmp eq i32 %6, 3
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %30
10: ; preds = %5
%11 = call i32 (...) @detect()
%12 = icmp eq i32 %11, 4
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %29
15: ; preds = %10
%16 = call i32 (...) @detect()
%17 = icmp eq i32 %16, 5
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %28
20: ; preds = %15
%21 = call i32 (...) @detect()
%22 = icmp eq i32 %21, 6
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %27
25: ; preds = %20
%26 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
br label %27
27: ; preds = %25, %23
br label %28
28: ; preds = %27, %18
br label %29
29: ; preds = %28, %13
br label %30
30: ; preds = %29, %8
br label %31
31: ; preds = %30, %3
ret void
}

LLVM IR (-O2):
@str = [7 x i8] c"mips64\00"
@str.6 = [6 x i8] c"i6500\00"
@str.7 = [6 x i8] c"p6600\00"
@str.8 = [6 x i8] c"i6400\00"
@str.9 = [11 x i8] c"loongson3b\00"
@str.10 = [11 x i8] c"loongson3a\00"
define void @get_libname() {
%1 = tail call i32 (...) @detect()
%2 = icmp eq i32 %1, 2
br i1 %2, label %16, label %3
3: ; preds = %0
%4 = tail call i32 (...) @detect()
%5 = icmp eq i32 %4, 3
br i1 %5, label %16, label %6
6: ; preds = %3
%7 = tail call i32 (...) @detect()
%8 = icmp eq i32 %7, 4
br i1 %8, label %16, label %9
9: ; preds = %6
%10 = tail call i32 (...) @detect()
%11 = icmp eq i32 %10, 5
br i1 %11, label %16, label %12
12: ; preds = %9
%13 = tail call i32 (...) @detect()
%14 = icmp eq i32 %13, 6
%15 = select i1 %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @str.6, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0)
br label %16
16: ; preds = %12, %9, %6, %3, %0
%17 = phi i8* [ getelementptr inbounds ([11 x i8], [11 x i8]* @str.10, i64 0, i64 0), %0 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @str.9, i64 0, i64 0), %3 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @str.8, i64 0, i64 0), %6 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @str.7, i64 0, i64 0), %9 ], [ %15, %12 ]
%18 = tail call i32 @puts(i8* dereferenceable(1) %17)
ret void
}