#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() == 1) {
    printf("p5600\n");
  } else if (detect() == 2) {
    printf("mips1004K\n");
  } else if (detect() == 3) {
    printf("mips24K\n");
  } else {
    printf("mips\n");
  }
}


x86 assembly (clang, -O0):
<get_libname>:
push   %rbp
mov    %rsp,%rbp
mov    $0x0,%al
call   1040 <detect@plt>
cmp    $0x1,%eax
jne    1145 <get_libname+0x25>
lea    0xec5(%rip),%rdi
call   1030 <printf@plt>
jmp    119d <get_libname+0x7d>
mov    $0x0,%al
call   1040 <detect@plt>
cmp    $0x2,%eax
jne    1166 <get_libname+0x46>
lea    0xeab(%rip),%rdi
call   1030 <printf@plt>
jmp    1198 <get_libname+0x78>
mov    $0x0,%al
call   1040 <detect@plt>
cmp    $0x3,%eax
jne    1187 <get_libname+0x67>
lea    0xe95(%rip),%rdi
call   1030 <printf@plt>
jmp    1193 <get_libname+0x73>
lea    0xe8d(%rip),%rdi
call   1030 <printf@plt>
jmp    1198 <get_libname+0x78>
jmp    119d <get_libname+0x7d>
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_libname>:
push   %rax
xor    %eax,%eax
call   1040 <detect@plt>
cmp    $0x1,%eax
jne    113a <get_libname+0x1a>
lea    0xee3(%rip),%rdi
pop    %rax
jmp    1030 <puts@plt>
xor    %eax,%eax
call   1040 <detect@plt>
cmp    $0x2,%eax
jne    1153 <get_libname+0x33>
lea    0xec0(%rip),%rdi
pop    %rax
jmp    1030 <puts@plt>
xor    %eax,%eax
call   1040 <detect@plt>
cmp    $0x3,%eax
lea    0xea1(%rip),%rax
lea    0xe95(%rip),%rdi
cmove  %rax,%rdi
pop    %rax
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"p5600\0A\00"
@.str.1 = [11 x i8] c"mips1004K\0A\00"
@.str.2 = [9 x i8] c"mips24K\0A\00"
@.str.3 = [6 x i8] c"mips\0A\00"
define void @get_libname() {
%1 = call i32 (...) @detect()
%2 = icmp eq i32 %1, 1
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %19
5: ; preds = %0
%6 = call i32 (...) @detect()
%7 = icmp eq i32 %6, 2
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %18
10: ; preds = %5
%11 = call i32 (...) @detect()
%12 = icmp eq i32 %11, 3
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
br label %17
15: ; preds = %10
%16 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %17
17: ; preds = %15, %13
br label %18
18: ; preds = %17, %8
br label %19
19: ; preds = %18, %3
ret void
}

LLVM IR (-O2):
@str = [5 x i8] c"mips\00"
@str.4 = [8 x i8] c"mips24K\00"
@str.5 = [10 x i8] c"mips1004K\00"
@str.6 = [6 x i8] c"p5600\00"
define void @get_libname() {
%1 = tail call i32 (...) @detect()
%2 = icmp eq i32 %1, 1
br i1 %2, label %10, label %3
3: ; preds = %0
%4 = tail call i32 (...) @detect()
%5 = icmp eq i32 %4, 2
br i1 %5, label %10, label %6
6: ; preds = %3
%7 = tail call i32 (...) @detect()
%8 = icmp eq i32 %7, 3
%9 = select i1 %8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0)
br label %10
10: ; preds = %6, %3, %0
%11 = phi i8* [ getelementptr inbounds ([6 x i8], [6 x i8]* @str.6, i64 0, i64 0), %0 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @str.5, i64 0, i64 0), %3 ], [ %9, %6 ]
%12 = tail call i32 @puts(i8* dereferenceable(1) %11)
ret void
}