#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 */
typedef int uint32_t;
struct razor_rpm {
  int dummy;
};
struct razor_importer {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ ntohl(int const);
int /*<<< orphan*/ razor_importer_add_property(struct razor_importer *,
                                               char const *, int, char const *);
void *razor_rpm_get_indirect(struct razor_rpm *, int, unsigned int *);
int rpm_to_razor_flags(int /*<<< orphan*/);
scalar_t__ strlen(char const *);
void import_properties(struct razor_importer *importer, uint32_t type,
                       struct razor_rpm *rpm, int name_tag, int version_tag,
                       int flags_tag) {
  const char *name, *version;
  const uint32_t *flags;
  uint32_t f;
  unsigned int i, count;
  name = razor_rpm_get_indirect(rpm, name_tag, &count);
  if (name == NULL)
    return;
  flags = razor_rpm_get_indirect(rpm, flags_tag, &count);
  version = razor_rpm_get_indirect(rpm, version_tag, &count);
  for (i = 0; i < count; i++) {
    f = rpm_to_razor_flags(ntohl(flags[i]));
    razor_importer_add_property(importer, name, f | type, version);
    name += strlen(name) + 1;
    version += strlen(version) + 1;
  }
}


x86 assembly (clang, -O0):
<import_properties>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
lea    -0x4c(%rbp),%rdx
call   1040 <razor_rpm_get_indirect@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1192 <import_properties+0x42>
jmp    1235 <import_properties+0xe5>
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%esi
lea    -0x4c(%rbp),%rdx
call   1040 <razor_rpm_get_indirect@plt>
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%esi
lea    -0x4c(%rbp),%rdx
call   1040 <razor_rpm_get_indirect@plt>
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x48(%rbp)
mov    -0x48(%rbp),%eax
cmp    -0x4c(%rbp),%eax
jae    1235 <import_properties+0xe5>
mov    -0x40(%rbp),%rax
mov    -0x48(%rbp),%ecx
mov    (%rax,%rcx,4),%edi
call   1070 <ntohl@plt>
mov    %eax,%edi
call   1050 <rpm_to_razor_flags@plt>
mov    %eax,-0x44(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x44(%rbp),%edx
or     -0xc(%rbp),%edx
mov    -0x38(%rbp),%rcx
call   1060 <razor_importer_add_property@plt>
mov    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
add    $0x1,%rax
add    -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x38(%rbp),%rdi
call   1030 <strlen@plt>
add    $0x1,%rax
add    -0x38(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    11c1 <import_properties+0x71>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<import_properties>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,%r12d
mov    %r8d,%ebp
mov    %rdx,%rbx
mov    %esi,%r14d
mov    %rdi,%r15
lea    0x4(%rsp),%rdx
mov    %rbx,%rdi
mov    %ecx,%esi
call   1040 <razor_rpm_get_indirect@plt>
test   %rax,%rax
je     120e <import_properties+0xbe>
mov    %rax,%r13
lea    0x4(%rsp),%rdx
mov    %rbx,%rdi
mov    %r12d,%esi
call   1040 <razor_rpm_get_indirect@plt>
mov    %rax,%r12
mov    %rbx,%rdi
mov    %ebp,%esi
lea    0x4(%rsp),%rdx
call   1040 <razor_rpm_get_indirect@plt>
cmpl   $0x0,0x4(%rsp)
je     120e <import_properties+0xbe>
mov    %rax,%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r12,%rbp,4),%edi
call   1070 <ntohl@plt>
mov    %eax,%edi
call   1050 <rpm_to_razor_flags@plt>
or     %r14d,%eax
mov    %r15,%rdi
mov    %r13,%rsi
mov    %eax,%edx
mov    %rbx,%rcx
call   1060 <razor_importer_add_property@plt>
mov    %r13,%rdi
call   1030 <strlen@plt>
add    %rax,%r13
add    $0x1,%r13
mov    %rbx,%rdi
call   1030 <strlen@plt>
add    %rax,%rbx
add    $0x1,%rbx
add    $0x1,%rbp
mov    0x4(%rsp),%eax
cmp    %rax,%rbp
jb     11c0 <import_properties+0x70>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.razor_importer = type { i32 }
%struct.razor_rpm = type { i32 }
define void @import_properties(%struct.razor_importer* %0, i32 %1, %struct.razor_rpm* %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca %struct.razor_importer*
%8 = alloca i32
%9 = alloca %struct.razor_rpm*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i32*
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
store %struct.razor_importer* %0, %struct.razor_importer** %7
store i32 %1, i32* %8
store %struct.razor_rpm* %2, %struct.razor_rpm** %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i32 %5, i32* %12
%19 = load %struct.razor_rpm*, %struct.razor_rpm** %9
%20 = load i32, i32* %10
%21 = call i8* @razor_rpm_get_indirect(%struct.razor_rpm* %19, i32 %20, i32* %18)
store i8* %21, i8** %13
%22 = load i8*, i8** %13
%23 = icmp eq i8* %22, null
br i1 %23, label %24, label %25
24: ; preds = %6
br label %65
25: ; preds = %6
%26 = load %struct.razor_rpm*, %struct.razor_rpm** %9
%27 = load i32, i32* %12
%28 = call i8* @razor_rpm_get_indirect(%struct.razor_rpm* %26, i32 %27, i32* %18)
%29 = bitcast i8* %28 to i32*
store i32* %29, i32** %15
%30 = load %struct.razor_rpm*, %struct.razor_rpm** %9
%31 = load i32, i32* %11
%32 = call i8* @razor_rpm_get_indirect(%struct.razor_rpm* %30, i32 %31, i32* %18)
store i8* %32, i8** %14
store i32 0, i32* %17
br label %33
33: ; preds = %62, %25
%34 = load i32, i32* %17
%35 = load i32, i32* %18
%36 = icmp ult i32 %34, %35
br i1 %36, label %37, label %65
37: ; preds = %33
%38 = load i32*, i32** %15
%39 = load i32, i32* %17
%40 = zext i32 %39 to i64
%41 = getelementptr inbounds i32, i32* %38, i64 %40
%42 = load i32, i32* %41
%43 = call i32 @ntohl(i32 %42)
%44 = call i32 @rpm_to_razor_flags(i32 %43)
store i32 %44, i32* %16
%45 = load %struct.razor_importer*, %struct.razor_importer** %7
%46 = load i8*, i8** %13
%47 = load i32, i32* %16
%48 = load i32, i32* %8
%49 = or i32 %47, %48
%50 = load i8*, i8** %14
%51 = call i32 @razor_importer_add_property(%struct.razor_importer* %45, i8* %46, i32 %49, i8* %50)
%52 = load i8*, i8** %13
%53 = call i64 @strlen(i8* %52)
%54 = add nsw i64 %53, 1
%55 = load i8*, i8** %13
%56 = getelementptr inbounds i8, i8* %55, i64 %54
store i8* %56, i8** %13
%57 = load i8*, i8** %14
%58 = call i64 @strlen(i8* %57)
%59 = add nsw i64 %58, 1
%60 = load i8*, i8** %14
%61 = getelementptr inbounds i8, i8* %60, i64 %59
store i8* %61, i8** %14
br label %62
62: ; preds = %37
%63 = load i32, i32* %17
%64 = add i32 %63, 1
store i32 %64, i32* %17
br label %33
65: ; preds = %24, %33
ret void
}

LLVM IR (-O2):
%struct.razor_importer = type { i32 }
%struct.razor_rpm = type { i32 }
define void @import_properties(%struct.razor_importer* %0, i32 %1, %struct.razor_rpm* %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca i32
%8 = bitcast i32* %7 to i8*
%9 = call i8* @razor_rpm_get_indirect(%struct.razor_rpm* %2, i32 %3, i32* %7)
%10 = icmp eq i8* %9, null
br i1 %10, label %37, label %11
11: ; preds = %6
%12 = call i8* @razor_rpm_get_indirect(%struct.razor_rpm* %2, i32 %5, i32* %7)
%13 = bitcast i8* %12 to i32*
%14 = call i8* @razor_rpm_get_indirect(%struct.razor_rpm* %2, i32 %4, i32* %7)
%15 = load i32, i32* %7
%16 = icmp eq i32 %15, 0
br i1 %16, label %37, label %17
17: ; preds = %11, %17
%18 = phi i64 [ %33, %17 ], [ 0, %11 ]
%19 = phi i8* [ %29, %17 ], [ %9, %11 ]
%20 = phi i8* [ %32, %17 ], [ %14, %11 ]
%21 = getelementptr inbounds i32, i32* %13, i64 %18
%22 = load i32, i32* %21
%23 = call i32 @ntohl(i32 %22)
%24 = call i32 @rpm_to_razor_flags(i32 %23)
%25 = or i32 %24, %1
%26 = call i32 @razor_importer_add_property(%struct.razor_importer* %0, i8* %19, i32 %25, i8* %20)
%27 = call i64 @strlen(i8* dereferenceable(1) %19)
%28 = add nsw i64 %27, 1
%29 = getelementptr inbounds i8, i8* %19, i64 %28
%30 = call i64 @strlen(i8* dereferenceable(1) %20)
%31 = add nsw i64 %30, 1
%32 = getelementptr inbounds i8, i8* %20, i64 %31
%33 = add nuw nsw i64 %18, 1
%34 = load i32, i32* %7
%35 = zext i32 %34 to i64
%36 = icmp ult i64 %33, %35
br i1 %36, label %17, label %37
37: ; preds = %17, %11, %6
ret void
}