#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 record {
  int dummy;
};

/* Variables and functions */
struct record *cdf_record_update(struct record *, unsigned long);
struct record **record_find(int);
void pmf_generic(int pid, unsigned long int time, int type) {
  struct record **r = record_find(pid);
  if (!r)
    return;
  r[type] = cdf_record_update(r[type], time);
}


x86 assembly (clang, -O0):
<pmf_generic>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <record_find@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    114e <pmf_generic+0x2e>
jmp    1172 <pmf_generic+0x52>
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <cdf_record_update@plt>
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pmf_generic>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebp
mov    %rsi,%r14
call   1030 <record_find@plt>
test   %rax,%rax
je     1149 <pmf_generic+0x29>
mov    %rax,%rbx
movslq %ebp,%rbp
mov    (%rax,%rbp,8),%rdi
mov    %r14,%rsi
call   1040 <cdf_record_update@plt>
mov    %rax,(%rbx,%rbp,8)
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.record = type { i32 }
define void @pmf_generic(i32 %0, i64 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i64
%6 = alloca i32
%7 = alloca %struct.record**
store i32 %0, i32* %4
store i64 %1, i64* %5
store i32 %2, i32* %6
%8 = load i32, i32* %4
%9 = call %struct.record** @record_find(i32 %8)
store %struct.record** %9, %struct.record*** %7
%10 = load %struct.record**, %struct.record*** %7
%11 = icmp ne %struct.record** %10, null
br i1 %11, label %13, label %12
12: ; preds = %3
br label %25
13: ; preds = %3
%14 = load %struct.record**, %struct.record*** %7
%15 = load i32, i32* %6
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds %struct.record*, %struct.record** %14, i64 %16
%18 = load %struct.record*, %struct.record** %17
%19 = load i64, i64* %5
%20 = call %struct.record* @cdf_record_update(%struct.record* %18, i64 %19)
%21 = load %struct.record**, %struct.record*** %7
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds %struct.record*, %struct.record** %21, i64 %23
store %struct.record* %20, %struct.record** %24
br label %25
25: ; preds = %13, %12
ret void
}

LLVM IR (-O2):
%struct.record = type { i32 }
define void @pmf_generic(i32 %0, i64 %1, i32 %2) {
%4 = tail call %struct.record** @record_find(i32 %0)
%5 = icmp eq %struct.record** %4, null
br i1 %5, label %11, label %6
6: ; preds = %3
%7 = sext i32 %2 to i64
%8 = getelementptr inbounds %struct.record*, %struct.record** %4, i64 %7
%9 = load %struct.record*, %struct.record** %8
%10 = tail call %struct.record* @cdf_record_update(%struct.record* %9, i64 %1)
store %struct.record* %10, %struct.record** %8
br label %11
11: ; preds = %3, %6
ret void
}