#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 ilog2(int);
int /*<<< orphan*/ printf(char *, char);
void write_mg_info(FILE *fp, char class) {
  int problem_size, nit, log2_size, lt_default, lm;
  int ndim1, ndim2, ndim3;
  if (class == 'S') {
    problem_size = 32;
    nit = 4;
  } else if (class == 'W') {
    problem_size = 64;
    nit = 40;
  } else if (class == 'A') {
    problem_size = 256;
    nit = 4;
  } else if (class == 'B') {
    problem_size = 256;
    nit = 20;
  } else if (class == 'C') {
    problem_size = 512;
    nit = 20;
  } else {
    printf("setparams: Internal error: invalid class type %c\n", class);
    exit(1);
  }
  log2_size = ilog2(problem_size);
  lt_default = log2_size;
  lm = log2_size;
  ndim1 = lm;
  ndim3 = log2_size;
  ndim2 = log2_size;
  fprintf(fp, "%sinteger nx_default, ny_default, nz_default\n", "        ");
  fprintf(fp, "%sparameter (nx_default=%d, ny_default=%d, nz_default=%d)\n",
          "        ", problem_size, problem_size, problem_size);
  fprintf(fp, "%sinteger nit_default, lm, lt_default\n", "        ");
  fprintf(fp, "%sparameter (nit_default=%d, lm = %d, lt_default=%d)\n",
          "        ", nit, lm, lt_default);
  fprintf(fp, "%sinteger debug_default\n", "        ");
  fprintf(fp, "%sparameter (debug_default=%d)\n", "        ", 0);
  fprintf(fp, "%sinteger ndim1, ndim2, ndim3\n", "        ");
  fprintf(fp, "%sparameter (ndim1 = %d, ndim2 = %d, ndim3 = %d)\n", "        ",
          ndim1, ndim2, ndim3);
}


