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


x86 assembly (clang, -O0):
<testFiveBitsStart>:
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 <testFiveBitsStart+0x4e>
mov    -0x10(%rbp),%rsi
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1183 <testFiveBitsStart+0x63>
lea    0xeb9(%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):
<testFiveBitsStart>:
push   %rax
movw   $0x1f,0x6(%rsp)
lea    0x6(%rsp),%rdi
mov    $0x2,%esi
call   1050 <calcStuffBufferBitSize@plt>
cmp    $0x11,%rax
jne    115d <testFiveBitsStart+0x2d>
lea    0xed8(%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.testFiveBitsStart.testS = [2 x i8] c"\1F\00"
@.str = [44 x i8] c"testFiveBitsStart -- Failed 17 but got %ld\0A\00"
@.str.1 = [29 x i8] c"testFiveBitsStart -- Passed\0A\00"
define i32 @testFiveBitsStart() {
%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 ([44 x i8], [44 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 ([29 x i8], [29 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 = [44 x i8] c"testFiveBitsStart -- Failed 17 but got %ld\0A\00"
@str = [28 x i8] c"testFiveBitsStart -- Passed\00"
define i32 @testFiveBitsStart() {
%1 = alloca i16
%2 = bitcast i16* %1 to i8*
store i16 31, 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 ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i64 %3)
br label %9
7: ; preds = %0
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
br label %9
9: ; preds = %7, %5
%10 = phi i32 [ 1, %5 ], [ 0, %7 ]
ret i32 %10
}