#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 implver();
int /*<<< orphan*/ printf(char *, ...);
void get_cpuconfig(void) {
  printf("#define EV%d\n", implver() + 4);
  switch (implver()) {
  case 0:
    printf("#define L1_DATA_SIZE 16384\n");
    printf("#define L1_DATA_LINESIZE 32\n");
    printf("#define L2_SIZE 2097152\n");
    printf("#define L2_LINESIZE 32\n");
    printf("#define DTB_DEFAULT_ENTRIES 32\n");
    printf("#define DTB_SIZE 8192\n");
    break;
  case 1:
    printf("#define L1_DATA_SIZE 16384\n");
    printf("#define L1_DATA_LINESIZE 32\n");
    printf("#define L2_SIZE 2097152\n");
    printf("#define L2_LINESIZE 64\n");
    printf("#define DTB_DEFAULT_ENTRIES 64\n");
    printf("#define DTB_SIZE 8192\n");
    break;
  case 2:
    printf("#define L1_DATA_SIZE 32768\n");
    printf("#define L1_DATA_LINESIZE 64\n");
    printf("#define L2_SIZE 4194304\n");
    printf("#define L2_LINESIZE 64\n");
    printf("#define DTB_DEFAULT_ENTRIES 64\n");
    printf("#define DTB_SIZE 8192\n");
    break;
  }
}


