#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 */
long calcStuffBufferBitSize(unsigned char *, int);
int /*<<< orphan*/ printf(char *, ...);
int testFiveBitsEnd() {
  unsigned char testS[] = {0x00, 0xF8};
  long bits = calcStuffBufferBitSize(testS, 2);
  if (bits != 17) {
    printf("testFiveBitsEnd -- Failed 17 but got %ld\n", bits);
    return 1;
  }
  printf("testFiveBitsEnd -- Passed\n");
  return 0;
}


x86 assembly (clang, -O0):
<testFiveBitsEnd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0xed1(%rip),%ax
mov    %ax,-0x6(%rbp)
lea    -0x6(%rbp),%rdi
mov    $0x2,%esi
call   1040 <calcStuffBufferBitSize@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x11,-0x10(%rbp)
je     116e <testFiveBitsEnd+0x4e>
mov    -0x10(%rbp),%rsi
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1183 <testFiveBitsEnd+0x63>
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testFiveBitsEnd>:
push   %rax
movw   $0xf800,0x6(%rsp)
lea    0x6(%rsp),%rdi
mov    $0x2,%esi
call   1050 <calcStuffBufferBitSize@plt>
cmp    $0x11,%rax
jne    115d <testFiveBitsEnd+0x2d>
lea    0xed6(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret
lea    0xe9c(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%eax
pop    %rcx
ret

LLVM IR (-O0):
@__const.testFiveBitsEnd.testS = [2 x i8] c"\00\F8"
@.str = [42 x i8] c"testFiveBitsEnd -- Failed 17 but got %ld\0A\00"
@.str.1 = [27 x i8] c"testFiveBitsEnd -- Passed\0A\00"
define i32 @testFiveBitsEnd() {
%1 = alloca i32
%2 = alloca [2 x i8]
%3 = alloca i64
%4 = bitcast [2 x i8]* %2 to i8*
%5 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
%6 = call i64 @calcStuffBufferBitSize(i8* %5, i32 2)
store i64 %6, i64* %3
%7 = load i64, i64* %3
%8 = icmp ne i64 %7, 17
br i1 %8, label %9, label %12
9: ; preds = %0
%10 = load i64, i64* %3
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i64 %10)
store i32 1, i32* %1
br label %14
12: ; preds = %0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
br label %14
14: ; preds = %12, %9
%15 = load i32, i32* %1
ret i32 %15
}

LLVM IR (-O2):
@.str = [42 x i8] c"testFiveBitsEnd -- Failed 17 but got %ld\0A\00"
@str = [26 x i8] c"testFiveBitsEnd -- Passed\00"
define i32 @testFiveBitsEnd() {
%1 = alloca i16
%2 = bitcast i16* %1 to i8*
store i16 -2048, i16* %1
%3 = call i64 @calcStuffBufferBitSize(i8* %2, i32 2)
%4 = icmp eq i64 %3, 17
br i1 %4, label %7, label %5
5: ; preds = %0
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i64 %3)
br label %9
7: ; preds = %0
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
br label %9
9: ; preds = %7, %5
%10 = phi i32 [ 1, %5 ], [ 0, %7 ]
ret i32 %10
}