#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 {
    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    11c3 <get_libname+0xa3>
mov    $0x0,%al
call   1040 <detect@plt>
cmp    $0x3,%eax
jne    1166 <get_libname+0x46>
lea    0xeb0(%rip),%rdi
call   1030 <printf@plt>
jmp    11be <get_libname+0x9e>
mov    $0x0,%al
call   1040 <detect@plt>
cmp    $0x4,%eax
jne    1187 <get_libname+0x67>
lea    0xe9b(%rip),%rdi
call   1030 <printf@plt>
jmp    11b9 <get_libname+0x99>
mov    $0x0,%al
call   1040 <detect@plt>
cmp    $0x5,%eax
jne    11a8 <get_libname+0x88>
lea    0xe81(%rip),%rdi
call   1030 <printf@plt>
jmp    11b4 <get_libname+0x94>
lea    0xe77(%rip),%rdi
call   1030 <printf@plt>
jmp    11b9 <get_libname+0x99>
jmp    11be <get_libname+0x9e>
jmp    11c3 <get_libname+0xa3>
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    0xeea(%rip),%rdi
pop    %rax
jmp    1030 <puts@plt>
xor    %eax,%eax
call   1040 <detect@plt>
cmp    $0x3,%eax
jne    1153 <get_libname+0x33>
lea    0xec6(%rip),%rdi
pop    %rax
jmp    1030 <puts@plt>
xor    %eax,%eax
call   1040 <detect@plt>
cmp    $0x4,%eax
jne    116c <get_libname+0x4c>
lea    0xea7(%rip),%rdi
pop    %rax
jmp    1030 <puts@plt>
xor    %eax,%eax
call   1040 <detect@plt>
cmp    $0x5,%eax
lea    0xe8a(%rip),%rax
lea    0xe7c(%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 = [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 %25
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 %24
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 %23
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 %22
20: ; preds = %15
%21 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
br label %22
22: ; preds = %20, %18
br label %23
23: ; preds = %22, %13
br label %24
24: ; preds = %23, %8
br label %25
25: ; preds = %24, %3
ret void
}

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