#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 _file_stream {
  int dummy;
};
struct _field_infos {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ add_internal(struct _field_infos *, char *, int, int);
int fs_read_byte(struct _file_stream *);
char *fs_read_string(struct _file_stream *);
int fs_read_vint(struct _file_stream *);
int /*<<< orphan*/ printf(char *, ...);
void field_infos_read(struct _field_infos *fieldinfos,
                      struct _file_stream *in) {
  int size = fs_read_vint(in);
  printf("field_infos_read:size: %d\n", size);
  int i;
  char *name;
  int bits;
  int is_indexed;
  int store_term_vector;
  for (i = 0; i < size; i++) {
    name = fs_read_string(in);
    printf("field_infos_read:fi->name: %s\n", name);
    bits = fs_read_byte(in);
    printf("field_infos_read:bits: %d\n", bits);
    is_indexed = (bits & 0x1) != 0;
    store_term_vector = (bits & 0x2) != 0;
    add_internal(fieldinfos, name, is_indexed, store_term_vector);
  }
}


x86 assembly (clang, -O0):
<field_infos_read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <fs_read_vint@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1215 <field_infos_read+0xc5>
mov    -0x10(%rbp),%rdi
call   1070 <fs_read_string@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1050 <fs_read_byte@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%esi
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%edx
mov    -0x2c(%rbp),%ecx
call   1040 <add_internal@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1184 <field_infos_read+0x34>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<field_infos_read>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r13
mov    %rdi,%r14
mov    %rsi,%rdi
call   1060 <fs_read_vint@plt>
mov    %eax,%ebp
lea    0xe8e(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
test   %ebp,%ebp
jle    11e3 <field_infos_read+0x93>
lea    0xeb4(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
mov    %r13,%rdi
call   1070 <fs_read_string@plt>
mov    %rax,%rbx
lea    0xe79(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r13,%rdi
call   1050 <fs_read_byte@plt>
mov    %eax,%r15d
mov    %r12,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15d,%edx
and    $0x1,%edx
shr    %r15d
and    $0x1,%r15d
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r15d,%ecx
call   1040 <add_internal@plt>
add    $0xffffffff,%ebp
jne    1190 <field_infos_read+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct._field_infos = type { i32 }
%struct._file_stream = type { i32 }
@.str = [27 x i8] c"field_infos_read:size: %d\0A\00"
@.str.1 = [31 x i8] c"field_infos_read:fi->name: %s\0A\00"
@.str.2 = [27 x i8] c"field_infos_read:bits: %d\0A\00"
define void @field_infos_read(%struct._field_infos* %0, %struct._file_stream* %1) {
%3 = alloca %struct._field_infos*
%4 = alloca %struct._file_stream*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store %struct._field_infos* %0, %struct._field_infos** %3
store %struct._file_stream* %1, %struct._file_stream** %4
%11 = load %struct._file_stream*, %struct._file_stream** %4
%12 = call i32 @fs_read_vint(%struct._file_stream* %11)
store i32 %12, i32* %5
%13 = load i32, i32* %5
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %13)
store i32 0, i32* %6
br label %15
15: ; preds = %41, %2
%16 = load i32, i32* %6
%17 = load i32, i32* %5
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %44
19: ; preds = %15
%20 = load %struct._file_stream*, %struct._file_stream** %4
%21 = call i8* @fs_read_string(%struct._file_stream* %20)
store i8* %21, i8** %7
%22 = load i8*, i8** %7
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %22)
%24 = load %struct._file_stream*, %struct._file_stream** %4
%25 = call i32 @fs_read_byte(%struct._file_stream* %24)
store i32 %25, i32* %8
%26 = load i32, i32* %8
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %26)
%28 = load i32, i32* %8
%29 = and i32 %28, 1
%30 = icmp ne i32 %29, 0
%31 = zext i1 %30 to i32
store i32 %31, i32* %9
%32 = load i32, i32* %8
%33 = and i32 %32, 2
%34 = icmp ne i32 %33, 0
%35 = zext i1 %34 to i32
store i32 %35, i32* %10
%36 = load %struct._field_infos*, %struct._field_infos** %3
%37 = load i8*, i8** %7
%38 = load i32, i32* %9
%39 = load i32, i32* %10
%40 = call i32 @add_internal(%struct._field_infos* %36, i8* %37, i32 %38, i32 %39)
br label %41
41: ; preds = %19
%42 = load i32, i32* %6
%43 = add nsw i32 %42, 1
store i32 %43, i32* %6
br label %15
44: ; preds = %15
ret void
}

LLVM IR (-O2):
%struct._field_infos = type { i32 }
%struct._file_stream = type { i32 }
@.str = [27 x i8] c"field_infos_read:size: %d\0A\00"
@.str.1 = [31 x i8] c"field_infos_read:fi->name: %s\0A\00"
@.str.2 = [27 x i8] c"field_infos_read:bits: %d\0A\00"
define void @field_infos_read(%struct._field_infos* %0, %struct._file_stream* %1) {
%3 = tail call i32 @fs_read_vint(%struct._file_stream* %1)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = icmp sgt i32 %3, 0
br i1 %5, label %6, label %18
6: ; preds = %2, %6
%7 = phi i32 [ %16, %6 ], [ 0, %2 ]
%8 = tail call i8* @fs_read_string(%struct._file_stream* %1)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = tail call i32 @fs_read_byte(%struct._file_stream* %1)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %10)
%12 = and i32 %10, 1
%13 = lshr i32 %10, 1
%14 = and i32 %13, 1
%15 = tail call i32 @add_internal(%struct._field_infos* %0, i8* %8, i32 %12, i32 %14)
%16 = add nuw nsw i32 %7, 1
%17 = icmp eq i32 %16, %3
br i1 %17, label %18, label %6
18: ; preds = %6, %2
ret void
}