#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 code_table_6_0(unsigned char **);
int /*<<< orphan*/ fatal_error(char *, char *);
unsigned int missing_points(unsigned char *, unsigned int);
int /*<<< orphan*/ sprintf(char *, char *, ...);
unsigned int uint4(unsigned char *);
int f_bitmap(int mode, unsigned char **sec, float *data, unsigned int ndata,
             char *inv_out, void **local) {
  int i;
  unsigned int nmiss;
  if (mode >= 0) {
    i = code_table_6_0(sec);
    if (i == 0) {
      nmiss = uint4(sec[3] + 6) - (sec[5] ? uint4(sec[5] + 5) : 0);
      sprintf(inv_out, "bitmap %d undef pts", nmiss);
      if (nmiss != missing_points(sec[6] + 6, uint4(sec[3] + 6)))
        fatal_error("inconsistent number of undefined points", "");
    } else if (i == 255) {
      sprintf(inv_out, "no bitmap");
    } else if (i == 254) {
      sprintf(inv_out, "old bitmap");
    } else {
      sprintf(inv_out, "predefined bitmap #%d", i);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<f_bitmap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
cmpl   $0x0,-0x4(%rbp)
jl     12b7 <f_bitmap+0x167>
mov    -0x10(%rbp),%rdi
call   1050 <code_table_6_0@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jne    124b <f_bitmap+0xfb>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
add    $0x6,%rdi
call   1030 <uint4@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x28(%rax)
je     11ca <f_bitmap+0x7a>
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdi
add    $0x5,%rdi
call   1030 <uint4@plt>
mov    %eax,-0x40(%rbp)
jmp    11d4 <f_bitmap+0x84>
xor    %eax,%eax
mov    %eax,-0x40(%rbp)
jmp    11d4 <f_bitmap+0x84>
mov    -0x3c(%rbp),%eax
mov    -0x40(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x38(%rbp),%edx
lea    0xe13(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
mov    -0x38(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x10(%rbp),%rax
mov    0x30(%rax),%rax
add    $0x6,%rax
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
add    $0x6,%rdi
call   1030 <uint4@plt>
mov    -0x50(%rbp),%rdi
mov    %eax,%esi
call   1070 <missing_points@plt>
mov    %eax,%ecx
mov    -0x44(%rbp),%eax
cmp    %ecx,%eax
je     1246 <f_bitmap+0xf6>
lea    0xdda(%rip),%rdi
lea    0xe25(%rip),%rsi
call   1040 <fatal_error@plt>
jmp    12b2 <f_bitmap+0x162>
cmpl   $0xff,-0x34(%rbp)
jne    126f <f_bitmap+0x11f>
mov    -0x28(%rbp),%rdi
lea    0xdd9(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
jmp    12ad <f_bitmap+0x15d>
cmpl   $0xfe,-0x34(%rbp)
jne    1293 <f_bitmap+0x143>
mov    -0x28(%rbp),%rdi
lea    0xdbf(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
jmp    12a8 <f_bitmap+0x158>
mov    -0x28(%rbp),%rdi
mov    -0x34(%rbp),%edx
lea    0xdb0(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
jmp    12ad <f_bitmap+0x15d>
jmp    12b2 <f_bitmap+0x162>
jmp    12b7 <f_bitmap+0x167>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f_bitmap>:
push   %rbp
push   %r14
push   %rbx
test   %edi,%edi
js     122e <f_bitmap+0xde>
mov    %r8,%r14
mov    %rsi,%rbx
mov    %rsi,%rdi
call   1050 <code_table_6_0@plt>
cmp    $0xff,%eax
je     119f <f_bitmap+0x4f>
cmp    $0xfe,%eax
je     11b5 <f_bitmap+0x65>
test   %eax,%eax
jne    11cc <f_bitmap+0x7c>
mov    0x18(%rbx),%rdi
add    $0x6,%rdi
call   1030 <uint4@plt>
mov    %eax,%ebp
mov    0x28(%rbx),%rdi
test   %rdi,%rdi
je     11e1 <f_bitmap+0x91>
add    $0x5,%rdi
call   1030 <uint4@plt>
jmp    11e3 <f_bitmap+0x93>
movabs $0x616d746962206f6e,%rax
74 6d 61
mov    %rax,(%r14)
movw   $0x70,0x8(%r14)
jmp    122e <f_bitmap+0xde>
movabs $0x6d74696220646c6f,%rax
69 74 6d
mov    %rax,(%r14)
movl   $0x70616d,0x7(%r14)
jmp    122e <f_bitmap+0xde>
lea    0xe7e(%rip),%rsi
mov    %r14,%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <sprintf@plt>
jmp    122e <f_bitmap+0xde>
xor    %eax,%eax
sub    %eax,%ebp
lea    0xe14(%rip),%rsi
mov    %r14,%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1060 <sprintf@plt>
mov    0x18(%rbx),%rdi
mov    0x30(%rbx),%rbx
add    $0x6,%rbx
add    $0x6,%rdi
call   1030 <uint4@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1070 <missing_points@plt>
cmp    %eax,%ebp
je     122e <f_bitmap+0xde>
lea    0xdf2(%rip),%rdi
lea    0xe3d(%rip),%rsi
call   1040 <fatal_error@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"bitmap %d undef pts\00"
@.str.1 = [40 x i8] c"inconsistent number of undefined points\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [10 x i8] c"no bitmap\00"
@.str.4 = [11 x i8] c"old bitmap\00"
@.str.5 = [22 x i8] c"predefined bitmap #%d\00"
define i32 @f_bitmap(i32 %0, i8** %1, float* %2, i32 %3, i8* %4, i8** %5) {
%7 = alloca i32
%8 = alloca i8**
%9 = alloca float*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8**
%13 = alloca i32
%14 = alloca i32
store i32 %0, i32* %7
store i8** %1, i8*** %8
store float* %2, float** %9
store i32 %3, i32* %10
store i8* %4, i8** %11
store i8** %5, i8*** %12
%15 = load i32, i32* %7
%16 = icmp sge i32 %15, 0
br i1 %16, label %17, label %79
17: ; preds = %6
%18 = load i8**, i8*** %8
%19 = call i32 @code_table_6_0(i8** %18)
store i32 %19, i32* %13
%20 = load i32, i32* %13
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %60
22: ; preds = %17
%23 = load i8**, i8*** %8
%24 = getelementptr inbounds i8*, i8** %23, i64 3
%25 = load i8*, i8** %24
%26 = getelementptr inbounds i8, i8* %25, i64 6
%27 = call i32 @uint4(i8* %26)
%28 = load i8**, i8*** %8
%29 = getelementptr inbounds i8*, i8** %28, i64 5
%30 = load i8*, i8** %29
%31 = icmp ne i8* %30, null
br i1 %31, label %32, label %38
32: ; preds = %22
%33 = load i8**, i8*** %8
%34 = getelementptr inbounds i8*, i8** %33, i64 5
%35 = load i8*, i8** %34
%36 = getelementptr inbounds i8, i8* %35, i64 5
%37 = call i32 @uint4(i8* %36)
br label %39
38: ; preds = %22
br label %39
39: ; preds = %38, %32
%40 = phi i32 [ %37, %32 ], [ 0, %38 ]
%41 = sub i32 %27, %40
store i32 %41, i32* %14
%42 = load i8*, i8** %11
%43 = load i32, i32* %14
%44 = call i32 (i8*, i8*, ...) @sprintf(i8* %42, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %43)
%45 = load i32, i32* %14
%46 = load i8**, i8*** %8
%47 = getelementptr inbounds i8*, i8** %46, i64 6
%48 = load i8*, i8** %47
%49 = getelementptr inbounds i8, i8* %48, i64 6
%50 = load i8**, i8*** %8
%51 = getelementptr inbounds i8*, i8** %50, i64 3
%52 = load i8*, i8** %51
%53 = getelementptr inbounds i8, i8* %52, i64 6
%54 = call i32 @uint4(i8* %53)
%55 = call i32 @missing_points(i8* %49, i32 %54)
%56 = icmp ne i32 %45, %55
br i1 %56, label %57, label %59
57: ; preds = %39
%58 = call i32 @fatal_error(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
br label %59
59: ; preds = %57, %39
br label %78
60: ; preds = %17
%61 = load i32, i32* %13
%62 = icmp eq i32 %61, 255
br i1 %62, label %63, label %66
63: ; preds = %60
%64 = load i8*, i8** %11
%65 = call i32 (i8*, i8*, ...) @sprintf(i8* %64, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %77
66: ; preds = %60
%67 = load i32, i32* %13
%68 = icmp eq i32 %67, 254
br i1 %68, label %69, label %72
69: ; preds = %66
%70 = load i8*, i8** %11
%71 = call i32 (i8*, i8*, ...) @sprintf(i8* %70, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
br label %76
72: ; preds = %66
%73 = load i8*, i8** %11
%74 = load i32, i32* %13
%75 = call i32 (i8*, i8*, ...) @sprintf(i8* %73, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i32 %74)
br label %76
76: ; preds = %72, %69
br label %77
77: ; preds = %76, %63
br label %78
78: ; preds = %77, %59
br label %79
79: ; preds = %78, %6
ret i32 0
}

LLVM IR (-O2):
@.str = [20 x i8] c"bitmap %d undef pts\00"
@.str.1 = [40 x i8] c"inconsistent number of undefined points\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [10 x i8] c"no bitmap\00"
@.str.4 = [11 x i8] c"old bitmap\00"
@.str.5 = [22 x i8] c"predefined bitmap #%d\00"
define i32 @f_bitmap(i32 %0, i8** %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 %39
8: ; preds = %6
%9 = tail call i32 @code_table_6_0(i8** %1)
switch i32 %9, label %37 [
i32 0, label %10
i32 255, label %35
i32 254, label %36
]
10: ; preds = %8
%11 = getelementptr inbounds i8*, i8** %1, i64 3
%12 = load i8*, i8** %11
%13 = getelementptr inbounds i8, i8* %12, i64 6
%14 = tail call i32 @uint4(i8* %13)
%15 = getelementptr inbounds i8*, i8** %1, i64 5
%16 = load i8*, i8** %15
%17 = icmp eq i8* %16, null
br i1 %17, label %21, label %18
18: ; preds = %10
%19 = getelementptr inbounds i8, i8* %16, i64 5
%20 = tail call i32 @uint4(i8* %19)
br label %21
21: ; preds = %10, %18
%22 = phi i32 [ %20, %18 ], [ 0, %10 ]
%23 = sub i32 %14, %22
%24 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %4, i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %23)
%25 = getelementptr inbounds i8*, i8** %1, i64 6
%26 = load i8*, i8** %25
%27 = getelementptr inbounds i8, i8* %26, i64 6
%28 = load i8*, i8** %11
%29 = getelementptr inbounds i8, i8* %28, i64 6
%30 = tail call i32 @uint4(i8* %29)
%31 = tail call i32 @missing_points(i8* %27, i32 %30)
%32 = icmp eq i32 %23, %31
br i1 %32, label %39, label %33
33: ; preds = %21
%34 = tail call i32 @fatal_error(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
br label %39
35: ; preds = %8
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(10) %4, i8* align 1 dereferenceable(10) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i64 10, i1 false)
br label %39
36: ; preds = %8
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(11) %4, i8* align 1 dereferenceable(11) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i64 11, i1 false)
br label %39
37: ; preds = %8
%38 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %4, i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i32 %9)
br label %39
39: ; preds = %33, %21, %36, %37, %35, %6
ret i32 0
}