#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 */
struct bitstream {
  int dummy;
};

/* Variables and functions */
struct bitstream *create_bitstream(char *);
int /*<<< orphan*/ free_bitstream(struct bitstream *);
int /*<<< orphan*/ write_bitstream(struct bitstream *, int, int);
int main(void) {
  struct bitstream *stream = create_bitstream("test.b");
  write_bitstream(stream, 13, 0x5bc6);
  write_bitstream(stream, 3, 0x7);
  write_bitstream(stream, 5, 0x12);
  write_bitstream(stream, 32, 0x12345678);
  write_bitstream(stream, 3, 0x07);
  write_bitstream(stream, 1, 0x1);
  write_bitstream(stream, 4, 0xe);
  write_bitstream(stream, 2, 0x1);
  write_bitstream(stream, 1, 0x1);
  write_bitstream(stream, 7, 0x74);
  write_bitstream(stream, 16, 0x1234);
  free_bitstream(stream);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1030 <create_bitstream@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0xd,%esi
mov    $0x5bc6,%edx
call   1040 <write_bitstream@plt>
mov    -0x10(%rbp),%rdi
mov    $0x3,%esi
mov    $0x7,%edx
call   1040 <write_bitstream@plt>
mov    -0x10(%rbp),%rdi
mov    $0x5,%esi
mov    $0x12,%edx
call   1040 <write_bitstream@plt>
mov    -0x10(%rbp),%rdi
mov    $0x20,%esi
mov    $0x12345678,%edx
call   1040 <write_bitstream@plt>
mov    -0x10(%rbp),%rdi
mov    $0x3,%esi
mov    $0x7,%edx
call   1040 <write_bitstream@plt>
mov    -0x10(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1040 <write_bitstream@plt>
mov    -0x10(%rbp),%rdi
mov    $0x4,%esi
mov    $0xe,%edx
call   1040 <write_bitstream@plt>
mov    -0x10(%rbp),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
call   1040 <write_bitstream@plt>
mov    -0x10(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1040 <write_bitstream@plt>
mov    -0x10(%rbp),%rdi
mov    $0x7,%esi
mov    $0x74,%edx
call   1040 <write_bitstream@plt>
mov    -0x10(%rbp),%rdi
mov    $0x10,%esi
mov    $0x1234,%edx
call   1040 <write_bitstream@plt>
mov    -0x10(%rbp),%rdi
call   1050 <free_bitstream@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xec8(%rip),%rdi
call   1030 <create_bitstream@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0xd,%esi
mov    $0x5bc6,%edx
call   1040 <write_bitstream@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x7,%edx
call   1040 <write_bitstream@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
mov    $0x12,%edx
call   1040 <write_bitstream@plt>
mov    %rbx,%rdi
mov    $0x20,%esi
mov    $0x12345678,%edx
call   1040 <write_bitstream@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x7,%edx
call   1040 <write_bitstream@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
call   1040 <write_bitstream@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0xe,%edx
call   1040 <write_bitstream@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x1,%edx
call   1040 <write_bitstream@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
call   1040 <write_bitstream@plt>
mov    %rbx,%rdi
mov    $0x7,%esi
mov    $0x74,%edx
call   1040 <write_bitstream@plt>
mov    %rbx,%rdi
mov    $0x10,%esi
mov    $0x1234,%edx
call   1040 <write_bitstream@plt>
mov    %rbx,%rdi
call   1050 <free_bitstream@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.bitstream = type { i32 }
@.str = [7 x i8] c"test.b\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.bitstream*
store i32 0, i32* %1
%3 = call %struct.bitstream* @create_bitstream(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store %struct.bitstream* %3, %struct.bitstream** %2
%4 = load %struct.bitstream*, %struct.bitstream** %2
%5 = call i32 @write_bitstream(%struct.bitstream* %4, i32 13, i32 23494)
%6 = load %struct.bitstream*, %struct.bitstream** %2
%7 = call i32 @write_bitstream(%struct.bitstream* %6, i32 3, i32 7)
%8 = load %struct.bitstream*, %struct.bitstream** %2
%9 = call i32 @write_bitstream(%struct.bitstream* %8, i32 5, i32 18)
%10 = load %struct.bitstream*, %struct.bitstream** %2
%11 = call i32 @write_bitstream(%struct.bitstream* %10, i32 32, i32 305419896)
%12 = load %struct.bitstream*, %struct.bitstream** %2
%13 = call i32 @write_bitstream(%struct.bitstream* %12, i32 3, i32 7)
%14 = load %struct.bitstream*, %struct.bitstream** %2
%15 = call i32 @write_bitstream(%struct.bitstream* %14, i32 1, i32 1)
%16 = load %struct.bitstream*, %struct.bitstream** %2
%17 = call i32 @write_bitstream(%struct.bitstream* %16, i32 4, i32 14)
%18 = load %struct.bitstream*, %struct.bitstream** %2
%19 = call i32 @write_bitstream(%struct.bitstream* %18, i32 2, i32 1)
%20 = load %struct.bitstream*, %struct.bitstream** %2
%21 = call i32 @write_bitstream(%struct.bitstream* %20, i32 1, i32 1)
%22 = load %struct.bitstream*, %struct.bitstream** %2
%23 = call i32 @write_bitstream(%struct.bitstream* %22, i32 7, i32 116)
%24 = load %struct.bitstream*, %struct.bitstream** %2
%25 = call i32 @write_bitstream(%struct.bitstream* %24, i32 16, i32 4660)
%26 = load %struct.bitstream*, %struct.bitstream** %2
%27 = call i32 @free_bitstream(%struct.bitstream* %26)
ret i32 0
}

LLVM IR (-O2):
%struct.bitstream = type { i32 }
@.str = [7 x i8] c"test.b\00"
define i32 @main() {
%1 = tail call %struct.bitstream* @create_bitstream(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @write_bitstream(%struct.bitstream* %1, i32 13, i32 23494)
%3 = tail call i32 @write_bitstream(%struct.bitstream* %1, i32 3, i32 7)
%4 = tail call i32 @write_bitstream(%struct.bitstream* %1, i32 5, i32 18)
%5 = tail call i32 @write_bitstream(%struct.bitstream* %1, i32 32, i32 305419896)
%6 = tail call i32 @write_bitstream(%struct.bitstream* %1, i32 3, i32 7)
%7 = tail call i32 @write_bitstream(%struct.bitstream* %1, i32 1, i32 1)
%8 = tail call i32 @write_bitstream(%struct.bitstream* %1, i32 4, i32 14)
%9 = tail call i32 @write_bitstream(%struct.bitstream* %1, i32 2, i32 1)
%10 = tail call i32 @write_bitstream(%struct.bitstream* %1, i32 1, i32 1)
%11 = tail call i32 @write_bitstream(%struct.bitstream* %1, i32 7, i32 116)
%12 = tail call i32 @write_bitstream(%struct.bitstream* %1, i32 16, i32 4660)
%13 = tail call i32 @free_bitstream(%struct.bitstream* %1)
ret i32 0
}