x86 assembly (clang, -O0):
<write_mg_info>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%eax
cmp    $0x53,%eax
jne    1172 <write_mg_info+0x32>
movl   $0x20,-0x10(%rbp)
movl   $0x4,-0x14(%rbp)
jmp    1220 <write_mg_info+0xe0>
movsbl -0x9(%rbp),%eax
cmp    $0x57,%eax
jne    1192 <write_mg_info+0x52>
movl   $0x40,-0x10(%rbp)
movl   $0x28,-0x14(%rbp)
jmp    121b <write_mg_info+0xdb>
movsbl -0x9(%rbp),%eax
cmp    $0x41,%eax
jne    11b2 <write_mg_info+0x72>
movl   $0x100,-0x10(%rbp)
movl   $0x4,-0x14(%rbp)
jmp    1216 <write_mg_info+0xd6>
movsbl -0x9(%rbp),%eax
cmp    $0x42,%eax
jne    11d2 <write_mg_info+0x92>
movl   $0x100,-0x10(%rbp)
movl   $0x14,-0x14(%rbp)
jmp    1211 <write_mg_info+0xd1>
movsbl -0x9(%rbp),%eax
cmp    $0x43,%eax
jne    11f2 <write_mg_info+0xb2>
movl   $0x200,-0x10(%rbp)
movl   $0x14,-0x14(%rbp)
jmp    120c <write_mg_info+0xcc>
lea    0xe07(%rip),%rdi
movsbl -0x9(%rbp),%esi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
jmp    1211 <write_mg_info+0xd1>
jmp    1216 <write_mg_info+0xd6>
jmp    121b <write_mg_info+0xdb>
jmp    1220 <write_mg_info+0xe0>
mov    -0x10(%rbp),%edi
call   1030 <ilog2@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xdde(%rip),%rsi
lea    0xe05(%rip),%rdx
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%ecx
mov    -0x10(%rbp),%r8d
mov    -0x10(%rbp),%r9d
lea    0xdf1(%rip),%rsi
lea    0xde1(%rip),%rdx
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xe13(%rip),%rsi
lea    0xdc8(%rip),%rdx
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%ecx
mov    -0x20(%rbp),%r8d
mov    -0x1c(%rbp),%r9d
lea    0xe16(%rip),%rsi
lea    0xda4(%rip),%rdx
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xe33(%rip),%rsi
lea    0xd8b(%rip),%rdx
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xe33(%rip),%rsi
lea    0xd72(%rip),%rdx
xor    %ecx,%ecx
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xe38(%rip),%rsi
lea    0xd57(%rip),%rdx
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%r8d
mov    -0x2c(%rbp),%r9d
lea    0xe33(%rip),%rsi
lea    0xd33(%rip),%rdx
mov    $0x0,%al
call   1050 <fprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_mg_info>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
lea    -0x41(%rsi),%eax
cmp    $0x16,%al
ja     1275 <write_mg_info+0x135>
mov    %rdi,%rbx
mov    $0x20,%ebp
mov    $0x4,%r14d
movzbl %al,%eax
lea    0xe95(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x100,%ebp
jmp    11a0 <write_mg_info+0x60>
mov    $0x100,%ebp
mov    $0x14,%r14d
jmp    11a0 <write_mg_info+0x60>
mov    $0x200,%ebp
mov    $0x14,%r14d
jmp    11a0 <write_mg_info+0x60>
mov    $0x40,%ebp
mov    $0x28,%r14d
mov    %ebp,%edi
call   1030 <ilog2@plt>
mov    %eax,%r12d
lea    0xedd(%rip),%rsi
lea    0xf04(%rip),%r15
mov    %rbx,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    0xef9(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
mov    %ebp,%ecx
mov    %ebp,%r8d
mov    %ebp,%r9d
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    0xf18(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    0xf2b(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
mov    %r14d,%ecx
mov    %r12d,%r8d
mov    %r12d,%r9d
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    0xf44(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    0xf49(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
xor    %ecx,%ecx
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    0xf53(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    0xf5e(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
mov    %r12d,%ecx
mov    %r12d,%r8d
mov    %r12d,%r9d
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <fprintf@plt>
movsbl %sil,%esi
lea    0xddc(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [50 x i8] c"setparams: Internal error: invalid class type %c\0A\00"
@.str.1 = [46 x i8] c"%sinteger nx_default, ny_default, nz_default\0A\00"
@.str.2 = [9 x i8] c" \00"
@.str.3 = [59 x i8] c"%sparameter (nx_default=%d, ny_default=%d, nz_default=%d)\0A\00"
@.str.4 = [39 x i8] c"%sinteger nit_default, lm, lt_default\0A\00"
@.str.5 = [54 x i8] c"%sparameter (nit_default=%d, lm = %d, lt_default=%d)\0A\00"
@.str.6 = [25 x i8] c"%sinteger debug_default\0A\00"
@.str.7 = [32 x i8] c"%sparameter (debug_default=%d)\0A\00"
@.str.8 = [31 x i8] c"%sinteger ndim1, ndim2, ndim3\0A\00"
@.str.9 = [50 x i8] c"%sparameter (ndim1 = %d, ndim2 = %d, ndim3 = %d)\0A\00"
define void @write_mg_info(i32* %0, i8 signext %1) {
%3 = alloca i32*
%4 = alloca i8
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32* %0, i32** %3
store i8 %1, i8* %4
%13 = load i8, i8* %4
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 83
br i1 %15, label %16, label %17
16: ; preds = %2
store i32 32, i32* %5
store i32 4, i32* %6
br label %45
17: ; preds = %2
%18 = load i8, i8* %4
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 87
br i1 %20, label %21, label %22
21: ; preds = %17
store i32 64, i32* %5
store i32 40, i32* %6
br label %44
22: ; preds = %17
%23 = load i8, i8* %4
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 65
br i1 %25, label %26, label %27
26: ; preds = %22
store i32 256, i32* %5
store i32 4, i32* %6
br label %43
27: ; preds = %22
%28 = load i8, i8* %4
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 66
br i1 %30, label %31, label %32
31: ; preds = %27
store i32 256, i32* %5
store i32 20, i32* %6
br label %42
32: ; preds = %27
%33 = load i8, i8* %4
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 67
br i1 %35, label %36, label %37
36: ; preds = %32
store i32 512, i32* %5
store i32 20, i32* %6
br label %41
37: ; preds = %32
%38 = load i8, i8* %4
%39 = call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i8 signext %38)
%40 = call i32 @exit(i32 1)
unreachable
41: ; preds = %36
br label %42
42: ; preds = %41, %31
br label %43
43: ; preds = %42, %26
br label %44
44: ; preds = %43, %21
br label %45
45: ; preds = %44, %16
%46 = load i32, i32* %5
%47 = call i32 @ilog2(i32 %46)
store i32 %47, i32* %7
%48 = load i32, i32* %7
store i32 %48, i32* %8
%49 = load i32, i32* %7
store i32 %49, i32* %9
%50 = load i32, i32* %9
store i32 %50, i32* %10
%51 = load i32, i32* %7
store i32 %51, i32* %12
%52 = load i32, i32* %7
store i32 %52, i32* %11
%53 = load i32*, i32** %3
%54 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %53, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%55 = load i32*, i32** %3
%56 = load i32, i32* %5
%57 = load i32, i32* %5
%58 = load i32, i32* %5
%59 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %55, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %56, i32 %57, i32 %58)
%60 = load i32*, i32** %3
%61 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %60, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%62 = load i32*, i32** %3
%63 = load i32, i32* %6
%64 = load i32, i32* %9
%65 = load i32, i32* %8
%66 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %62, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %63, i32 %64, i32 %65)
%67 = load i32*, i32** %3
%68 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %67, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%69 = load i32*, i32** %3
%70 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %69, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 0)
%71 = load i32*, i32** %3
%72 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %71, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%73 = load i32*, i32** %3
%74 = load i32, i32* %10
%75 = load i32, i32* %11
%76 = load i32, i32* %12
%77 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %73, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %74, i32 %75, i32 %76)
ret void
}

LLVM IR (-O2):
@.str = [50 x i8] c"setparams: Internal error: invalid class type %c\0A\00"
@.str.1 = [46 x i8] c"%sinteger nx_default, ny_default, nz_default\0A\00"
@.str.2 = [9 x i8] c" \00"
@.str.3 = [59 x i8] c"%sparameter (nx_default=%d, ny_default=%d, nz_default=%d)\0A\00"
@.str.4 = [39 x i8] c"%sinteger nit_default, lm, lt_default\0A\00"
@.str.5 = [54 x i8] c"%sparameter (nit_default=%d, lm = %d, lt_default=%d)\0A\00"
@.str.6 = [25 x i8] c"%sinteger debug_default\0A\00"
@.str.7 = [32 x i8] c"%sparameter (debug_default=%d)\0A\00"
@.str.8 = [31 x i8] c"%sinteger ndim1, ndim2, ndim3\0A\00"
@.str.9 = [50 x i8] c"%sparameter (ndim1 = %d, ndim2 = %d, ndim3 = %d)\0A\00"
define void @write_mg_info(i32* nocapture %0, i8 signext %1) {
switch i8 %1, label %7 [
i8 83, label %10
i8 87, label %3
i8 65, label %4
i8 66, label %5
i8 67, label %6
]
3: ; preds = %2
br label %10
4: ; preds = %2
br label %10
5: ; preds = %2
br label %10
6: ; preds = %2
br label %10
7: ; preds = %2
%8 = tail call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i8 signext %1)
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %2, %3, %5, %6, %4
%11 = phi i32 [ 40, %3 ], [ 4, %4 ], [ 20, %5 ], [ 20, %6 ], [ 4, %2 ]
%12 = phi i32 [ 64, %3 ], [ 256, %4 ], [ 256, %5 ], [ 512, %6 ], [ 32, %2 ]
%13 = tail call i32 @ilog2(i32 %12)
%14 = tail call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%15 = tail call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %12, i32 %12, i32 %12)
%16 = tail call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%17 = tail call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %11, i32 %13, i32 %13)
%18 = tail call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%19 = tail call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 0)
%20 = tail call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%21 = tail call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %13, i32 %13, i32 %13)
ret void
}