#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 */
void *henten(int, int, unsigned char *);
int /*<<< orphan*/ printf(char *, ...);
void get_data(unsigned char *frame, int antall) {
  int i, j;
  unsigned char type = henten(0, 6, frame);
  printf("MessageID: %d\n", type);
  unsigned long mmsi = henten(8, 30, frame);
  printf("MMSI: %09d\n", mmsi);
  unsigned long longitude;
  unsigned long latitude;
  unsigned short sog;
  unsigned short heading, heading2;
  char rateofturn;
  char underway;
  switch (type) {
  case 1:
    longitude = henten(38 + 22, 29, frame);
    printf("Longitude: %f\n", (float)longitude / 600000);
    latitude = henten(38 + 22 + 29, 27, frame);
    printf("Latitude: %f\n", (float)latitude / 600000);
    heading = henten(38 + 22 + 28 + 28, 12, frame);
    printf("Heading: %f\n", (float)heading / 10);
    sog = henten(38 + 11, 10, frame);
    printf("Knots: %f\n", (float)sog / 10);
    rateofturn = henten(38 + 2, 8, frame);
    printf("Rateofturn: %i\n", rateofturn);
    underway = henten(38, 2, frame);
    printf("Underway: %d\n", underway);
    heading2 = henten(38 + 22 + 28 + 28 + 12, 9, frame);
    printf("Heading2: %d\n", heading2);
    break;
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<get_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdx
xor    %edi,%edi
mov    %edi,-0x40(%rbp)
mov    $0x6,%esi
call   1040 <henten@plt>
mov    %rax,%rcx
mov    -0x40(%rbp),%eax
mov    %cl,-0x15(%rbp)
movzbl -0x15(%rbp),%esi
lea    0xeb2(%rip),%rdi
mov    %al,-0x39(%rbp)
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdx
mov    $0x8,%edi
mov    $0x1e,%esi
call   1040 <henten@plt>
mov    %rax,%rcx
mov    -0x39(%rbp),%al
mov    %rcx,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xe91(%rip),%rdi
call   1030 <printf@plt>
mov    -0x15(%rbp),%al
sub    $0x1,%al
jne    1386 <get_data+0x266>
jmp    119b <get_data+0x7b>
mov    -0x8(%rbp),%rdx
mov    $0x3c,%edi
mov    $0x1d,%esi
call   1040 <henten@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rdx
shr    %rdx
mov    %eax,%ecx
and    $0x1,%ecx
or     %rdx,%rcx
cvtsi2ss %rcx,%xmm0
addss  %xmm0,%xmm0
cvtsi2ss %rax,%xmm1
movss  %xmm1,-0x48(%rbp)
test   %rax,%rax
movss  %xmm0,-0x44(%rbp)
js     11ef <get_data+0xcf>
movss  -0x48(%rbp),%xmm0
movss  %xmm0,-0x44(%rbp)
movss  -0x44(%rbp),%xmm0
movss  0xe08(%rip),%xmm1
movss  %xmm1,-0x58(%rbp)
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe13(%rip),%rdi
mov    $0x1,%al
mov    %al,-0x51(%rbp)
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdx
mov    $0x59,%edi
mov    $0x1b,%esi
call   1040 <henten@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,%rdx
shr    %rdx
mov    %eax,%ecx
and    $0x1,%ecx
or     %rdx,%rcx
cvtsi2ss %rcx,%xmm0
addss  %xmm0,%xmm0
cvtsi2ss %rax,%xmm1
movss  %xmm1,-0x50(%rbp)
test   %rax,%rax
movss  %xmm0,-0x4c(%rbp)
js     126e <get_data+0x14e>
movss  -0x50(%rbp),%xmm0
movss  %xmm0,-0x4c(%rbp)
mov    -0x51(%rbp),%al
movss  -0x58(%rbp),%xmm1
movss  -0x4c(%rbp),%xmm0
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xda8(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdx
mov    $0x74,%edi
mov    $0xc,%esi
call   1040 <henten@plt>
mov    %rax,%rcx
mov    -0x51(%rbp),%al
mov    %cx,-0x34(%rbp)
movzwl -0x34(%rbp),%ecx
cvtsi2ss %ecx,%xmm0
movss  0xd44(%rip),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd75(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdx
mov    $0x31,%edi
mov    $0xa,%esi
call   1040 <henten@plt>
mov    %ax,-0x32(%rbp)
movzwl -0x32(%rbp),%eax
cvtsi2ss %eax,%xmm0
movss  0xd09(%rip),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd47(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdx
mov    $0x28,%edi
mov    $0x8,%esi
call   1040 <henten@plt>
mov    %al,-0x37(%rbp)
movsbl -0x37(%rbp),%esi
lea    0xd2a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdx
mov    $0x26,%edi
mov    $0x2,%esi
call   1040 <henten@plt>
mov    %al,-0x38(%rbp)
movsbl -0x38(%rbp),%esi
lea    0xd12(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdx
mov    $0x80,%edi
mov    $0x9,%esi
call   1040 <henten@plt>
mov    %ax,-0x36(%rbp)
movzwl -0x36(%rbp),%esi
lea    0xcf7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xcf5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_data>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
xor    %edi,%edi
mov    $0x6,%esi
mov    %rbx,%rdx
call   1050 <henten@plt>
movzbl %al,%ebp
lea    0xeb9(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x8,%edi
mov    $0x1e,%esi
mov    %rbx,%rdx
call   1050 <henten@plt>
lea    0xea6(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x1,%ebp
jne    12f9 <get_data+0x1c9>
mov    $0x3c,%edi
mov    $0x1d,%esi
mov    %rbx,%rdx
call   1050 <henten@plt>
test   %rax,%rax
js     11a2 <get_data+0x72>
cvtsi2ss %rax,%xmm0
jmp    11b7 <get_data+0x87>
mov    %rax,%rcx
shr    %rcx
and    $0x1,%eax
or     %rcx,%rax
cvtsi2ss %rax,%xmm0
addss  %xmm0,%xmm0
divss  0xe41(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe59(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    $0x59,%edi
mov    $0x1b,%esi
mov    %rbx,%rdx
call   1050 <henten@plt>
test   %rax,%rax
js     11f2 <get_data+0xc2>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
jmp    120a <get_data+0xda>
mov    %rax,%rcx
shr    %rcx
and    $0x1,%eax
or     %rcx,%rax
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
addss  %xmm0,%xmm0
divss  0xdee(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe15(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    $0x74,%edi
mov    $0xc,%esi
mov    %rbx,%rdx
call   1050 <henten@plt>
movzwl %ax,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
divss  0xdbc(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xded(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    $0x31,%edi
mov    $0xa,%esi
mov    %rbx,%rdx
call   1050 <henten@plt>
movzwl %ax,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
divss  0xd86(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdc4(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    $0x28,%edi
mov    $0x8,%esi
mov    %rbx,%rdx
call   1050 <henten@plt>
movsbl %al,%esi
lea    0xdac(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x26,%edi
mov    $0x2,%esi
mov    %rbx,%rdx
call   1050 <henten@plt>
movsbl %al,%esi
lea    0xd99(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x80,%edi
mov    $0x9,%esi
mov    %rbx,%rdx
call   1050 <henten@plt>
movzwl %ax,%esi
lea    0xd84(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [15 x i8] c"MessageID: %d\0A\00"
@.str.1 = [12 x i8] c"MMSI: %09d\0A\00"
@.str.2 = [15 x i8] c"Longitude: %f\0A\00"
@.str.3 = [14 x i8] c"Latitude: %f\0A\00"
@.str.4 = [13 x i8] c"Heading: %f\0A\00"
@.str.5 = [11 x i8] c"Knots: %f\0A\00"
@.str.6 = [16 x i8] c"Rateofturn: %i\0A\00"
@.str.7 = [14 x i8] c"Underway: %d\0A\00"
@.str.8 = [14 x i8] c"Heading2: %d\0A\00"
@.str.9 = [2 x i8] c"\0A\00"
define void @get_data(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca i16
%12 = alloca i16
%13 = alloca i16
%14 = alloca i8
%15 = alloca i8
store i8* %0, i8** %3
store i32 %1, i32* %4
%16 = load i8*, i8** %3
%17 = call i8* @henten(i32 0, i32 6, i8* %16)
%18 = ptrtoint i8* %17 to i8
store i8 %18, i8* %7
%19 = load i8, i8* %7
%20 = zext i8 %19 to i32
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %20)
%22 = load i8*, i8** %3
%23 = call i8* @henten(i32 8, i32 30, i8* %22)
%24 = ptrtoint i8* %23 to i64
store i64 %24, i64* %8
%25 = load i64, i64* %8
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i64 %25)
%27 = load i8, i8* %7
%28 = zext i8 %27 to i32
switch i32 %28, label %80 [
i32 1, label %29
]
29: ; preds = %2
%30 = load i8*, i8** %3
%31 = call i8* @henten(i32 60, i32 29, i8* %30)
%32 = ptrtoint i8* %31 to i64
store i64 %32, i64* %9
%33 = load i64, i64* %9
%34 = uitofp i64 %33 to float
%35 = fdiv float %34, 6.000000e+05
%36 = fpext float %35 to double
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), double %36)
%38 = load i8*, i8** %3
%39 = call i8* @henten(i32 89, i32 27, i8* %38)
%40 = ptrtoint i8* %39 to i64
store i64 %40, i64* %10
%41 = load i64, i64* %10
%42 = uitofp i64 %41 to float
%43 = fdiv float %42, 6.000000e+05
%44 = fpext float %43 to double
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), double %44)
%46 = load i8*, i8** %3
%47 = call i8* @henten(i32 116, i32 12, i8* %46)
%48 = ptrtoint i8* %47 to i16
store i16 %48, i16* %12
%49 = load i16, i16* %12
%50 = uitofp i16 %49 to float
%51 = fdiv float %50, 1.000000e+01
%52 = fpext float %51 to double
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), double %52)
%54 = load i8*, i8** %3
%55 = call i8* @henten(i32 49, i32 10, i8* %54)
%56 = ptrtoint i8* %55 to i16
store i16 %56, i16* %11
%57 = load i16, i16* %11
%58 = uitofp i16 %57 to float
%59 = fdiv float %58, 1.000000e+01
%60 = fpext float %59 to double
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), double %60)
%62 = load i8*, i8** %3
%63 = call i8* @henten(i32 40, i32 8, i8* %62)
%64 = ptrtoint i8* %63 to i8
store i8 %64, i8* %14
%65 = load i8, i8* %14
%66 = sext i8 %65 to i32
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i32 %66)
%68 = load i8*, i8** %3
%69 = call i8* @henten(i32 38, i32 2, i8* %68)
%70 = ptrtoint i8* %69 to i8
store i8 %70, i8* %15
%71 = load i8, i8* %15
%72 = sext i8 %71 to i32
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i32 %72)
%74 = load i8*, i8** %3
%75 = call i8* @henten(i32 128, i32 9, i8* %74)
%76 = ptrtoint i8* %75 to i16
store i16 %76, i16* %13
%77 = load i16, i16* %13
%78 = zext i16 %77 to i32
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0), i32 %78)
br label %80
80: ; preds = %2, %29
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"MessageID: %d\0A\00"
@.str.1 = [12 x i8] c"MMSI: %09d\0A\00"
@.str.2 = [15 x i8] c"Longitude: %f\0A\00"
@.str.3 = [14 x i8] c"Latitude: %f\0A\00"
@.str.4 = [13 x i8] c"Heading: %f\0A\00"
@.str.5 = [11 x i8] c"Knots: %f\0A\00"
@.str.6 = [16 x i8] c"Rateofturn: %i\0A\00"
@.str.7 = [14 x i8] c"Underway: %d\0A\00"
@.str.8 = [14 x i8] c"Heading2: %d\0A\00"
define void @get_data(i8* %0, i32 %1) {
%3 = tail call i8* @henten(i32 0, i32 6, i8* %0)
%4 = ptrtoint i8* %3 to i64
%5 = trunc i64 %4 to i32
%6 = and i32 %5, 255
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = tail call i8* @henten(i32 8, i32 30, i8* %0)
%9 = ptrtoint i8* %8 to i64
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i64 %9)
%11 = icmp eq i32 %6, 1
br i1 %11, label %12, label %56
12: ; preds = %2
%13 = tail call i8* @henten(i32 60, i32 29, i8* %0)
%14 = ptrtoint i8* %13 to i64
%15 = uitofp i64 %14 to float
%16 = fdiv float %15, 6.000000e+05
%17 = fpext float %16 to double
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), double %17)
%19 = tail call i8* @henten(i32 89, i32 27, i8* %0)
%20 = ptrtoint i8* %19 to i64
%21 = uitofp i64 %20 to float
%22 = fdiv float %21, 6.000000e+05
%23 = fpext float %22 to double
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), double %23)
%25 = tail call i8* @henten(i32 116, i32 12, i8* %0)
%26 = ptrtoint i8* %25 to i64
%27 = trunc i64 %26 to i16
%28 = uitofp i16 %27 to float
%29 = fdiv float %28, 1.000000e+01
%30 = fpext float %29 to double
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), double %30)
%32 = tail call i8* @henten(i32 49, i32 10, i8* %0)
%33 = ptrtoint i8* %32 to i64
%34 = trunc i64 %33 to i16
%35 = uitofp i16 %34 to float
%36 = fdiv float %35, 1.000000e+01
%37 = fpext float %36 to double
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), double %37)
%39 = tail call i8* @henten(i32 40, i32 8, i8* %0)
%40 = ptrtoint i8* %39 to i64
%41 = trunc i64 %40 to i32
%42 = shl i32 %41, 24
%43 = ashr exact i32 %42, 24
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i32 %43)
%45 = tail call i8* @henten(i32 38, i32 2, i8* %0)
%46 = ptrtoint i8* %45 to i64
%47 = trunc i64 %46 to i32
%48 = shl i32 %47, 24
%49 = ashr exact i32 %48, 24
%50 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i32 %49)
%51 = tail call i8* @henten(i32 128, i32 9, i8* %0)
%52 = ptrtoint i8* %51 to i64
%53 = trunc i64 %52 to i32
%54 = and i32 %53, 65535
%55 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0), i32 %54)
br label %56
56: ; preds = %2, %12
%57 = tail call i32 @putchar(i32 10)
ret void
}