#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *, ...);
int isqrt(int);
int /*<<< orphan*/ printf(char *, char);
void write_sp_info(FILE *fp, int nprocs, char class) {
  int maxcells, problem_size, niter;
  char *dt;
  maxcells = isqrt(nprocs);
  if (class == 'S') {
    problem_size = 12;
    dt = "0.015d0";
    niter = 100;
  } else if (class == 'W') {
    problem_size = 36;
    dt = "0.0015d0";
    niter = 400;
  } else if (class == 'A') {
    problem_size = 64;
    dt = "0.0015d0";
    niter = 400;
  } else if (class == 'B') {
    problem_size = 102;
    dt = "0.001d0";
    niter = 400;
  } else if (class == 'C') {
    problem_size = 162;
    dt = "0.00067d0";
    niter = 400;
  } else if (class == 'D') {
    problem_size = 408;
    dt = "0.00030d0";
    niter = 500;
  } else {
    printf("setparams: Internal error: invalid class %c\n", class);
    exit(1);
  }
  fprintf(fp, "%sinteger maxcells, problem_size, niter_default\n", "        ");
  fprintf(fp, "%sparameter (maxcells=%d, problem_size=%d, niter_default=%d)\n",
          "        ", maxcells, problem_size, niter);
  fprintf(fp, "%sdouble precision dt_default\n", "        ");
  fprintf(fp, "%sparameter (dt_default = %s)\n", "        ", dt);
}


