#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 mem_param {
  int dummy;
};
struct mem_controller {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ order_dimms(struct mem_controller const *);
int /*<<< orphan*/ spd_enable_2channels(struct mem_controller const *);
int /*<<< orphan*/ spd_handle_unbuffered_dimms(struct mem_controller const *);
int /*<<< orphan*/ spd_set_dram_timing(struct mem_controller const *,
                                       struct mem_param const *);
struct mem_param *spd_set_memclk(struct mem_controller const *);
int /*<<< orphan*/ spd_set_ram_size(struct mem_controller const *);
void sdram_set_spd_registers(const struct mem_controller *ctrl) {
  const struct mem_param *param;
  spd_enable_2channels(ctrl);
  spd_set_ram_size(ctrl);
  spd_handle_unbuffered_dimms(ctrl);
  param = spd_set_memclk(ctrl);
  spd_set_dram_timing(ctrl, param);
  order_dimms(ctrl);
}


x86 assembly (clang, -O0):
<sdram_set_spd_registers>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <spd_enable_2channels@plt>
mov    -0x8(%rbp),%rdi
call   1030 <spd_set_ram_size@plt>
mov    -0x8(%rbp),%rdi
call   1060 <spd_handle_unbuffered_dimms@plt>
mov    -0x8(%rbp),%rdi
call   1070 <spd_set_memclk@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <spd_set_dram_timing@plt>
mov    -0x8(%rbp),%rdi
call   1080 <order_dimms@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sdram_set_spd_registers>:
push   %rbx
mov    %rdi,%rbx
call   1050 <spd_enable_2channels@plt>
mov    %rbx,%rdi
call   1030 <spd_set_ram_size@plt>
mov    %rbx,%rdi
call   1060 <spd_handle_unbuffered_dimms@plt>
mov    %rbx,%rdi
call   1070 <spd_set_memclk@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1040 <spd_set_dram_timing@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1080 <order_dimms@plt>

LLVM IR (-O0):
%struct.mem_controller = type { i32 }
%struct.mem_param = type { i32 }
define void @sdram_set_spd_registers(%struct.mem_controller* %0) {
%2 = alloca %struct.mem_controller*
%3 = alloca %struct.mem_param*
store %struct.mem_controller* %0, %struct.mem_controller** %2
%4 = load %struct.mem_controller*, %struct.mem_controller** %2
%5 = call i32 @spd_enable_2channels(%struct.mem_controller* %4)
%6 = load %struct.mem_controller*, %struct.mem_controller** %2
%7 = call i32 @spd_set_ram_size(%struct.mem_controller* %6)
%8 = load %struct.mem_controller*, %struct.mem_controller** %2
%9 = call i32 @spd_handle_unbuffered_dimms(%struct.mem_controller* %8)
%10 = load %struct.mem_controller*, %struct.mem_controller** %2
%11 = call %struct.mem_param* @spd_set_memclk(%struct.mem_controller* %10)
store %struct.mem_param* %11, %struct.mem_param** %3
%12 = load %struct.mem_controller*, %struct.mem_controller** %2
%13 = load %struct.mem_param*, %struct.mem_param** %3
%14 = call i32 @spd_set_dram_timing(%struct.mem_controller* %12, %struct.mem_param* %13)
%15 = load %struct.mem_controller*, %struct.mem_controller** %2
%16 = call i32 @order_dimms(%struct.mem_controller* %15)
ret void
}

LLVM IR (-O2):
%struct.mem_controller = type { i32 }
%struct.mem_param = type { i32 }
define void @sdram_set_spd_registers(%struct.mem_controller* %0) {
%2 = tail call i32 @spd_enable_2channels(%struct.mem_controller* %0)
%3 = tail call i32 @spd_set_ram_size(%struct.mem_controller* %0)
%4 = tail call i32 @spd_handle_unbuffered_dimms(%struct.mem_controller* %0)
%5 = tail call %struct.mem_param* @spd_set_memclk(%struct.mem_controller* %0)
%6 = tail call i32 @spd_set_dram_timing(%struct.mem_controller* %0, %struct.mem_param* %5)
%7 = tail call i32 @order_dimms(%struct.mem_controller* %0)
ret void
}