x86 assembly (clang, -O0):
<get_cpuconfig>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xor    %eax,%eax
mov    %al,-0x5(%rbp)
call   1030 <implver@plt>
mov    %eax,%esi
mov    -0x5(%rbp),%al
add    $0x4,%esi
lea    0xebf(%rip),%rdi
call   1040 <printf@plt>
mov    -0x5(%rbp),%al
call   1030 <implver@plt>
mov    %eax,%ecx
mov    %ecx,-0x4(%rbp)
test   %eax,%eax
je     1182 <get_cpuconfig+0x62>
jmp    1160 <get_cpuconfig+0x40>
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
je     11db <get_cpuconfig+0xbb>
jmp    1171 <get_cpuconfig+0x51>
mov    -0x4(%rbp),%eax
sub    $0x2,%eax
je     1234 <get_cpuconfig+0x114>
jmp    1288 <get_cpuconfig+0x168>
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xec9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1288 <get_cpuconfig+0x168>
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1288 <get_cpuconfig+0x168>
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xec9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_cpuconfig>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
xor    %eax,%eax
call   1030 <implver@plt>
lea    0x4(%rax),%esi
lea    0xeb6(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1030 <implver@plt>
cmp    $0x2,%eax
ja     11ed <get_cpuconfig+0xbd>
cltq
lea    0xfc6(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
lea    0xfc4(%rip),%rcx
movslq (%rcx,%rax,4),%r13
add    %rcx,%r13
lea    0xfc2(%rip),%rcx
movslq (%rcx,%rax,4),%r14
add    %rcx,%r14
lea    0xfc0(%rip),%rcx
movslq (%rcx,%rax,4),%r15
add    %rcx,%r15
lea    0xfbe(%rip),%rcx
movslq (%rcx,%rax,4),%r12
add    %rcx,%r12
lea    0xfbc(%rip),%rcx
movslq (%rcx,%rax,4),%rbx
add    %rcx,%rbx
call   1040 <puts@plt>
mov    %r13,%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1040 <puts@plt>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [14 x i8] c"#define EV%d\0A\00"
@.str.1 = [28 x i8] c"#define L1_DATA_SIZE 16384\0A\00"
@.str.2 = [29 x i8] c"#define L1_DATA_LINESIZE 32\0A\00"
@.str.3 = [25 x i8] c"#define L2_SIZE 2097152\0A\00"
@.str.4 = [24 x i8] c"#define L2_LINESIZE 32\0A\00"
@.str.5 = [32 x i8] c"#define DTB_DEFAULT_ENTRIES 32\0A\00"
@.str.6 = [23 x i8] c"#define DTB_SIZE 8192\0A\00"
@.str.7 = [24 x i8] c"#define L2_LINESIZE 64\0A\00"
@.str.8 = [32 x i8] c"#define DTB_DEFAULT_ENTRIES 64\0A\00"
@.str.9 = [28 x i8] c"#define L1_DATA_SIZE 32768\0A\00"
@.str.10 = [29 x i8] c"#define L1_DATA_LINESIZE 64\0A\00"
@.str.11 = [25 x i8] c"#define L2_SIZE 4194304\0A\00"
define void @get_cpuconfig() {
%1 = call i32 (...) @implver()
%2 = add nsw i32 %1, 4
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %2)
%4 = call i32 (...) @implver()
switch i32 %4, label %26 [
i32 0, label %5
i32 1, label %12
i32 2, label %19
]
5: ; preds = %0
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
br label %26
12: ; preds = %0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0))
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
br label %26
19: ; preds = %0
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.9, i64 0, i64 0))
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0))
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.11, i64 0, i64 0))
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0))
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0))
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
br label %26
26: ; preds = %0, %19, %12, %5
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"#define EV%d\0A\00"
@str = [27 x i8] c"#define L1_DATA_SIZE 32768\00"
@str.12 = [28 x i8] c"#define L1_DATA_LINESIZE 64\00"
@str.13 = [24 x i8] c"#define L2_SIZE 4194304\00"
@str.20 = [23 x i8] c"#define L2_LINESIZE 64\00"
@str.21 = [31 x i8] c"#define DTB_DEFAULT_ENTRIES 64\00"
@str.23 = [27 x i8] c"#define L1_DATA_SIZE 16384\00"
@str.24 = [28 x i8] c"#define L1_DATA_LINESIZE 32\00"
@str.25 = [24 x i8] c"#define L2_SIZE 2097152\00"
@str.26 = [23 x i8] c"#define L2_LINESIZE 32\00"
@str.27 = [31 x i8] c"#define DTB_DEFAULT_ENTRIES 32\00"
@str.28 = [22 x i8] c"#define DTB_SIZE 8192\00"
@reltable.get_cpuconfig = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([27 x i8]* @str.23 to i64), i64 ptrtoint ([3 x i32]* @reltable.get_cpuconfig to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([27 x i8]* @str.23 to i64), i64 ptrtoint ([3 x i32]* @reltable.get_cpuconfig to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([27 x i8]* @str to i64), i64 ptrtoint ([3 x i32]* @reltable.get_cpuconfig to i64)) to i32)]
@reltable.get_cpuconfig.34 = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([28 x i8]* @str.24 to i64), i64 ptrtoint ([3 x i32]* @reltable.get_cpuconfig.34 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([28 x i8]* @str.24 to i64), i64 ptrtoint ([3 x i32]* @reltable.get_cpuconfig.34 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([28 x i8]* @str.12 to i64), i64 ptrtoint ([3 x i32]* @reltable.get_cpuconfig.34 to i64)) to i32)]
@reltable.get_cpuconfig.35 = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([24 x i8]* @str.25 to i64), i64 ptrtoint ([3 x i32]* @reltable.get_cpuconfig.35 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([24 x i8]* @str.25 to i64), i64 ptrtoint ([3 x i32]* @reltable.get_cpuconfig.35 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([24 x i8]* @str.13 to i64), i64 ptrtoint ([3 x i32]* @reltable.get_cpuconfig.35 to i64)) to i32)]
@reltable.get_cpuconfig.36 = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([23 x i8]* @str.26 to i64), i64 ptrtoint ([3 x i32]* @reltable.get_cpuconfig.36 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([23 x i8]* @str.20 to i64), i64 ptrtoint ([3 x i32]* @reltable.get_cpuconfig.36 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([23 x i8]* @str.20 to i64), i64 ptrtoint ([3 x i32]* @reltable.get_cpuconfig.36 to i64)) to i32)]
@reltable.get_cpuconfig.37 = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([31 x i8]* @str.27 to i64), i64 ptrtoint ([3 x i32]* @reltable.get_cpuconfig.37 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([31 x i8]* @str.21 to i64), i64 ptrtoint ([3 x i32]* @reltable.get_cpuconfig.37 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([31 x i8]* @str.21 to i64), i64 ptrtoint ([3 x i32]* @reltable.get_cpuconfig.37 to i64)) to i32)]
@reltable.get_cpuconfig.38 = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([22 x i8]* @str.28 to i64), i64 ptrtoint ([3 x i32]* @reltable.get_cpuconfig.38 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([22 x i8]* @str.28 to i64), i64 ptrtoint ([3 x i32]* @reltable.get_cpuconfig.38 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([22 x i8]* @str.28 to i64), i64 ptrtoint ([3 x i32]* @reltable.get_cpuconfig.38 to i64)) to i32)]
define void @get_cpuconfig() {
%1 = tail call i32 (...) @implver()
%2 = add nsw i32 %1, 4
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %2)
%4 = tail call i32 (...) @implver()
%5 = icmp ult i32 %4, 3
br i1 %5, label %6, label %31
6: ; preds = %0
%7 = sext i32 %4 to i64
%8 = shl i64 %7, 2
%9 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.get_cpuconfig to i8*), i64 %8)
%10 = sext i32 %4 to i64
%11 = shl i64 %10, 2
%12 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.get_cpuconfig.34 to i8*), i64 %11)
%13 = sext i32 %4 to i64
%14 = shl i64 %13, 2
%15 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.get_cpuconfig.35 to i8*), i64 %14)
%16 = sext i32 %4 to i64
%17 = shl i64 %16, 2
%18 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.get_cpuconfig.36 to i8*), i64 %17)
%19 = sext i32 %4 to i64
%20 = shl i64 %19, 2
%21 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.get_cpuconfig.37 to i8*), i64 %20)
%22 = sext i32 %4 to i64
%23 = shl i64 %22, 2
%24 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.get_cpuconfig.38 to i8*), i64 %23)
%25 = tail call i32 @puts(i8* dereferenceable(1) %9)
%26 = tail call i32 @puts(i8* dereferenceable(1) %12)
%27 = tail call i32 @puts(i8* dereferenceable(1) %15)
%28 = tail call i32 @puts(i8* dereferenceable(1) %18)
%29 = tail call i32 @puts(i8* dereferenceable(1) %21)
%30 = tail call i32 @puts(i8* dereferenceable(1) %24)
br label %31
31: ; preds = %0, %6
ret void
}