x86 assembly (clang, -O0):
<write_sp_info>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %dl,%al
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %al,-0xd(%rbp)
mov    -0xc(%rbp),%edi
call   1050 <isqrt@plt>
mov    %eax,-0x14(%rbp)
movsbl -0xd(%rbp),%eax
cmp    $0x53,%eax
jne    118a <write_sp_info+0x4a>
movl   $0xc,-0x18(%rbp)
lea    0xe86(%rip),%rax
mov    %rax,-0x28(%rbp)
movl   $0x64,-0x1c(%rbp)
jmp    1294 <write_sp_info+0x154>
movsbl -0xd(%rbp),%eax
cmp    $0x57,%eax
jne    11b5 <write_sp_info+0x75>
movl   $0x24,-0x18(%rbp)
lea    0xe63(%rip),%rax
mov    %rax,-0x28(%rbp)
movl   $0x190,-0x1c(%rbp)
jmp    128f <write_sp_info+0x14f>
movsbl -0xd(%rbp),%eax
cmp    $0x41,%eax
jne    11e0 <write_sp_info+0xa0>
movl   $0x40,-0x18(%rbp)
lea    0xe38(%rip),%rax
mov    %rax,-0x28(%rbp)
movl   $0x190,-0x1c(%rbp)
jmp    128a <write_sp_info+0x14a>
movsbl -0xd(%rbp),%eax
cmp    $0x42,%eax
jne    120b <write_sp_info+0xcb>
movl   $0x66,-0x18(%rbp)
lea    0xe16(%rip),%rax
mov    %rax,-0x28(%rbp)
movl   $0x190,-0x1c(%rbp)
jmp    1285 <write_sp_info+0x145>
movsbl -0xd(%rbp),%eax
cmp    $0x43,%eax
jne    1236 <write_sp_info+0xf6>
movl   $0xa2,-0x18(%rbp)
lea    0xdf3(%rip),%rax
mov    %rax,-0x28(%rbp)
movl   $0x190,-0x1c(%rbp)
jmp    1280 <write_sp_info+0x140>
movsbl -0xd(%rbp),%eax
cmp    $0x44,%eax
jne    1261 <write_sp_info+0x121>
movl   $0x198,-0x18(%rbp)
lea    0xdd2(%rip),%rax
mov    %rax,-0x28(%rbp)
movl   $0x1f4,-0x1c(%rbp)
jmp    127b <write_sp_info+0x13b>
lea    0xdc5(%rip),%rdi
movsbl -0xd(%rbp),%esi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
jmp    1280 <write_sp_info+0x140>
jmp    1285 <write_sp_info+0x145>
jmp    128a <write_sp_info+0x14a>
jmp    128f <write_sp_info+0x14f>
jmp    1294 <write_sp_info+0x154>
mov    -0x8(%rbp),%rdi
lea    0xdbb(%rip),%rsi
lea    0xde5(%rip),%rdx
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
mov    -0x1c(%rbp),%r9d
lea    0xdd1(%rip),%rsi
lea    0xdc1(%rip),%rdx
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xdf6(%rip),%rsi
lea    0xda8(%rip),%rdx
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rcx
lea    0xdf8(%rip),%rsi
lea    0xd8b(%rip),%rdx
mov    $0x0,%al
call   1040 <fprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_sp_info>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rdi,%rbx
mov    %esi,%edi
call   1050 <isqrt@plt>
mov    %eax,%r15d
lea    -0x41(%rbp),%eax
cmp    $0x16,%al
ja     1263 <write_sp_info+0x123>
lea    0xef0(%rip),%r14
mov    $0x64,%r12d
mov    $0xc,%r13d
movzbl %al,%eax
lea    0xe7e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xed2(%rip),%r14
mov    $0x190,%r12d
mov    $0x40,%r13d
jmp    11f2 <write_sp_info+0xb2>
lea    0xec6(%rip),%r14
mov    $0x190,%r12d
mov    $0x66,%r13d
jmp    11f2 <write_sp_info+0xb2>
lea    0xeb9(%rip),%r14
mov    $0x190,%r12d
mov    $0xa2,%r13d
jmp    11f2 <write_sp_info+0xb2>
lea    0xeae(%rip),%r14
mov    $0x1f4,%r12d
mov    $0x198,%r13d
jmp    11f2 <write_sp_info+0xb2>
lea    0xe7e(%rip),%r14
mov    $0x190,%r12d
mov    $0x24,%r13d
lea    0xebd(%rip),%rsi
lea    0xee7(%rip),%rbp
mov    %rbx,%rdi
mov    %rbp,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
lea    0xedc(%rip),%rsi
mov    %rbx,%rdi
mov    %rbp,%rdx
mov    %r15d,%ecx
mov    %r13d,%r8d
mov    %r12d,%r9d
xor    %eax,%eax
call   1040 <fprintf@plt>
lea    0xefd(%rip),%rsi
mov    %rbx,%rdi
mov    %rbp,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
lea    0xf08(%rip),%rsi
mov    %rbx,%rdi
mov    %rbp,%rdx
mov    %r14,%rcx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fprintf@plt>
movsbl %bpl,%esi
lea    0xe1b(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"0.015d0\00"
@.str.1 = [9 x i8] c"0.0015d0\00"
@.str.2 = [8 x i8] c"0.001d0\00"
@.str.3 = [10 x i8] c"0.00067d0\00"
@.str.4 = [10 x i8] c"0.00030d0\00"
@.str.5 = [45 x i8] c"setparams: Internal error: invalid class %c\0A\00"
@.str.6 = [49 x i8] c"%sinteger maxcells, problem_size, niter_default\0A\00"
@.str.7 = [9 x i8] c" \00"
@.str.8 = [62 x i8] c"%sparameter (maxcells=%d, problem_size=%d, niter_default=%d)\0A\00"
@.str.9 = [31 x i8] c"%sdouble precision dt_default\0A\00"
@.str.10 = [31 x i8] c"%sparameter (dt_default = %s)\0A\00"
define void @write_sp_info(i32* %0, i32 %1, i8 signext %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i8
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
store i32* %0, i32** %4
store i32 %1, i32* %5
store i8 %2, i8* %6
%11 = load i32, i32* %5
%12 = call i32 @isqrt(i32 %11)
store i32 %12, i32* %7
%13 = load i8, i8* %6
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 83
br i1 %15, label %16, label %17
16: ; preds = %3
store i32 12, i32* %8
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %10
store i32 100, i32* %9
br label %51
17: ; preds = %3
%18 = load i8, i8* %6
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 87
br i1 %20, label %21, label %22
21: ; preds = %17
store i32 36, i32* %8
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8** %10
store i32 400, i32* %9
br label %50
22: ; preds = %17
%23 = load i8, i8* %6
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 65
br i1 %25, label %26, label %27
26: ; preds = %22
store i32 64, i32* %8
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8** %10
store i32 400, i32* %9
br label %49
27: ; preds = %22
%28 = load i8, i8* %6
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 66
br i1 %30, label %31, label %32
31: ; preds = %27
store i32 102, i32* %8
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8** %10
store i32 400, i32* %9
br label %48
32: ; preds = %27
%33 = load i8, i8* %6
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 67
br i1 %35, label %36, label %37
36: ; preds = %32
store i32 162, i32* %8
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8** %10
store i32 400, i32* %9
br label %47
37: ; preds = %32
%38 = load i8, i8* %6
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 68
br i1 %40, label %41, label %42
41: ; preds = %37
store i32 408, i32* %8
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8** %10
store i32 500, i32* %9
br label %46
42: ; preds = %37
%43 = load i8, i8* %6
%44 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0), i8 signext %43)
%45 = call i32 @exit(i32 1)
unreachable
46: ; preds = %41
br label %47
47: ; preds = %46, %36
br label %48
48: ; preds = %47, %31
br label %49
49: ; preds = %48, %26
br label %50
50: ; preds = %49, %21
br label %51
51: ; preds = %50, %16
%52 = load i32*, i32** %4
%53 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %52, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%54 = load i32*, i32** %4
%55 = load i32, i32* %7
%56 = load i32, i32* %8
%57 = load i32, i32* %9
%58 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %54, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i32 %55, i32 %56, i32 %57)
%59 = load i32*, i32** %4
%60 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %59, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%61 = load i32*, i32** %4
%62 = load i8*, i8** %10
%63 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %61, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* %62)
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"0.015d0\00"
@.str.1 = [9 x i8] c"0.0015d0\00"
@.str.2 = [8 x i8] c"0.001d0\00"
@.str.3 = [10 x i8] c"0.00067d0\00"
@.str.4 = [10 x i8] c"0.00030d0\00"
@.str.5 = [45 x i8] c"setparams: Internal error: invalid class %c\0A\00"
@.str.6 = [49 x i8] c"%sinteger maxcells, problem_size, niter_default\0A\00"
@.str.7 = [9 x i8] c" \00"
@.str.8 = [62 x i8] c"%sparameter (maxcells=%d, problem_size=%d, niter_default=%d)\0A\00"
@.str.9 = [31 x i8] c"%sdouble precision dt_default\0A\00"
@.str.10 = [31 x i8] c"%sparameter (dt_default = %s)\0A\00"
define void @write_sp_info(i32* nocapture %0, i32 %1, i8 signext %2) {
%4 = tail call i32 @isqrt(i32 %1)
switch i8 %2, label %10 [
i8 83, label %13
i8 87, label %5
i8 65, label %6
i8 66, label %7
i8 67, label %8
i8 68, label %9
]
5: ; preds = %3
br label %13
6: ; preds = %3
br label %13
7: ; preds = %3
br label %13
8: ; preds = %3
br label %13
9: ; preds = %3
br label %13
10: ; preds = %3
%11 = tail call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0), i8 signext %2)
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %3, %5, %7, %9, %8, %6
%14 = phi i32 [ 36, %5 ], [ 64, %6 ], [ 102, %7 ], [ 162, %8 ], [ 408, %9 ], [ 12, %3 ]
%15 = phi i32 [ 400, %5 ], [ 400, %6 ], [ 400, %7 ], [ 400, %8 ], [ 500, %9 ], [ 100, %3 ]
%16 = phi i8* [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), %5 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), %6 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), %7 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), %8 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), %9 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), %3 ]
%17 = tail call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%18 = tail call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i32 %4, i32 %14, i32 %15)
%19 = tail call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%20 = tail call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* %16)
ret void
}