#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*/ fixed_surfaces(unsigned char **, int *, float *, int *,
                                  int *, float *, int *);
int /*<<< orphan*/ level2(int, int, int, float, int, int, float, int, int,
                          char *);
int /*<<< orphan*/ sprintf(char *, char *, int, ...);
int /*<<< orphan*/ strlen(char *);
int f_lev(int mode, unsigned char **sec, float *data, unsigned int ndata,
          char *inv_out, void **local) {
  int level_type1, level_type2;
  float val1, val2;
  int undef_val1, undef_val2;
  int center, subcenter;
  if (mode < 0)
    return 0;
  center = ((int)((sec[1][5] << 8) + (sec[1][6])));
  subcenter = ((int)((sec[1][7] << 8) + (sec[1][8])));
  fixed_surfaces(sec, &level_type1, &val1, &undef_val1, &level_type2, &val2,
                 &undef_val2);
  if (mode > 1) {
    if (undef_val1 == 0)
      sprintf(inv_out, "lvl1=(%d,%lg) ", level_type1, val1);
    else
      sprintf(inv_out, "lvl1=(%d,missing) ", level_type1);
    inv_out += strlen(inv_out);
    if (undef_val2 == 0)
      sprintf(inv_out, "lvl2=(%d,%lg):", level_type2, val2);
    else
      sprintf(inv_out, "lvl2=(%d,missing):", level_type2);
    inv_out += strlen(inv_out);
  }
  level2(mode, level_type1, undef_val1, val1, level_type2, undef_val2, val2,
         center, subcenter, inv_out);
  return 0;
}


