#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 /*<<< orphan*/ sprintf(char *, char *, ...);
int f_varX(int mode, unsigned char **sec, float *data, unsigned int ndata,
           char *inv_out, void **local) {
  int discipline, center, mastertab, localtab, parmcat, parmnum;
  if (mode >= 0) {
    discipline = ((int)(sec[0][6]));
    center = ((int)((sec[1][5] << 8) + (sec[1][6])));
    mastertab = ((int)(sec[1][9]));
    localtab = ((int)(sec[1][10]));
    parmcat = (sec[4][9]);
    parmnum = (sec[4][10]);
    if (mode == 0) {
      if (parmnum == 255) {
        sprintf(inv_out, "missing");
        return 0;
      }
      sprintf(inv_out, "var%d_%d_%d_%d_%d_%d", discipline, mastertab, localtab,
              center, parmcat, parmnum);
    } else if (mode > 0) {
      if (parmnum == 255) {
        sprintf(inv_out, "missing definition [?]");
        return 0;
      }
      if (parmnum < 192) {
        sprintf(inv_out, "var discipline=%d master_table=%d parmcat=%d parm=%d",
                discipline, mastertab, parmcat, parmnum);
      } else {
        sprintf(inv_out,
                "var discipline=%d center=%d local_table=%d parmcat=%d parm=%d",
                discipline, center, localtab, parmcat, parmnum);
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<f_varX>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     12a7 <f_varX+0x197>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movzbl 0x6(%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movzbl 0x5(%rax),%eax
shl    $0x8,%eax
mov    -0x10(%rbp),%rcx
mov    0x8(%rcx),%rcx
movzbl 0x6(%rcx),%ecx
add    %ecx,%eax
mov    %eax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movzbl 0x9(%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movzbl 0xa(%rax),%eax
mov    %eax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
movzbl 0x9(%rax),%eax
mov    %eax,-0x44(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
movzbl 0xa(%rax),%eax
mov    %eax,-0x48(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    120b <f_varX+0xfb>
cmpl   $0xff,-0x48(%rbp)
jne    11d7 <f_varX+0xc7>
mov    -0x28(%rbp),%rdi
lea    0xe3c(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12ae <f_varX+0x19e>
mov    -0x28(%rbp),%rdi
mov    -0x34(%rbp),%edx
mov    -0x3c(%rbp),%ecx
mov    -0x40(%rbp),%r8d
mov    -0x38(%rbp),%r9d
mov    -0x44(%rbp),%r10d
mov    -0x48(%rbp),%eax
lea    0xe11(%rip),%rsi
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    12a2 <f_varX+0x192>
cmpl   $0x0,-0x8(%rbp)
jle    129d <f_varX+0x18d>
cmpl   $0xff,-0x48(%rbp)
jne    1240 <f_varX+0x130>
mov    -0x28(%rbp),%rdi
lea    0xdf0(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12ae <f_varX+0x19e>
cmpl   $0xc0,-0x48(%rbp)
jge    1272 <f_varX+0x162>
mov    -0x28(%rbp),%rdi
mov    -0x34(%rbp),%edx
mov    -0x3c(%rbp),%ecx
mov    -0x44(%rbp),%r8d
mov    -0x48(%rbp),%r9d
lea    0xdce(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    1298 <f_varX+0x188>
mov    -0x28(%rbp),%rdi
mov    -0x34(%rbp),%edx
mov    -0x38(%rbp),%ecx
mov    -0x40(%rbp),%r8d
mov    -0x44(%rbp),%r9d
mov    -0x48(%rbp),%eax
lea    0xddb(%rip),%rsi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    129d <f_varX+0x18d>
jmp    12a2 <f_varX+0x192>
jmp    12a7 <f_varX+0x197>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f_varX>:
push   %rax
test   %edi,%edi
js     11d8 <f_varX+0xc8>
mov    (%rsi),%rcx
mov    0x8(%rsi),%rax
movzbl 0x6(%rcx),%edx
movzwl 0x5(%rax),%r9d
shl    $0x10,%r9d
bswap  %r9d
movzbl 0x9(%rax),%ecx
movzbl 0xa(%rax),%eax
mov    0x20(%rsi),%rsi
movzbl 0x9(%rsi),%r10d
movzbl 0xa(%rsi),%r11d
test   %edi,%edi
je     116f <f_varX+0x5f>
cmp    $0xff,%r11b
je     118a <f_varX+0x7a>
cmp    $0xbf,%r11b
ja     11a5 <f_varX+0x95>
lea    0xecf(%rip),%rsi
mov    %r8,%rdi
mov    %r10d,%r8d
mov    %r11d,%r9d
xor    %eax,%eax
call   1030 <sprintf@plt>
jmp    11d8 <f_varX+0xc8>
cmp    $0xff,%r11b
je     11cb <f_varX+0xbb>
lea    0xe84(%rip),%rsi
mov    %r8,%rdi
mov    %eax,%r8d
xor    %eax,%eax
push   %r11
push   %r10
jmp    11c0 <f_varX+0xb0>
movups 0xe84(%rip),%xmm0
movups %xmm0,(%r8)
movabs $0x5d3f5b206e6f69,%rax
mov    %rax,0xf(%r8)
jmp    11d8 <f_varX+0xc8>
sub    $0x8,%rsp
lea    0xeb1(%rip),%rsi
mov    %r8,%rdi
mov    %r9d,%ecx
mov    %eax,%r8d
mov    %r10d,%r9d
xor    %eax,%eax
push   %r11
call   1030 <sprintf@plt>
add    $0x10,%rsp
jmp    11d8 <f_varX+0xc8>
movabs $0x676e697373696d,%rax
mov    %rax,(%r8)
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"missing\00"
@.str.1 = [21 x i8] c"var%d_%d_%d_%d_%d_%d\00"
@.str.2 = [23 x i8] c"missing definition [?]\00"
@.str.3 = [53 x i8] c"var discipline=%d master_table=%d parmcat=%d parm=%d\00"
@.str.4 = [62 x i8] c"var discipline=%d center=%d local_table=%d parmcat=%d parm=%d\00"
define i32 @f_varX(i32 %0, i8** %1, float* %2, i32 %3, i8* %4, i8** %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8**
%10 = alloca float*
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i8**
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
store i32 %0, i32* %8
store i8** %1, i8*** %9
store float* %2, float** %10
store i32 %3, i32* %11
store i8* %4, i8** %12
store i8** %5, i8*** %13
%20 = load i32, i32* %8
%21 = icmp sge i32 %20, 0
br i1 %21, label %22, label %114
22: ; preds = %6
%23 = load i8**, i8*** %9
%24 = getelementptr inbounds i8*, i8** %23, i64 0
%25 = load i8*, i8** %24
%26 = getelementptr inbounds i8, i8* %25, i64 6
%27 = load i8, i8* %26
%28 = zext i8 %27 to i32
store i32 %28, i32* %14
%29 = load i8**, i8*** %9
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = getelementptr inbounds i8, i8* %31, i64 5
%33 = load i8, i8* %32
%34 = zext i8 %33 to i32
%35 = shl i32 %34, 8
%36 = load i8**, i8*** %9
%37 = getelementptr inbounds i8*, i8** %36, i64 1
%38 = load i8*, i8** %37
%39 = getelementptr inbounds i8, i8* %38, i64 6
%40 = load i8, i8* %39
%41 = zext i8 %40 to i32
%42 = add nsw i32 %35, %41
store i32 %42, i32* %15
%43 = load i8**, i8*** %9
%44 = getelementptr inbounds i8*, i8** %43, i64 1
%45 = load i8*, i8** %44
%46 = getelementptr inbounds i8, i8* %45, i64 9
%47 = load i8, i8* %46
%48 = zext i8 %47 to i32
store i32 %48, i32* %16
%49 = load i8**, i8*** %9
%50 = getelementptr inbounds i8*, i8** %49, i64 1
%51 = load i8*, i8** %50
%52 = getelementptr inbounds i8, i8* %51, i64 10
%53 = load i8, i8* %52
%54 = zext i8 %53 to i32
store i32 %54, i32* %17
%55 = load i8**, i8*** %9
%56 = getelementptr inbounds i8*, i8** %55, i64 4
%57 = load i8*, i8** %56
%58 = getelementptr inbounds i8, i8* %57, i64 9
%59 = load i8, i8* %58
%60 = zext i8 %59 to i32
store i32 %60, i32* %18
%61 = load i8**, i8*** %9
%62 = getelementptr inbounds i8*, i8** %61, i64 4
%63 = load i8*, i8** %62
%64 = getelementptr inbounds i8, i8* %63, i64 10
%65 = load i8, i8* %64
%66 = zext i8 %65 to i32
store i32 %66, i32* %19
%67 = load i32, i32* %8
%68 = icmp eq i32 %67, 0
br i1 %68, label %69, label %84
69: ; preds = %22
%70 = load i32, i32* %19
%71 = icmp eq i32 %70, 255
br i1 %71, label %72, label %75
72: ; preds = %69
%73 = load i8*, i8** %12
%74 = call i32 (i8*, i8*, ...) @sprintf(i8* %73, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %7
br label %115
75: ; preds = %69
%76 = load i8*, i8** %12
%77 = load i32, i32* %14
%78 = load i32, i32* %16
%79 = load i32, i32* %17
%80 = load i32, i32* %15
%81 = load i32, i32* %18
%82 = load i32, i32* %19
%83 = call i32 (i8*, i8*, ...) @sprintf(i8* %76, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %77, i32 %78, i32 %79, i32 %80, i32 %81, i32 %82)
br label %113
84: ; preds = %22
%85 = load i32, i32* %8
%86 = icmp sgt i32 %85, 0
br i1 %86, label %87, label %112
87: ; preds = %84
%88 = load i32, i32* %19
%89 = icmp eq i32 %88, 255
br i1 %89, label %90, label %93
90: ; preds = %87
%91 = load i8*, i8** %12
%92 = call i32 (i8*, i8*, ...) @sprintf(i8* %91, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %7
br label %115
93: ; preds = %87
%94 = load i32, i32* %19
%95 = icmp slt i32 %94, 192
br i1 %95, label %96, label %103
96: ; preds = %93
%97 = load i8*, i8** %12
%98 = load i32, i32* %14
%99 = load i32, i32* %16
%100 = load i32, i32* %18
%101 = load i32, i32* %19
%102 = call i32 (i8*, i8*, ...) @sprintf(i8* %97, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0), i32 %98, i32 %99, i32 %100, i32 %101)
br label %111
103: ; preds = %93
%104 = load i8*, i8** %12
%105 = load i32, i32* %14
%106 = load i32, i32* %15
%107 = load i32, i32* %17
%108 = load i32, i32* %18
%109 = load i32, i32* %19
%110 = call i32 (i8*, i8*, ...) @sprintf(i8* %104, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.4, i64 0, i64 0), i32 %105, i32 %106, i32 %107, i32 %108, i32 %109)
br label %111
111: ; preds = %103, %96
br label %112
112: ; preds = %111, %84
br label %113
113: ; preds = %112, %75
br label %114
114: ; preds = %113, %6
store i32 0, i32* %7
br label %115
115: ; preds = %114, %90, %72
%116 = load i32, i32* %7
ret i32 %116
}

LLVM IR (-O2):
@.str.1 = [21 x i8] c"var%d_%d_%d_%d_%d_%d\00"
@.str.2 = [23 x i8] c"missing definition [?]\00"
@.str.3 = [53 x i8] c"var discipline=%d master_table=%d parmcat=%d parm=%d\00"
@.str.4 = [62 x i8] c"var discipline=%d center=%d local_table=%d parmcat=%d parm=%d\00"
define i32 @f_varX(i32 %0, i8** nocapture %1, float* nocapture readnone %2, i32 %3, i8* nocapture writeonly %4, i8** nocapture readnone %5) {
%7 = icmp sgt i32 %0, -1
br i1 %7, label %8, label %52
8: ; preds = %6
%9 = load i8*, i8** %1
%10 = getelementptr inbounds i8, i8* %9, i64 6
%11 = load i8, i8* %10
%12 = zext i8 %11 to i32
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = getelementptr inbounds i8, i8* %14, i64 5
%16 = load i8, i8* %15
%17 = zext i8 %16 to i32
%18 = shl nuw nsw i32 %17, 8
%19 = getelementptr inbounds i8, i8* %14, i64 6
%20 = load i8, i8* %19
%21 = zext i8 %20 to i32
%22 = or i32 %18, %21
%23 = getelementptr inbounds i8, i8* %14, i64 9
%24 = load i8, i8* %23
%25 = zext i8 %24 to i32
%26 = getelementptr inbounds i8, i8* %14, i64 10
%27 = load i8, i8* %26
%28 = zext i8 %27 to i32
%29 = getelementptr inbounds i8*, i8** %1, i64 4
%30 = load i8*, i8** %29
%31 = getelementptr inbounds i8, i8* %30, i64 9
%32 = load i8, i8* %31
%33 = zext i8 %32 to i32
%34 = getelementptr inbounds i8, i8* %30, i64 10
%35 = load i8, i8* %34
%36 = zext i8 %35 to i32
%37 = icmp eq i32 %0, 0
%38 = icmp eq i8 %35, -1
br i1 %37, label %39, label %44
39: ; preds = %8
br i1 %38, label %40, label %42
40: ; preds = %39
%41 = bitcast i8* %4 to i64*
store i64 29113321788762477, i64* %41
br label %52
42: ; preds = %39
%43 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %4, i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %12, i32 %25, i32 %28, i32 %22, i32 %33, i32 %36)
br label %52
44: ; preds = %8
br i1 %38, label %45, label %46
45: ; preds = %44
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(23) %4, i8* align 1 dereferenceable(23) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i64 23, i1 false)
br label %52
46: ; preds = %44
%47 = icmp ult i8 %35, -64
br i1 %47, label %48, label %50
48: ; preds = %46
%49 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %4, i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0), i32 %12, i32 %25, i32 %33, i32 %36)
br label %52
50: ; preds = %46
%51 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %4, i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @.str.4, i64 0, i64 0), i32 %12, i32 %22, i32 %28, i32 %33, i32 %36)
br label %52
52: ; preds = %6, %50, %48, %42, %45, %40
ret i32 0
}