#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 *, int);
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, "#define\tNX_DEFAULT\t%d\n", problem_size);
  fprintf(fp, "#define\tNY_DEFAULT\t%d\n", problem_size);
  fprintf(fp, "#define\tNZ_DEFAULT\t%d\n", problem_size);
  fprintf(fp, "#define\tNIT_DEFAULT\t%d\n", nit);
  fprintf(fp, "#define\tLM\t%d\n", lm);
  fprintf(fp, "#define\tLT_DEFAULT\t%d\n", lt_default);
  fprintf(fp, "#define\tDEBUG_DEFAULT\t%d\n", 0);
  fprintf(fp, "#define\tNDIM1\t%d\n", ndim1);
  fprintf(fp, "#define\tNDIM2\t%d\n", ndim2);
  fprintf(fp, "#define\tNDIM3\t%d\n", 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
mov    -0x10(%rbp),%edx
lea    0xddb(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%edx
lea    0xddf(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%edx
lea    0xde3(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xde7(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%edx
lea    0xdec(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    0xde8(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xdef(%rip),%rsi
xor    %edx,%edx
call   1050 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%edx
lea    0xdf4(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%edx
lea    0xdf3(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x2c(%rbp),%edx
lea    0xdf2(%rip),%rsi
call   1050 <fprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_mg_info>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    -0x41(%rsi),%eax
cmp    $0x16,%al
ja     1263 <write_mg_info+0x123>
mov    %rdi,%rbx
mov    $0x20,%ebp
mov    $0x4,%r14d
movzbl %al,%eax
lea    0xe96(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x100,%ebp
jmp    119f <write_mg_info+0x5f>
mov    $0x100,%ebp
mov    $0x14,%r14d
jmp    119f <write_mg_info+0x5f>
mov    $0x200,%ebp
mov    $0x14,%r14d
jmp    119f <write_mg_info+0x5f>
mov    $0x40,%ebp
mov    $0x28,%r14d
mov    %ebp,%edi
call   1030 <ilog2@plt>
mov    %eax,%r15d
lea    0xede(%rip),%rsi
mov    %rbx,%rdi
mov    %ebp,%edx
call   1050 <fprintf@plt>
lea    0xee4(%rip),%rsi
mov    %rbx,%rdi
mov    %ebp,%edx
call   1050 <fprintf@plt>
lea    0xeea(%rip),%rsi
mov    %rbx,%rdi
mov    %ebp,%edx
call   1050 <fprintf@plt>
lea    0xef0(%rip),%rsi
mov    %rbx,%rdi
mov    %r14d,%edx
call   1050 <fprintf@plt>
lea    0xef6(%rip),%rsi
mov    %rbx,%rdi
mov    %r15d,%edx
call   1050 <fprintf@plt>
lea    0xef3(%rip),%rsi
mov    %rbx,%rdi
mov    %r15d,%edx
call   1050 <fprintf@plt>
lea    0xef8(%rip),%rsi
mov    %rbx,%rdi
xor    %edx,%edx
call   1050 <fprintf@plt>
lea    0xf01(%rip),%rsi
mov    %rbx,%rdi
mov    %r15d,%edx
call   1050 <fprintf@plt>
lea    0xf01(%rip),%rsi
mov    %rbx,%rdi
mov    %r15d,%edx
call   1050 <fprintf@plt>
lea    0xf01(%rip),%rsi
mov    %rbx,%rdi
mov    %r15d,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <fprintf@plt>
movsbl %sil,%esi
lea    0xdee(%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 = [23 x i8] c"#define\09NX_DEFAULT\09%d\0A\00"
@.str.2 = [23 x i8] c"#define\09NY_DEFAULT\09%d\0A\00"
@.str.3 = [23 x i8] c"#define\09NZ_DEFAULT\09%d\0A\00"
@.str.4 = [24 x i8] c"#define\09NIT_DEFAULT\09%d\0A\00"
@.str.5 = [15 x i8] c"#define\09LM\09%d\0A\00"
@.str.6 = [23 x i8] c"#define\09LT_DEFAULT\09%d\0A\00"
@.str.7 = [26 x i8] c"#define\09DEBUG_DEFAULT\09%d\0A\00"
@.str.8 = [18 x i8] c"#define\09NDIM1\09%d\0A\00"
@.str.9 = [18 x i8] c"#define\09NDIM2\09%d\0A\00"
@.str.10 = [18 x i8] c"#define\09NDIM3\09%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 = load i32, i32* %5
%55 = call i32 @fprintf(i32* %53, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %54)
%56 = load i32*, i32** %3
%57 = load i32, i32* %5
%58 = call i32 @fprintf(i32* %56, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %57)
%59 = load i32*, i32** %3
%60 = load i32, i32* %5
%61 = call i32 @fprintf(i32* %59, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %60)
%62 = load i32*, i32** %3
%63 = load i32, i32* %6
%64 = call i32 @fprintf(i32* %62, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i32 %63)
%65 = load i32*, i32** %3
%66 = load i32, i32* %9
%67 = call i32 @fprintf(i32* %65, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %66)
%68 = load i32*, i32** %3
%69 = load i32, i32* %8
%70 = call i32 @fprintf(i32* %68, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i32 %69)
%71 = load i32*, i32** %3
%72 = call i32 @fprintf(i32* %71, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), i32 0)
%73 = load i32*, i32** %3
%74 = load i32, i32* %10
%75 = call i32 @fprintf(i32* %73, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), i32 %74)
%76 = load i32*, i32** %3
%77 = load i32, i32* %11
%78 = call i32 @fprintf(i32* %76, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i32 %77)
%79 = load i32*, i32** %3
%80 = load i32, i32* %12
%81 = call i32 @fprintf(i32* %79, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0), i32 %80)
ret void
}

LLVM IR (-O2):
@.str = [50 x i8] c"setparams: Internal error: invalid class type %c\0A\00"
@.str.1 = [23 x i8] c"#define\09NX_DEFAULT\09%d\0A\00"
@.str.2 = [23 x i8] c"#define\09NY_DEFAULT\09%d\0A\00"
@.str.3 = [23 x i8] c"#define\09NZ_DEFAULT\09%d\0A\00"
@.str.4 = [24 x i8] c"#define\09NIT_DEFAULT\09%d\0A\00"
@.str.5 = [15 x i8] c"#define\09LM\09%d\0A\00"
@.str.6 = [23 x i8] c"#define\09LT_DEFAULT\09%d\0A\00"
@.str.7 = [26 x i8] c"#define\09DEBUG_DEFAULT\09%d\0A\00"
@.str.8 = [18 x i8] c"#define\09NDIM1\09%d\0A\00"
@.str.9 = [18 x i8] c"#define\09NDIM2\09%d\0A\00"
@.str.10 = [18 x i8] c"#define\09NDIM3\09%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 @fprintf(i32* %0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%15 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%16 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %12)
%17 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i32 %11)
%18 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %13)
%19 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i32 %13)
%20 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), i32 0)
%21 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), i32 %13)
%22 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i32 %13)
%23 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0), i32 %13)
ret void
}