x86 assembly (clang, -O0):
<f_lev>:
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)
jge    1174 <f_lev+0x34>
movl   $0x0,-0x4(%rbp)
jmp    12d4 <f_lev+0x194>
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,-0x4c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movzbl 0x7(%rax),%eax
shl    $0x8,%eax
mov    -0x10(%rbp),%rcx
mov    0x8(%rcx),%rcx
movzbl 0x8(%rcx),%ecx
add    %ecx,%eax
mov    %eax,-0x50(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x34(%rbp),%rsi
lea    -0x3c(%rbp),%rdx
lea    -0x44(%rbp),%rcx
lea    -0x38(%rbp),%r8
lea    -0x40(%rbp),%r9
lea    -0x48(%rbp),%rax
mov    %rax,(%rsp)
call   1050 <fixed_surfaces@plt>
cmpl   $0x1,-0x8(%rbp)
jle    1299 <f_lev+0x159>
cmpl   $0x0,-0x44(%rbp)
jne    1210 <f_lev+0xd0>
mov    -0x28(%rbp),%rdi
mov    -0x34(%rbp),%edx
movss  -0x3c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdfc(%rip),%rsi
mov    $0x1,%al
call   1060 <sprintf@plt>
jmp    1225 <f_lev+0xe5>
mov    -0x28(%rbp),%rdi
mov    -0x34(%rbp),%edx
lea    0xdf1(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
cmpl   $0x0,-0x48(%rbp)
jne    126b <f_lev+0x12b>
mov    -0x28(%rbp),%rdi
mov    -0x38(%rbp),%edx
movss  -0x40(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdc3(%rip),%rsi
mov    $0x1,%al
call   1060 <sprintf@plt>
jmp    1280 <f_lev+0x140>
mov    -0x28(%rbp),%rdi
mov    -0x38(%rbp),%edx
lea    0xdb8(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x34(%rbp),%esi
mov    -0x44(%rbp),%edx
movss  -0x3c(%rbp),%xmm0
mov    -0x38(%rbp),%ecx
mov    -0x48(%rbp),%r8d
movss  -0x40(%rbp),%xmm1
mov    -0x4c(%rbp),%r9d
mov    -0x50(%rbp),%r10d
mov    -0x28(%rbp),%rax
mov    %r10d,(%rsp)
mov    %rax,0x8(%rsp)
call   1040 <level2@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f_lev>:
test   %edi,%edi
js     1277 <f_lev+0x137>
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %r8,%rbp
mov    %edi,%r14d
mov    0x8(%rsi),%rax
movzwl 0x5(%rax),%r15d
shl    $0x10,%r15d
bswap  %r15d
movzwl 0x7(%rax),%r12d
shl    $0x10,%r12d
bswap  %r12d
sub    $0x8,%rsp
lea    0x10(%rsp),%rbx
lea    0x24(%rsp),%rax
lea    0x1c(%rsp),%rdx
lea    0x14(%rsp),%rcx
lea    0x20(%rsp),%r8
lea    0x18(%rsp),%r9
mov    %rsi,%rdi
mov    %rax,%rsi
push   %rbx
call   1050 <fixed_surfaces@plt>
add    $0x10,%rsp
cmp    $0x2,%r14d
jb     1240 <f_lev+0x100>
cmpl   $0x0,0xc(%rsp)
mov    0x1c(%rsp),%edx
je     11d0 <f_lev+0x90>
lea    0xe4b(%rip),%rsi
mov    %rbp,%rdi
xor    %eax,%eax
call   1060 <sprintf@plt>
jmp    11eb <f_lev+0xab>
movss  0x14(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe1f(%rip),%rsi
mov    %rbp,%rdi
mov    $0x1,%al
call   1060 <sprintf@plt>
mov    %rbp,%rdi
call   1030 <strlen@plt>
movslq %eax,%rbx
add    %rbp,%rbx
cmpl   $0x0,0x8(%rsp)
mov    0x18(%rsp),%edx
je     1217 <f_lev+0xd7>
lea    0xe26(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <sprintf@plt>
jmp    1232 <f_lev+0xf2>
movss  0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdfa(%rip),%rsi
mov    %rbx,%rdi
mov    $0x1,%al
call   1060 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
movslq %eax,%rbp
add    %rbx,%rbp
mov    0x1c(%rsp),%esi
mov    0xc(%rsp),%edx
movss  0x14(%rsp),%xmm0
mov    0x18(%rsp),%ecx
mov    0x8(%rsp),%r8d
movss  0x10(%rsp),%xmm1
mov    %r14d,%edi
mov    %r15d,%r9d
push   %rbp
push   %r12
call   1040 <level2@plt>
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
xor    %eax,%eax
ret

LLVM IR (-O0):
@.str = [15 x i8] c"lvl1=(%d,%lg) \00"
@.str.1 = [19 x i8] c"lvl1=(%d,missing) \00"
@.str.2 = [15 x i8] c"lvl2=(%d,%lg):\00"
@.str.3 = [19 x i8] c"lvl2=(%d,missing):\00"
define i32 @f_lev(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 float
%17 = alloca float
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = 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
%22 = load i32, i32* %8
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %6
store i32 0, i32* %7
br label %107
25: ; preds = %6
%26 = load i8**, i8*** %9
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = getelementptr inbounds i8, i8* %28, i64 5
%30 = load i8, i8* %29
%31 = zext i8 %30 to i32
%32 = shl i32 %31, 8
%33 = load i8**, i8*** %9
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
%36 = getelementptr inbounds i8, i8* %35, i64 6
%37 = load i8, i8* %36
%38 = zext i8 %37 to i32
%39 = add nsw i32 %32, %38
store i32 %39, i32* %20
%40 = load i8**, i8*** %9
%41 = getelementptr inbounds i8*, i8** %40, i64 1
%42 = load i8*, i8** %41
%43 = getelementptr inbounds i8, i8* %42, i64 7
%44 = load i8, i8* %43
%45 = zext i8 %44 to i32
%46 = shl i32 %45, 8
%47 = load i8**, i8*** %9
%48 = getelementptr inbounds i8*, i8** %47, i64 1
%49 = load i8*, i8** %48
%50 = getelementptr inbounds i8, i8* %49, i64 8
%51 = load i8, i8* %50
%52 = zext i8 %51 to i32
%53 = add nsw i32 %46, %52
store i32 %53, i32* %21
%54 = load i8**, i8*** %9
%55 = call i32 @fixed_surfaces(i8** %54, i32* %14, float* %16, i32* %18, i32* %15, float* %17, i32* %19)
%56 = load i32, i32* %8
%57 = icmp sgt i32 %56, 1
br i1 %57, label %58, label %95
58: ; preds = %25
%59 = load i32, i32* %18
%60 = icmp eq i32 %59, 0
br i1 %60, label %61, label %67
61: ; preds = %58
%62 = load i8*, i8** %12
%63 = load i32, i32* %14
%64 = load float, float* %16
%65 = fpext float %64 to double
%66 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %62, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %63, double %65)
br label %71
67: ; preds = %58
%68 = load i8*, i8** %12
%69 = load i32, i32* %14
%70 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %68, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %69)
br label %71
71: ; preds = %67, %61
%72 = load i8*, i8** %12
%73 = call i32 @strlen(i8* %72)
%74 = load i8*, i8** %12
%75 = sext i32 %73 to i64
%76 = getelementptr inbounds i8, i8* %74, i64 %75
store i8* %76, i8** %12
%77 = load i32, i32* %19
%78 = icmp eq i32 %77, 0
br i1 %78, label %79, label %85
79: ; preds = %71
%80 = load i8*, i8** %12
%81 = load i32, i32* %15
%82 = load float, float* %17
%83 = fpext float %82 to double
%84 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %80, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %81, double %83)
br label %89
85: ; preds = %71
%86 = load i8*, i8** %12
%87 = load i32, i32* %15
%88 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %86, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %87)
br label %89
89: ; preds = %85, %79
%90 = load i8*, i8** %12
%91 = call i32 @strlen(i8* %90)
%92 = load i8*, i8** %12
%93 = sext i32 %91 to i64
%94 = getelementptr inbounds i8, i8* %92, i64 %93
store i8* %94, i8** %12
br label %95
95: ; preds = %89, %25
%96 = load i32, i32* %8
%97 = load i32, i32* %14
%98 = load i32, i32* %18
%99 = load float, float* %16
%100 = load i32, i32* %15
%101 = load i32, i32* %19
%102 = load float, float* %17
%103 = load i32, i32* %20
%104 = load i32, i32* %21
%105 = load i8*, i8** %12
%106 = call i32 @level2(i32 %96, i32 %97, i32 %98, float %99, i32 %100, i32 %101, float %102, i32 %103, i32 %104, i8* %105)
store i32 0, i32* %7
br label %107
107: ; preds = %95, %24
%108 = load i32, i32* %7
ret i32 %108
}

LLVM IR (-O2):
@.str = [15 x i8] c"lvl1=(%d,%lg) \00"
@.str.1 = [19 x i8] c"lvl1=(%d,missing) \00"
@.str.2 = [15 x i8] c"lvl2=(%d,%lg):\00"
@.str.3 = [19 x i8] c"lvl2=(%d,missing):\00"
define i32 @f_lev(i32 %0, i8** %1, float* nocapture readnone %2, i32 %3, i8* %4, i8** nocapture readnone %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca float
%10 = alloca float
%11 = alloca i32
%12 = alloca i32
%13 = bitcast i32* %7 to i8*
%14 = bitcast i32* %8 to i8*
%15 = bitcast float* %9 to i8*
%16 = bitcast float* %10 to i8*
%17 = bitcast i32* %11 to i8*
%18 = bitcast i32* %12 to i8*
%19 = icmp slt i32 %0, 0
br i1 %19, label %77, label %20
20: ; preds = %6
%21 = getelementptr inbounds i8*, i8** %1, i64 1
%22 = load i8*, i8** %21
%23 = getelementptr inbounds i8, i8* %22, i64 5
%24 = load i8, i8* %23
%25 = zext i8 %24 to i32
%26 = shl nuw nsw i32 %25, 8
%27 = getelementptr inbounds i8, i8* %22, i64 6
%28 = load i8, i8* %27
%29 = zext i8 %28 to i32
%30 = or i32 %26, %29
%31 = getelementptr inbounds i8, i8* %22, i64 7
%32 = load i8, i8* %31
%33 = zext i8 %32 to i32
%34 = shl nuw nsw i32 %33, 8
%35 = getelementptr inbounds i8, i8* %22, i64 8
%36 = load i8, i8* %35
%37 = zext i8 %36 to i32
%38 = or i32 %34, %37
%39 = call i32 @fixed_surfaces(i8** %1, i32* %7, float* %9, i32* %11, i32* %8, float* %10, i32* %12)
%40 = icmp ugt i32 %0, 1
br i1 %40, label %41, label %68
41: ; preds = %20
%42 = load i32, i32* %11
%43 = icmp eq i32 %42, 0
%44 = load i32, i32* %7
br i1 %43, label %45, label %49
45: ; preds = %41
%46 = load float, float* %9
%47 = fpext float %46 to double
%48 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* dereferenceable(1) %4, i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %44, double %47)
br label %51
49: ; preds = %41
%50 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* dereferenceable(1) %4, i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %44)
br label %51
51: ; preds = %49, %45
%52 = call i32 @strlen(i8* %4)
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8, i8* %4, i64 %53
%55 = load i32, i32* %12
%56 = icmp eq i32 %55, 0
%57 = load i32, i32* %8
br i1 %56, label %58, label %62
58: ; preds = %51
%59 = load float, float* %10
%60 = fpext float %59 to double
%61 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* dereferenceable(1) %54, i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %57, double %60)
br label %64
62: ; preds = %51
%63 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* dereferenceable(1) %54, i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %57)
br label %64
64: ; preds = %62, %58
%65 = call i32 @strlen(i8* %54)
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i8, i8* %54, i64 %66
br label %68
68: ; preds = %64, %20
%69 = phi i8* [ %67, %64 ], [ %4, %20 ]
%70 = load i32, i32* %7
%71 = load i32, i32* %11
%72 = load float, float* %9
%73 = load i32, i32* %8
%74 = load i32, i32* %12
%75 = load float, float* %10
%76 = call i32 @level2(i32 %0, i32 %70, i32 %71, float %72, i32 %73, i32 %74, float %75, i32 %30, i32 %38, i8* %69)
br label %77
77: ; preds = %6, %68
ret i32 0
}