#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 */
scalar_t__ glbGetChiFunction(int, int, int, char *, int);
int /*<<< orphan*/ glb_error(char *);
scalar_t__ strcmp(char *, char *);
int glbGetErrorDim(int exp, int rule, int on_off) {
  char sys_id[100];
  int i;
  if (glbGetChiFunction(exp, rule, on_off, sys_id, 100) != 0) {
    glb_error("glbGetErrorDim: Invalid parameters");
    return -1;
  }
  if (strcmp(sys_id, "chiSpectrumTilt") == 0)
    return 0;
  else if (strcmp(sys_id, "chiNoSysSpectrum") == 0)
    return 2;
  else if (strcmp(sys_id, "chiTotalRatesTilt") == 0)
    return 4;
  else if (strcmp(sys_id, "chiSpectrumOnly") == 0)
    return 7;
  else if (strcmp(sys_id, "chiNoSysTotalRates") == 0)
    return 8;
  else if (strcmp(sys_id, "chiSpectrumCalib") == 0)
    return 9;
  else {
    glb_error("glbGetErrorDim: No error dimension associated with this chi^2 "
              "function");
    return -1;
  }
  return -1;
}


x86 assembly (clang, -O0):
<glbGetErrorDim>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    -0x80(%rbp),%rcx
mov    $0x64,%r8d
call   1050 <glbGetChiFunction@plt>
cmp    $0x0,%rax
je     117e <glbGetErrorDim+0x4e>
lea    0xe93(%rip),%rdi
call   1030 <glb_error@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1275 <glbGetErrorDim+0x145>
lea    -0x80(%rbp),%rdi
lea    0xe9a(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11a4 <glbGetErrorDim+0x74>
movl   $0x0,-0x4(%rbp)
jmp    1275 <glbGetErrorDim+0x145>
lea    -0x80(%rbp),%rdi
lea    0xe84(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11ca <glbGetErrorDim+0x9a>
movl   $0x2,-0x4(%rbp)
jmp    1275 <glbGetErrorDim+0x145>
lea    -0x80(%rbp),%rdi
lea    0xe6f(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11f0 <glbGetErrorDim+0xc0>
movl   $0x4,-0x4(%rbp)
jmp    1275 <glbGetErrorDim+0x145>
lea    -0x80(%rbp),%rdi
lea    0xe5b(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1216 <glbGetErrorDim+0xe6>
movl   $0x7,-0x4(%rbp)
jmp    1275 <glbGetErrorDim+0x145>
lea    -0x80(%rbp),%rdi
lea    0xe45(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    123c <glbGetErrorDim+0x10c>
movl   $0x8,-0x4(%rbp)
jmp    1275 <glbGetErrorDim+0x145>
lea    -0x80(%rbp),%rdi
lea    0xe32(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1262 <glbGetErrorDim+0x132>
movl   $0x9,-0x4(%rbp)
jmp    1275 <glbGetErrorDim+0x145>
lea    0xe21(%rip),%rdi
call   1030 <glb_error@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<glbGetErrorDim>:
sub    $0x68,%rsp
mov    %rsp,%rcx
mov    $0x64,%r8d
call   1050 <glbGetChiFunction@plt>
test   %rax,%rax
je     115d <glbGetErrorDim+0x2d>
lea    0xeb2(%rip),%rdi
call   1030 <glb_error@plt>
mov    $0xffffffff,%eax
add    $0x68,%rsp
ret
lea    0xebf(%rip),%rsi
mov    %rsp,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11e1 <glbGetErrorDim+0xb1>
lea    0xebb(%rip),%rsi
mov    %rsp,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11e8 <glbGetErrorDim+0xb8>
lea    0xeb8(%rip),%rsi
mov    %rsp,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11f2 <glbGetErrorDim+0xc2>
lea    0xeb6(%rip),%rsi
mov    %rsp,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11fc <glbGetErrorDim+0xcc>
lea    0xeb2(%rip),%rsi
mov    %rsp,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1206 <glbGetErrorDim+0xd6>
lea    0xeb1(%rip),%rsi
mov    %rsp,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1210 <glbGetErrorDim+0xe0>
lea    0xeae(%rip),%rdi
jmp    114e <glbGetErrorDim+0x1e>
xor    %eax,%eax
add    $0x68,%rsp
ret
mov    $0x2,%eax
add    $0x68,%rsp
ret
mov    $0x4,%eax
add    $0x68,%rsp
ret
mov    $0x7,%eax
add    $0x68,%rsp
ret
mov    $0x8,%eax
add    $0x68,%rsp
ret
mov    $0x9,%eax
add    $0x68,%rsp
ret

LLVM IR (-O0):
@.str = [35 x i8] c"glbGetErrorDim: Invalid parameters\00"
@.str.1 = [16 x i8] c"chiSpectrumTilt\00"
@.str.2 = [17 x i8] c"chiNoSysSpectrum\00"
@.str.3 = [18 x i8] c"chiTotalRatesTilt\00"
@.str.4 = [16 x i8] c"chiSpectrumOnly\00"
@.str.5 = [19 x i8] c"chiNoSysTotalRates\00"
@.str.6 = [17 x i8] c"chiSpectrumCalib\00"
@.str.7 = [71 x i8] c"glbGetErrorDim: No error dimension associated with this chi^2 function\00"
define i32 @glbGetErrorDim(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [100 x i8]
%9 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%10 = load i32, i32* %5
%11 = load i32, i32* %6
%12 = load i32, i32* %7
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%14 = call i64 @glbGetChiFunction(i32 %10, i32 %11, i32 %12, i8* %13, i32 100)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %3
%17 = call i32 @glb_error(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %4
br label %50
18: ; preds = %3
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%20 = call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %18
store i32 0, i32* %4
br label %50
23: ; preds = %18
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%25 = call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %23
store i32 2, i32* %4
br label %50
28: ; preds = %23
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%30 = call i64 @strcmp(i8* %29, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %28
store i32 4, i32* %4
br label %50
33: ; preds = %28
%34 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%35 = call i64 @strcmp(i8* %34, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %33
store i32 7, i32* %4
br label %50
38: ; preds = %33
%39 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%40 = call i64 @strcmp(i8* %39, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %43
42: ; preds = %38
store i32 8, i32* %4
br label %50
43: ; preds = %38
%44 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%45 = call i64 @strcmp(i8* %44, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %48
47: ; preds = %43
store i32 9, i32* %4
br label %50
48: ; preds = %43
%49 = call i32 @glb_error(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.7, i64 0, i64 0))
store i32 -1, i32* %4
br label %50
50: ; preds = %48, %47, %42, %37, %32, %27, %22, %16
%51 = load i32, i32* %4
ret i32 %51
}

LLVM IR (-O2):
@.str = [35 x i8] c"glbGetErrorDim: Invalid parameters\00"
@.str.1 = [16 x i8] c"chiSpectrumTilt\00"
@.str.2 = [17 x i8] c"chiNoSysSpectrum\00"
@.str.3 = [18 x i8] c"chiTotalRatesTilt\00"
@.str.4 = [16 x i8] c"chiSpectrumOnly\00"
@.str.5 = [19 x i8] c"chiNoSysTotalRates\00"
@.str.6 = [17 x i8] c"chiSpectrumCalib\00"
@.str.7 = [71 x i8] c"glbGetErrorDim: No error dimension associated with this chi^2 function\00"
define i32 @glbGetErrorDim(i32 %0, i32 %1, i32 %2) {
%4 = alloca [100 x i8]
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%6 = call i64 @glbGetChiFunction(i32 %0, i32 %1, i32 %2, i8* %5, i32 100)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %26
8: ; preds = %3
%9 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %29, label %11
11: ; preds = %8
%12 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %29, label %14
14: ; preds = %11
%15 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %29, label %17
17: ; preds = %14
%18 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %29, label %20
20: ; preds = %17
%21 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %29, label %23
23: ; preds = %20
%24 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %29, label %26
26: ; preds = %23, %3
%27 = phi i8* [ getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), %3 ], [ getelementptr inbounds ([71 x i8], [71 x i8]* @.str.7, i64 0, i64 0), %23 ]
%28 = call i32 @glb_error(i8* %27)
br label %29
29: ; preds = %26, %23, %20, %17, %14, %11, %8
%30 = phi i32 [ 0, %8 ], [ 2, %11 ], [ 4, %14 ], [ 7, %17 ], [ 8, %20 ], [ 9, %23 ], [ -1, %26 ]
ret i32 %30
}